home · contact · privacy
Various minor fixes.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 11 Mar 2025 23:13:51 +0000 (00:13 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 11 Mar 2025 23:13:51 +0000 (00:13 +0100)
testing/home/desktop/.local/bin/borgplom
testing/scripts/_misc.sh
testing/scripts/setup_desktop.sh
testing/scripts/setup_secrets_root.sh
testing/scripts/setup_secrets_user.sh

index 4010829014d873c7f3acc6a98e16a1ce640b6ea0..cd48a0b02a588b3f1a01683b280c055f340e1e2a 100755 (executable)
@@ -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}"
index 760dda75d4e7a0085f275c500d580616be8ebc69..327d85a079b79c8ef7aff97f1bd9d628aa5f7683 100644 (file)
@@ -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
 }
index f954302873a63d7664f39fba7da5cb52a1cf5e9a..78cce2fe51c1c2e74485fdd94d23282b55e21315 100755 (executable)
@@ -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
index 2a8f8f24fc2e777b475166924b9e82435db0a2b3..486aa8f4a40fa1e7f9d8657a751b86dea10a6f63 100755 (executable)
@@ -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}'"
index 40ee16e2abc73096359bf24e26ae03629104797c..0d5be2ae0a4537a4839eeacde16459e0034dc45e 100755 (executable)
@@ -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