. lib/constants_secrets # PATH_REL_SECRETS, PATH_SECRETS, PATH_SECRETS_BORGKEYS
. lib/constants_ssh # PATH_USER_SSH
. lib/constants_user # USERNAME
-. lib/mount_secrets # mount_secrets, copy_and_unmount_secrets
+. lib/copy_and_unmount_secrets
+. lib/mount_secrets
+. lib/prefixed_msg
+
+prefixed_msg_init
abort_if_exists "${PATH_SECRETS}"
-echo "Collecting new ${PATH_REL_SECRETS}."
+prefixed_msg "Collecting new ${PATH_REL_SECRETS}."
mkdir "${PATH_SECRETS}"
"${NAME_BORGAPP}" backup_keys "${PATH_SECRETS_BORGKEYS}"
cp -a "${PATH_USER_SSH}" "${PATH_SECRETS_SSH}"
-echo "secrets file, last update: $(whoami)/$(hostname) at $(date)" > "${PATH_SECRETS}/info"
+prefixed_msg "secrets file, last update: $(whoami)/$(hostname) at $(date)" > "${PATH_SECRETS}/info"
mount_secrets "$1" # sets PATH_MOUNTED_SECRETS
SUFFIX_OLD=.old
PATH_REL_SECRETS_OLD="${PATH_REL_SECRETS}${SUFFIX_OLD}"
PATH_MOUNTED_SECRETS_OLD="${PATH_MOUNTED_SECRETS}${SUFFIX_OLD}"
if [ -d "${PATH_MOUNTED_SECRETS}" ]; then
- echo "Drive already has ${PATH_REL_SECRETS}, moving to ${PATH_REL_SECRETS_OLD}."
+ prefixed_msg "Drive already has ${PATH_REL_SECRETS}, moving to ${PATH_REL_SECRETS_OLD}."
rm -rf "${PATH_MOUNTED_SECRETS_OLD}"
mv "${PATH_MOUNTED_SECRETS}" "${PATH_MOUNTED_SECRETS_OLD}"
fi
copy_and_unmount_secrets 'out'
+
+prefixed_msg_exit
--- /dev/null
+../../../../../scripts/lib/copy_and_unmount_secrets
\ No newline at end of file
# so we don't have to enter our SSH key password all the time
-eval $(ssh-agent) && ssh-add
+eval $(ssh-agent) && ssh-add -q
# zero audio volume (rather than "just" mute)
vol 0
. lib/constants_ssh # PATH_USER_SSH
. lib/constants_user # USERNAME
. lib/constants_borg # NAME_BORGAPP
-. lib/mount_secrets # mount_secrets, copy_and_unmount_secrets
+. lib/copy_and_unmount_secrets
+. lib/mount_secrets
. lib/prefixed_msg
. lib/retry_until
. lib/trapp
mkdir "${PATH_REPOS}"
cd "${PATH_REPOS}"
ssh ${REPOS_SITE_LOGIN} "cd ${REMOTE_PATH_REPOS} && ls -1" | while read REPO_NAME; do
- git clone --recurse "${REPOS_SITE_LOGIN}:${REMOTE_PATH_REPOS}/${REPO_NAME}"
+ git clone --quiet --recurse "${REPOS_SITE_LOGIN}:${REMOTE_PATH_REPOS}/${REPO_NAME}"
done
cd - > /dev/null
-prefixed_msg '# Setting up borg and pull in ~/org …'
+prefixed_msg 'Setting up borg and pull in ~/org …'
cd "${PATH_SECRETS_BORGKEYS}"
ls -1 | while read _FILENAME; do
"${NAME_BORGAPP}" claim "${_FILENAME}"
fi
prefixed_msg "In ${PATH_KNOWN_HOSTS}, removing previous entry for ${SERVER} if found …"
-ssh-keygen -f "${PATH_KNOWN_HOSTS}" -R "${SERVER}" > /dev/null
+ssh-keygen -q -f "${PATH_KNOWN_HOSTS}" -R "${SERVER}"
prefixed_msg 'Scanning server for new key to add to file …'
PATH_LOG_KEYSCAN_STDERR=$(path_tmp_timestamped)
--- /dev/null
+. lib/constants_secrets # PATH_REL_SECRETS, PATH_SECRETS
+
+copy_and_unmount_secrets() {
+prefixed_msg_init copy_and_unmount_secrets
+
+prefixed_msg "Copying over ${PATH_REL_SECRETS}."
+if [ "$1" = "out" ]; then
+ cp -a "${PATH_SECRETS}" "${PATH_MOUNTED_SECRETS}"
+elif [ "$1" = "in" ]; then
+ cp -a "${PATH_MOUNTED_SECRETS}" "${PATH_SECRETS}"
+else
+ abort "Illegal argument to unmount_secrets."
+fi
+pumount "${SECRETS_DEV}"
+prefixed_msg "You can remove device ${SECRETS_DEV} now."
+
+prefixed_msg_exit
+}
. lib/retry_until
mount_secrets() {
- prefixed_msg_init mount_secrets
- expect_n_args 1 1 "(device name, e.g. 'sda')" $@
- SECRETS_DEV=$1
- if [ -z "${SECRETS_DEV}" ]; then
- abort "Aborting due to empty device argument."
- fi
- PATH_MOUNTED_SECRETS="${PATH_MEDIA}/${SECRETS_DEV}/${PATH_REL_SECRETS}"
- PATH_DEV="/dev/${SECRETS_DEV}"
- PATH_PMOUNT_ERR="$(path_tmp_timestamped 'err_mount')"
- prefixed_msg "Put secrets drive into slot for ${PATH_DEV}."
- while [ ! -e "${PATH_DEV}" ]; do
- sleep 0.1
- done
- _ON_LOOP_START='prefixed_msg_no_nl "Passphrase: "; PASSPHRASE=$(get_passphrase); echo ""'
- _TO_TEST='echo "${PASSPHRASE}" | pmount "${PATH_DEV}" 2>&1'
- _ON_FAIL='prefixed_msg "Aborting due to pmount error:"'
- retry_until 100 "${_ON_LOOP_START}" "${_TO_TEST}" "${_ON_FAIL}"
- prefixed_msg "${_OUTPUT}"
- prefixed_msg_exit
-}
+prefixed_msg_init mount_secrets
+
+expect_n_args 1 1 "(device name, e.g. 'sda')" $@
+SECRETS_DEV=$1
+if [ -z "${SECRETS_DEV}" ]; then
+ abort "Aborting due to empty device argument."
+fi
+PATH_MOUNTED_SECRETS="${PATH_MEDIA}/${SECRETS_DEV}/${PATH_REL_SECRETS}"
+PATH_DEV="/dev/${SECRETS_DEV}"
+PATH_PMOUNT_ERR="$(path_tmp_timestamped 'err_mount')"
+prefixed_msg "Put secrets drive into slot for ${PATH_DEV}."
+while [ ! -e "${PATH_DEV}" ]; do
+ sleep 0.1
+done
+_ON_LOOP_START='prefixed_msg_no_nl "Passphrase: "; PASSPHRASE=$(get_passphrase); echo ""'
+_TO_TEST='echo "${PASSPHRASE}" | pmount "${PATH_DEV}" 2>&1'
+_ON_FAIL='prefixed_msg "Aborting due to pmount error:"'
+retry_until 100 "${_ON_LOOP_START}" "${_TO_TEST}" "${_ON_FAIL}"
+prefixed_msg "${_OUTPUT}"
-copy_and_unmount_secrets() {
- prefixed_msg_init copy_and_unmount_secrets
- prefixed_msg "Copying over ${PATH_REL_SECRETS}."
- if [ "$1" = "out" ]; then
- cp -a "${PATH_SECRETS}" "${PATH_MOUNTED_SECRETS}"
- elif [ "$1" = "in" ]; then
- cp -a "${PATH_MOUNTED_SECRETS}" "${PATH_SECRETS}"
- else
- abort "Illegal argument to unmount_secrets."
- fi
- pumount "${SECRETS_DEV}"
- prefixed_msg "You can remove device ${SECRETS_DEV} now."
- prefixed_msg_exit
+prefixed_msg_exit
}
. lib/put_finished_marker
prefixed_msg_init
+prefixed_msg 'starting …'
PATH_NETWORK_INTERFACES="${PATH_ETC}/network/interfaces"
THINKPAD_NAMES="x220 w530 t490s"
WLAN_SSID=$(get_network_interfaces_last_wpa_value 'ssid')
WLAN_PSK=$(get_network_interfaces_last_wpa_value 'psk')
if [ ! -z "${WLAN_SSID}" ]; then
- prefixed_msg "Found, adding to NetworkManager."
+ prefixed_msg_no_nl "Found, adding to NetworkManager: "
if [ -z "${WLAN_PSK}" ]; then
nmcli connection add type wifi wifi.ssid "${WLAN_SSID}"
else # NB: assumes last (collected with tail -1) wpa-psk that of last wlan-ssid