#!/bin/bash # usage $0 [MAIL_HOST] # setup things which involve being the primary host or not source /usr/local/lib/err pre="${0##*/}:" m() { printf "$pre %s\n" "$*"; "$@"; } e() { printf "$pre %s\n" "$*"; } err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; } [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" if [[ $1 ]]; then new_host=$1 if [[ $new_host == localhost ]]; then mailhost_p=1 new_host=$HOSTNAME else mailhost_p=0 fi # https://www.robustperception.io/how-to-have-labels-for-machine-roles dir=/var/lib/prometheus/node-exporter if [[ -e $dir ]]; then cat > $dir/mailhost.prom </dev/null; then if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # arbtt disabled for now #DISPLAY=:0 arbtt-capture --sample-rate=10 & m systemctl --now enable rss2email.timer # off is in mail-setup. no reason for this to be in the rss2email block. m systemctl --now enable btrbk.timer else m systemctl --now disable btrbk.timer m systemctl stop rss2email.service m systemctl --now disable rss2email.timer # arbtt disabled for now # for ((i=0; i<10; i++)); do # killall arbtt-capture || break # sleep 1 # if [[ $i == 9 ]]; then # exit 1 # fi # done fi fi # todo: whats going on here? figure out if this should be removed. # if dpkg -s radicale &>/dev/null; then # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # m systemctl restart radicale # m systemctl enable radicale # if [[ -e /etc/logrotate.d/radicale.disabled ]]; then # m mv /etc/logrotate.d/radicale{.disabled,} # fi # else # m systemctl stop radicale # m systemctl disable radicale # # weekly logrotate tries to restart radicale even if it's a disabled service in flidas. # if [[ -e /etc/logrotate.d/radicale ]]; then # m mv /etc/logrotate.d/radicale{,.disabled} # fi # fi # fi # todo: this needs to be disabled earlier than primary-setup in switch-mail-host # if dpkg -s profile-sync-daemon &>/dev/null; then # if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # m systemctl --user start psd # m systemctl --user enable psd # else # m systemctl --user stop psd # m systemctl --user disable psd # fi # fi m /a/exe/mail-setup exit 0