mostly profanity and fixes
[distro-setup] / prof-backup
1 #!/bin/bash
2
3 # We setup kd as a server which runs profanity, because profanity
4 # contains important state which it does not save to disk: the most
5 # recent read message in each chat room and for private messages.
6 # To do this, uses data directories in /d/p.
7
8 # However, if we need to take kd down for maintenance, we can run
9 # profanity on HOST2 with data directory in /p. To do this, stop
10 # profanity, run prof-backup, and then systemctl start profanity from
11 # HOST2, and then run prof. To connect from other machines, run prof
12 # HOST2_SSH_NAME. To have the profanity service stopped and started with
13 # switch-mail-host, do touch /p/profanity-here. To do the reverse,
14 #
15 # systemctl stop profanity
16 # rsync /p/profanity{,-config} kdwg.b8.nz:/d/p
17 # ssh root@kdwg.b8.nz systemctl --now enable profanity
18
19 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
20 source /a/bin/errhandle/err
21
22 source /a/bin/bash_unpublished/source-state
23 if [[ $HOSTNAME != "$HOST2" ]]; then
24 exit 0
25 fi
26
27 case $HOSTNAME in
28 kd)
29 if systemctl --quiet is-active profanity; then
30 rsync /d/p/profanity{,-config} /p
31 fi
32 ;;
33 *)
34 if ssh b8.nz systemctl --quiet is-active profanity; then
35 rsync -a b8.nz:/d/p/profanity{,-config} /p
36 fi
37 ;;
38 esac