From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 11 Mar 2025 23:13:51 +0000 (+0100)
Subject: Various minor fixes.
X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/todo?a=commitdiff_plain;h=531dd511b9831d7caeb15e80832dce33baf5bdd4;p=config
Various minor fixes.
---
diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom
index 4010829..cd48a0b 100755
--- a/testing/home/desktop/.local/bin/borgplom
+++ b/testing/home/desktop/.local/bin/borgplom
@@ -1,5 +1,6 @@
#!/bin/sh
set -e
+. "${HOME}/.nonpath_bins/plomlib.sh"
PATH_BORGKEYS="${HOME}/.config/borg/keys"
NAME_REPO=borg
@@ -21,12 +22,8 @@ if [ "$1" = "orgpull" ]; then
REPO="${NAME_SERVER}:${NAME_REPO}"
while true; do
if [ -z "${BORG_PASSPHRASE}" ]; then
- stty -echo
- printf "Borg passphrase: "
- read passphrase
- stty echo
- printf "\n"
- export BORG_PASSPHRASE="${passphrase}"
+ get_passphrase
+ export BORG_PASSPHRASE="${PASSPHRASE}"
fi
set +e
ARCHIVES=$(borg list "${REPO}") # separate step so we may fail early on bad passphrase
@@ -37,9 +34,8 @@ if [ "$1" = "orgpull" ]; then
elif [ "${RESULT}" != "2" ]; then
echo "Aborting due to unexpected ${NAME_BORGAPP} error."
exit 1
- else
- export BORG_PASSPHRASE=""
fi
+ export BORG_PASSPHRASE=""
done
ARCHIVE=$(echo "${ARCHIVES}" | grep "${NAME_ARCHIVE}" | tail -1 | cut -f1 -d' ')
echo "Pulling archive: ${ARCHIVE}"
diff --git a/testing/scripts/_misc.sh b/testing/scripts/_misc.sh
index 760dda7..327d85a 100644
--- a/testing/scripts/_misc.sh
+++ b/testing/scripts/_misc.sh
@@ -1,31 +1,29 @@
-#!/bin/sh
-set -e
-
. ../../constants.sh
. "${PATH_MANY_MISC}"
+. "${HOME}/.nonpath_bins/plomlib.sh"
PATH_REL_SECRETS=to_usb
PATH_SECRETS=${PATH_USER_HOME}/${PATH_REL_SECRETS}
get_system_name_arg() {
- thinkpad_names="x220 w530 t490s"
- legal_system_names="${thinkpad_names} h610m"
- found=0
- for system_name_i in $legal_system_names; do
- if [ "$1" = "$system_name_i" ]; then
- found=1
- system_name="${system_name_i}"
+ THINKPAD_NAMES="x220 w530 t490s"
+ LEGAL_SYSTEM_NAMES="${THINKPAD_NAMES} h610m"
+ FOUND=0
+ for SYSTEM_NAME_I in $LEGAL_SYSTEM_NAMES; do
+ if [ "$1" = "$SYSTEM_NAME_I" ]; then
+ FOUND=1
+ SYSTEM_NAME="${SYSTEM_NAME_I}"
break
fi
done
- if [ "$found" = 0 ]; then
+ if [ "${FOUND}" = 0 ]; then
echo "Need legal system name."
false
fi
- system_class_name=
- for thinkpad_name in $thinkpad_names; do
- if [ "${system_name}" = "${thinkpad_name}" ]; then
- system_class_name=thinkpad
+ SYSTEM_CLASS_NAME=
+ for THINKPAD_NAME in $THINKPAD_NAMES; do
+ if [ "${SYSTEM_NAME}" = "${THINKPAD_NAME}" ]; then
+ SYSTEM_CLASS_NAME=thinkpad
break
fi
done
@@ -33,14 +31,14 @@ get_system_name_arg() {
abort_if_exists() {
if [ -e "${1}" ]; then
- echo "Aborting because ${1} already exists."
+ echo "Aborting because $1 already exists."
exit 1
fi
}
abort_if_not_user() {
if [ `whoami` != "$1" ]; then
- echo "Must be run as $1."
+ echo "Must be run as ${1}."
exit 1
fi
}
diff --git a/testing/scripts/setup_desktop.sh b/testing/scripts/setup_desktop.sh
index f954302..78cce2f 100755
--- a/testing/scripts/setup_desktop.sh
+++ b/testing/scripts/setup_desktop.sh
@@ -6,7 +6,7 @@ set -x
expect_min_n_args 1 "(system name)" "$@"
abort_if_offline
get_system_name_arg "$1"
-MIN_MODULES="all ${system_class_name} ${system_name}"
+MIN_MODULES="all ${SYSTEM_CLASS_NAME} ${SYSTEM_NAME}"
# For upgrading only very selectively prepare /etc/ files.
PATH_REL_APT=apt
@@ -24,8 +24,8 @@ apt -y -o Dpkg::Options::='--force-confnew' full-upgrade
apt -y autoremove
# Set hostname and FQDN.
-echo "${system_name}" > /etc/hostname
-hostname "${system_name}"
+echo "${SYSTEM_NAME}" > /etc/hostname
+hostname "${SYSTEM_NAME}"
final_ip="127.0.1.1"
for ip in $(hostname -I); do
if [ $(echo "${ip}" | grep ':' | wc -l) -eq 1 ]; then
@@ -49,12 +49,12 @@ for ip in $(hostname -I); do
final_ip="${ip}"
done
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
-echo "${final_ip} ${system_name}" >> /etc/hosts
+echo "${final_ip} ${SYSTEM_NAME}" >> /etc/hosts
# Ensure package installation state as defined by what packages are
# defined as required by Debian policy and by settings in ./apt-mark/.
mark_nonrequireds_auto
-if [ "$system_name" = "h610m" ]; then
+if [ "${SYSTEM_NAME}" = "h610m" ]; then
# Hold kernel known to work with nvidia-drivers.
apt-mark hold linux-image-amd64 linux-headers-amd64
fi
diff --git a/testing/scripts/setup_secrets_root.sh b/testing/scripts/setup_secrets_root.sh
index 2a8f8f2..486aa8f 100755
--- a/testing/scripts/setup_secrets_root.sh
+++ b/testing/scripts/setup_secrets_root.sh
@@ -16,13 +16,9 @@ while [ ! -e "${PATH_DEV}" ]; do
sleep 0.1
done
while true; do
- stty -echo
- printf "\nSecrets passphrase: "
- read SECRETS_PASS
- stty echo
- echo "" # newline so user knows their input return was accepted
+ get_passphrase
set +e
- echo "${SECRETS_PASS}" | pmount "${PATH_DEV}"
+ echo "${PASSPHRASE}" | pmount "${PATH_DEV}"
RESULT=$?
set -e
if [ "${RESULT}" = "0" ]; then
@@ -39,9 +35,9 @@ chown -R "${USERNAME}:${USERNAME}" "${PATH_SECRETS}"
cd ../..
PATH_REPO=$(pwd)
-CONTAINS_TICK=$(echo "${SECRETS_PASS}" | grep "'" | wc -l)
+CONTAINS_TICK=$(echo "${PASSPHRASE}" | grep "'" | wc -l)
if [ "${CONTAINS_TICK}" = "1" ]; then
echo "Cannot pass to user script passphrase with illegal character, aborting."
exit 1
fi
-su -l "${USERNAME}" -c "cd ${PATH_REPO}/testing/scripts && ./setup_secrets_user.sh '${SECRETS_PASS}'"
+su -l "${USERNAME}" -c "cd ${PATH_REPO}/testing/scripts && ./setup_secrets_user.sh '${PASSPHRASE}'"
diff --git a/testing/scripts/setup_secrets_user.sh b/testing/scripts/setup_secrets_user.sh
index 40ee16e..0d5be2a 100755
--- a/testing/scripts/setup_secrets_user.sh
+++ b/testing/scripts/setup_secrets_user.sh
@@ -2,13 +2,14 @@
set -e
. ./_misc.sh
-
-BORG_PASSPHRASE="$1"
PATH_REPOS="${HOME}/repos"
PATH_BORGKEYS="${HOME}/.config/borg/keys"
REPOS_SITE_DOMAIN=plomlompom.com
REMOTE_PATH_REPOS=/var/repos
NAME_BORGAPP=borgplom
+if [ ! -z "$1" ]; then
+ export BORG_PASSPHRASE="$1"
+fi
abort_if_not_user "${USERNAME}"
abort_if_offline