home · contact · privacy
Enhance secrets setup.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 6 May 2019 21:06:04 +0000 (23:06 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 6 May 2019 21:06:04 +0000 (23:06 +0200)
buster/setup_scripts/setup_secrets.sh

index e33a52d584bff0066af8477a1f2563b7d252619f..25a49bbc47dce3ffa24380f63272f33dd17810fd 100755 (executable)
@@ -1,19 +1,25 @@
 #!/bin/sh
 set -e
 
-if [ "$#" -ne 1 ]; then
-    echo 'Need exactly one argument (directory).'
-    false
-fi
-directory="$1"
+dev="sdb"
+source_dir="/media/${dev}/to_usb"
+target_dir="${HOME}/tmp_to_usb"
 borgkeys_dir=~/.config/borg/keys
 ssh_dir=~/.ssh
-
-cd "${directory}"
+while [ ! -e /dev/"${dev}" ]; do
+    echo "Put secrets drive into slot for /dev/${dev}, then hit Return."
+    read
+done
+sudo pmount /dev/"${dev}"
+cp -a "${source_dir}" "${target_dir}"
+sudo pumount "${dev}"
+echo "You can remove /dev/${dev} now."
+cd "${target_dir}"
 mkdir -p "${ssh_dir}"
 cp id_rsa ~/.ssh
 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
 tar xf borg_keyfiles.tar
 mkdir -p "${borgkeys_dir}"
 mv borg_keyfiles/* "${borgkeys_dir}"
-rmdir borg_keyfiles
+cd
+rm -rf "${target_dir}"