]> code.delx.au - monosys/blob - borg/do-install
bbdf7a4ab90262b57554ce48c8f0d56a38acb24d
[monosys] / borg / do-install
1 #!/bin/bash
2
3 set -eux
4
5 cd "$(dirname "$0")"
6
7 install -m 0755 backup /usr/local/bin/
8
9 if [ "${1:-}" != "full" ]; then
10 exit 0
11 fi
12
13 BORG_PASSPHRASE="$(dd if=/dev/urandom of=/dev/stdout bs=1 count=15 2>/dev/null | base64)"
14 install -m 0644 -T etc-borg-exclude /etc/borg-exclude
15 install -m 0600 -T etc-borg-env /etc/borg-env
16 sed -i "s|SECRET|$BORG_PASSPHRASE|" /etc/borg-env
17
18 install -m 0644 -T etc-cron.d-backup /etc/cron.d/backup
19 H=$((16#$(hostname|md5sum|head -c 1) % 7 + 14))
20 M=$((16#$(hostname|md5sum|head -c 2) % 60))
21 sed -i -e "s|\$H|$H|" -e "s|\$M|$M|" /etc/cron.d/backup
22
23 [ -f /root/.ssh/id_rsa.pub ] || ssh-keygen
24 cat /root/.ssh/id_rsa.pub
25 install -m 0600 -T root-ssh-config /root/.ssh/config