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
35 # https://www.robustperception.io/how-to-have-labels-for-machine-roles
36 dir
=/var
/lib
/prometheus
/node-exporter
37 if [[ -e $dir ]]; then
38 cat > $dir/mailhost.prom
<<EOF
39 host_role{role="mailhost"} $mailhost_p
43 m
sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a
/bin
/bash_unpublished
/source-state
45 source /a
/bin
/bash_unpublished
/source-state
47 # fixing up a bad state that servers got in.
48 if [[ -e /dev
/shm
/iank-status
]]; then
49 chown iank.iank
/dev
/shm
/iank-status
53 if [[ $HOSTNAME == "$MAIL_HOST" ||
$HOSTNAME == kd
]]; then
54 m systemctl
--now enable btrbk.timer
56 serm systemctl
--now disable btrbk.timer
60 if dpkg
-s rss2email
&>/dev
/null
; then
61 if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
62 # arbtt disabled for now
63 #DISPLAY=:0 arbtt-capture --sample-rate=10 &
64 m systemctl
--now enable rss2email.timer
66 files
=(/sysd-mail-once
/btrbk
*)
67 if (( ${#files[@]} )); then
71 serm systemctl stop rss2email.service
72 serm systemctl
--now disable rss2email.timer
73 # arbtt disabled for now
74 # for ((i=0; i<10; i++)); do
75 # killall arbtt-capture || break
77 # if [[ $i == 9 ]]; then
84 # todo: whats going on here? figure out if this should be removed.
86 # if dpkg -s radicale &>/dev/null; then
87 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
88 # m systemctl restart radicale
89 # m systemctl enable radicale
90 # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then
91 # m mv /etc/logrotate.d/radicale{.disabled,}
94 # m systemctl stop radicale
95 # m systemctl disable radicale
96 # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas.
97 # if [[ -e /etc/logrotate.d/radicale ]]; then
98 # m mv /etc/logrotate.d/radicale{,.disabled}
104 # todo: this needs to be disabled earlier than primary-setup in switch-mail-host
106 # if dpkg -s profile-sync-daemon &>/dev/null; then
107 # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
108 # m systemctl --user start psd
109 # m systemctl --user enable psd
111 # m systemctl --user stop psd
112 # m systemctl --user disable psd