4 # setup things which involve being the primary host or not
6 source /usr
/local
/lib
/err
9 m
() { printf "$pre %s\n" "$*"; "$@"; }
10 e
() { printf "$pre %s\n" "$*"; }
11 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
14 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
18 if [[ $new_host == localhost
]]; then
21 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
23 source /a
/bin
/bash_unpublished
/source-state
26 if dpkg
-s rss2email
&>/dev
/null
; then
27 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
28 # arbtt disabled for now
29 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
30 m systemctl start rss2email.timer
31 m systemctl
enable rss2email.timer
32 # off is in mail-setup. no reason for this to be in the rss2email block.
33 m systemctl start btrbk.timer
34 m systemctl
enable btrbk.timer
37 m systemctl stop rss2email.timer
38 m systemctl stop rss2email.service
39 m systemctl disable rss2email.timer
40 # arbtt disabled for now
41 # for ((i=0; i<10; i++)); do
42 # killall arbtt-capture || break
44 # if [[ $i == 9 ]]; then
51 # todo: whats going on here? figure out if this should be removed.
53 # if dpkg -s radicale &>/dev/null; then
54 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
55 # m systemctl restart radicale
56 # m systemctl enable radicale
57 # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
58 # m mv /etc/logrotate.d/radicale{.disabled,}
61 # m systemctl stop radicale
62 # m systemctl disable radicale
63 # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
64 # if [[ -e /etc/logrotate.d/radicale ]]; then
65 # m mv /etc/logrotate.d/radicale{,.disabled}
71 # todo: this needs to be disabled earlier than primary-setup in switch-mail-host
73 # if dpkg -s profile-sync-daemon &>/dev/null; then
74 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
75 # m systemctl --user start psd
76 # m systemctl --user enable psd
78 # m systemctl --user stop psd
79 # m systemctl --user disable psd