#!/bin/bash set -eux cd "$(dirname "$0")" install -m 0755 backup /usr/local/bin/ if [ "${1:-}" != "full" ]; then exit 0 fi BORG_PASSPHRASE="$(dd if=/dev/urandom of=/dev/stdout bs=1 count=15 2>/dev/null | base64)" install -m 0644 -T etc-borg-exclude /etc/borg-exclude install -m 0600 -T etc-borg-env /etc/borg-env sed -i "s|SECRET|$BORG_PASSPHRASE|" /etc/borg-env install -m 0644 -T etc-cron.d-backup /etc/cron.d/backup H=$((16#$(hostname|md5sum|head -c 1) % 7 + 14)) M=$((16#$(hostname|md5sum|head -c 2) % 60)) sed -i -e "s|\$H|$H|" -e "s|\$M|$M|" /etc/cron.d/backup [ -f /root/.ssh/id_rsa.pub ] || ssh-keygen cat /root/.ssh/id_rsa.pub install -m 0600 -T root-ssh-config /root/.ssh/config