]> piware.de Git - bin.git/commitdiff
backup: figure out ssh agent when running from cron
authorMartin Pitt <martin.pitt@ubuntu.com>
Thu, 18 Sep 2014 04:51:52 +0000 (06:51 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Thu, 18 Sep 2014 04:51:52 +0000 (06:51 +0200)
backup

diff --git a/backup b/backup
index 0518410024d7f5c2cd18c076bc970a08982bf49d..8d553c5cac6779e02f7e6f2df434c383be9a38b6 100755 (executable)
--- a/backup
+++ b/backup
@@ -22,6 +22,14 @@ if ! ip route | grep -q '^default.*wlan'; then
     exit 0
 fi
 
+# figure out ssh agent when running from cron
+if [ -z "${SSH_AUTH_SOCK:-}" ]; then
+    ssh_socket=$(ls /run/user/`id -u`/keyring-*/ssh 2>/dev/null)
+    if [ -S "$ssh_socket" ]; then
+        export SSH_AUTH_SOCK="$ssh_socket"
+    fi
+fi
+
 notify-send "Backup started"
 mkdir -p $(dirname $LOG)
 env PASSPHRASE="$(cat ~/.backup-passphrase)" duplicity --full-if-older-than 1M --exclude-globbing-filelist .duplicity-ignore . rsync://piware.de/backup/donald >> $LOG || { notify-send "BACKUP FAILED!"; exit 1; }