4 # setup things which involve being the primary host or not
6 source /usr
/local
/lib
/err
8 script_name
="${BASH_SOURCE[0]}"
9 script_name
="${script_name##*/}"
10 pre
="$script_name:${0##*/}:${SSH_CLIENT:+ $HOSTNAME:}"
11 m
() { printf "$pre %s\n" "$*"; "$@"; }
12 e
() { printf "$pre %s\n" "$*"; }
13 err
() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
18 if [[ ! -s /etc
/systemd
/system
/$service ]]; then
24 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
28 if [[ $new_host == localhost
]]; then
31 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
33 source /a
/bin
/bash_unpublished
/source-state
35 # fixing up a bad state that servers got in.
36 if [[ -e /dev
/shm
/iank-status
]]; then
37 chown iank.iank
/dev
/shm
/iank-status
41 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
46 # https://www.robustperception.io/how-to-have-labels-for-machine-roles
47 dir
=/var
/lib
/prometheus
/node-exporter
48 if [[ -e $dir ]]; then
49 cat > $dir/mailhost.prom
<<EOF
50 host_role{role="mailhost"} $mailhost_p
56 if [[ $HOSTNAME == "$MAIL_HOST" ||
$HOSTNAME == kd
]]; then
57 m systemctl
--now enable btrbk.timer
59 serm systemctl
--now disable btrbk.timer
63 if dpkg
-s rss2email
&>/dev
/null
; then
64 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
65 # arbtt disabled for now
66 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
67 m systemctl
--now enable rss2email.timer
69 files
=(/sysd-mail-once
/btrbk
*)
70 if (( ${#files[@]} )); then
74 serm systemctl stop rss2email.service
75 serm systemctl
--now disable rss2email.timer
76 # arbtt disabled for now
77 # for ((i=0; i<10; i++)); do
78 # killall arbtt-capture || break
80 # if [[ $i == 9 ]]; then
87 # todo: whats going on here? figure out if this should be removed.
89 # if dpkg -s radicale &>/dev/null; then
90 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
91 # m systemctl restart radicale
92 # m systemctl enable radicale
93 # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
94 # m mv /etc/logrotate.d/radicale{.disabled,}
97 # m systemctl stop radicale
98 # m systemctl disable radicale
99 # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
100 # if [[ -e /etc/logrotate.d/radicale ]]; then
101 # m mv /etc/logrotate.d/radicale{,.disabled}
107 # todo: this needs to be disabled earlier than primary-setup in switch-mail-host
109 # if dpkg -s profile-sync-daemon &>/dev/null; then
110 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
111 # m systemctl --user start psd
112 # m systemctl --user enable psd
114 # m systemctl --user stop psd
115 # m systemctl --user disable psd