X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=primary-setup;h=d6c0ed9ec4cf8ea43d64d2312fe0f50a46b23532;hb=80be8ed466553bef7f47edf4d15a69ace460f3da;hp=4ce132c3c94452274079ee66917c73b0f50051d7;hpb=c8f87d4173949b8d96c9c34e2d2c0730caeba0eb;p=distro-setup diff --git a/primary-setup b/primary-setup index 4ce132c..d6c0ed9 100755 --- a/primary-setup +++ b/primary-setup @@ -1,19 +1,24 @@ #!/bin/bash # usage $0 [MAIL_HOST] +# setup things which involve being the primary host or not set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR -# setup things which involve being the primary host or not + +if [[ $EUID == 0 && ! $SUDO_USER ]]; then + echo "$0: error: requires running as nonroot or sudo" + exit 1 +fi if [[ $1 ]]; then new_host=$1 - sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a/bin/bash_unpublished/source-semi-priv - source /a/bin/bash_unpublished/source-semi-priv + sed -ri "s/MAIL_HOST=.*/MAIL_HOST=$new_host/" /a/bin/bash_unpublished/source-state + source /a/bin/bash_unpublished/source-state fi -if [[ $HOSTNAME == $MAIL_HOST ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then # arbtt disabled for now #DISPLAY=:0 arbtt-capture --sample-rate=10 & sudo systemctl start rss2email.timer @@ -33,6 +38,6 @@ else # done fi -mail-setup +/a/exe/mail-setup exit 0 :