bug fix
authorIan Kelling <ian@iankelling.org>
Wed, 9 Oct 2024 05:43:02 +0000 (01:43 -0400)
committerIan Kelling <ian@iankelling.org>
Wed, 9 Oct 2024 05:43:02 +0000 (01:43 -0400)
filesystem/usr/local/bin/prof-backup

index 41a30ec9693b43493201765c055c260d5ab9a017..b57625cad5f14dc1eacac15db1bc7fbf87315e7d 100755 (executable)
@@ -38,6 +38,9 @@
 # ssh root@kdwg.b8.nz systemctl --now enable profanity
 
 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
+
+[[ $EUID == 1000 ]] || exec sudo -u iank "${BASH_SOURCE[0]}" "$@"
+
 source /a/bin/bash-bear-trap/bash-bear
 
 source /a/bin/bash_unpublished/source-state
@@ -48,15 +51,15 @@ if [[ $HOSTNAME != "$HOST2" ]]; then
   exit 0
 fi
 
-case $HOSTNAME in
-  kd)
-    if systemctl --quiet is-active profanity; then
-      rsync /d/p/profanity{,-config} /p
-    fi
-    ;;
-  *)
-    if ssh iank@b8.nz systemctl --user --quiet is-active profanity; then
-      rsync -a b8.nz:/d/p/profanity{,-config} /p
-    fi
-    ;;
-esac
+source /p/c/domain-info
+
+if [[ $HOSTNAME != $d_host ]]; then
+  shell_pre="ssh iank@b8.nz"
+  rsync_pre=b8.nz:
+fi
+
+if $shell_pre systemctl --user --quiet is-active profanity; then
+  rsync -a $rsync_pre/d/p/profanity{,-config} /p
+elif [[ -t 0 ]]; then
+  echo "profanity service not active. doing nothing"
+fi