home · contact · privacy
Better passphrase management.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 7 May 2019 12:08:04 +0000 (14:08 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 7 May 2019 12:08:04 +0000 (14:08 +0200)
all_new_2018/borg.sh
buster/setup_scripts/setup_eeepc.sh
buster/setup_scripts/setup_home_eeepc.sh

index 2c276bf27b090519709fca4054be43c9430a74d4..1be74bb13f0730d5366378d7e77f5795bbaf128b 100755 (executable)
@@ -19,12 +19,14 @@ read_pw() {
     eval $(ssh-agent)
     echo "ssh-add"
     ssh-add
-    stty -echo
-    printf "Borg passphrase: "
-    read password
-    stty echo
-    printf "\n"
-    export BORG_PASSPHRASE="${password}"
+    if [ "${#BORG_PASSPHRASE}" -eq 0 ]; then
+        stty -echo
+        printf "Borg passphrase: "
+        read password
+        stty echo
+        printf "\n"
+        export BORG_PASSPHRASE="${password}"
+    fi
 }
 
 if [ ! -f "${config_file}" ]; then
index 9e394ebde9942c412aa1a5df800e3bde6caccfdd..a7add59929cf920ea7b574fcd627eb0998420dd3 100755 (executable)
@@ -53,16 +53,20 @@ adduser --disabled-password --gecos "" plom
 usermod -a -G sudo plom
 passwd plom
 if [ "${HOME_DIR_EXISTS}" -eq 0 ]; then
+    echo "Put secrets drive into slot for /dev/${secrets_dev}."
     while [ ! -e /dev/"${secrets_dev}" ]; do
-        echo "Put secrets drive into slot for /dev/${secrets_dev}, then hit Return."
-        read ignore
+        sleep 1
     done
-    pmount /dev/"${secrets_dev}"
+    stty -echo
+    printf "Secrets passphrase: "
+    read secrets_pass
+    stty echo
+    echo "${secrets_pass}" | pmount /dev/"${secrets_dev}"
     cp -a "${source_dir_secrets}" "${target_dir_secrets}"
     chown -R plom:plom "${target_dir_secrets}"
     pumount "${secrets_dev}"
     echo "You can remove /dev/${secrets_dev} now."
     cp setup_home_eeepc.sh /home/plom
     chown plom:plom /home/plom/setup_home_eeepc.sh
-    su -c "cd && ./setup_home_eeepc.sh" plom
+    SECRETS_PASS="${secrets_pass}" su -c "cd && ./setup_home_eeepc.sh" plom
 fi
index 83f585f1c970d3d778def77365b66876903ff345..7678bf356b507f1d1c60901d773210446af502ad 100755 (executable)
@@ -53,7 +53,7 @@ cat "${borgrepos_file}" | while read line; do
     fi
     ssh-keyscan "${line}" >> "${ssh_dir}"/known_hosts
 done
-"${path_borgscript}" orgpull
+BORG_PASSPHRASE="${SECRETS_PASS}" "${path_borgscript}" orgpull
 
 # Fill ~/public_repos.
 cat "${repos_list_file}" | while read line; do