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 if [[ $EUID == 0 && ! $SUDO_USER ]]; then
15 err
"requires running as nonroot or sudo"
21 if [[ $new_host == localhost
]]; then
24 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
25 source /a
/bin
/bash_unpublished
/source-state
28 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
29 # arbtt disabled for now
30 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
31 m sudo systemctl start rss2email.timer
32 m sudo systemctl
enable rss2email.timer
33 m sudo systemctl start btrbk.timer
34 m sudo systemctl
enable btrbk.timer
37 m sudo systemctl stop rss2email.timer
38 m sudo systemctl stop rss2email.service
39 m sudo 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
50 if dpkg
-s radicale
&>/dev
/null
; then
51 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
52 m sudo systemctl restart radicale
53 m sudo systemctl
enable radicale
54 if [[ -e /etc
/logrotate.d
/radicale.disabled
]]; then
55 m sudo
mv /etc
/logrotate.d
/radicale
{.disabled
,}
58 m sudo systemctl stop radicale
59 m sudo systemctl disable radicale
60 # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
61 if [[ -e /etc
/logrotate.d
/radicale
]]; then
62 m sudo
mv /etc
/logrotate.d
/radicale
{,.disabled
}