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
25 # https://www.robustperception.io/how-to-have-labels-for-machine-roles
26 dir
=/var
/lib
/prometheus
/node-exporter
27 if [[ -e $dir ]]; then
28 cat > $dir/mailhost.prom
<<EOF
29 host_role{role="mailhost"} $mailhost_p
33 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
35 source /a
/bin
/bash_unpublished
/source-state
37 # fixing up a bad state that servers got in.
38 if [[ -e /dev
/shm
/iank-status
]]; then
39 chown iank.iank
/dev
/shm
/iank-status
43 if dpkg
-s rss2email
&>/dev
/null
; then
44 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
45 # arbtt disabled for now
46 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
47 m systemctl
--now enable rss2email.timer
48 # off is in mail-setup. no reason for this to be in the rss2email block.
49 m systemctl
--now enable btrbk.timer
51 files
=(/sysd-mail-once
/btrbk
*)
52 if (( ${#files[@]} )); then
55 m systemctl
--now disable btrbk.timer
57 m systemctl stop rss2email.service
58 m systemctl
--now disable rss2email.timer
59 # arbtt disabled for now
60 # for ((i=0; i<10; i++)); do
61 # killall arbtt-capture || break
63 # if [[ $i == 9 ]]; then
70 # todo: whats going on here? figure out if this should be removed.
72 # if dpkg -s radicale &>/dev/null; then
73 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
74 # m systemctl restart radicale
75 # m systemctl enable radicale
76 # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
77 # m mv /etc/logrotate.d/radicale{.disabled,}
80 # m systemctl stop radicale
81 # m systemctl disable radicale
82 # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
83 # if [[ -e /etc/logrotate.d/radicale ]]; then
84 # m mv /etc/logrotate.d/radicale{,.disabled}
90 # todo: this needs to be disabled earlier than primary-setup in switch-mail-host
92 # if dpkg -s profile-sync-daemon &>/dev/null; then
93 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
94 # m systemctl --user start psd
95 # m systemctl --user enable psd
97 # m systemctl --user stop psd
98 # m systemctl --user disable psd