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
="${SSH_CLIENT:+$HOSTNAME} $script_name:"
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; }
16 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
20 if [[ $new_host == localhost
]]; then
27 # https://www.robustperception.io/how-to-have-labels-for-machine-roles
28 dir
=/var
/lib
/prometheus
/node-exporter
29 if [[ -e $dir ]]; then
30 cat > $dir/mailhost.prom
<<EOF
31 host_role{role="mailhost"} $mailhost_p
35 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
37 source /a
/bin
/bash_unpublished
/source-state
39 # fixing up a bad state that servers got in.
40 if [[ -e /dev
/shm
/iank-status
]]; then
41 chown iank.iank
/dev
/shm
/iank-status
45 if [[ $HOSTNAME == "$MAIL_HOST" ||
$HOSTNAME == kd
]]; then
46 m systemctl
--now enable btrbk.timer
48 m systemctl
--now disable btrbk.timer
52 if dpkg
-s rss2email
&>/dev
/null
; then
53 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
54 # arbtt disabled for now
55 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
56 m systemctl
--now enable rss2email.timer
58 files
=(/sysd-mail-once
/btrbk
*)
59 if (( ${#files[@]} )); then
63 m systemctl stop rss2email.service
64 m systemctl
--now disable rss2email.timer
65 # arbtt disabled for now
66 # for ((i=0; i<10; i++)); do
67 # killall arbtt-capture || break
69 # if [[ $i == 9 ]]; then
76 # todo: whats going on here? figure out if this should be removed.
78 # if dpkg -s radicale &>/dev/null; then
79 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
80 # m systemctl restart radicale
81 # m systemctl enable radicale
82 # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
83 # m mv /etc/logrotate.d/radicale{.disabled,}
86 # m systemctl stop radicale
87 # m systemctl disable radicale
88 # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
89 # if [[ -e /etc/logrotate.d/radicale ]]; then
90 # m mv /etc/logrotate.d/radicale{,.disabled}
96 # todo: this needs to be disabled earlier than primary-setup in switch-mail-host
98 # if dpkg -s profile-sync-daemon &>/dev/null; then
99 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
100 # m systemctl --user start psd
101 # m systemctl --user enable psd
103 # m systemctl --user stop psd
104 # m systemctl --user disable psd