iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
robustness and satisfy shellcheck
[distro-setup]
/
primary-setup
diff --git
a/primary-setup
b/primary-setup
index 1a6ce0e05158124c1078040fdf24b1ab7f6cf068..30c4222a7bc9c3cdfb6885546a147c4b8225438f 100755
(executable)
--- a/
primary-setup
+++ b/
primary-setup
@@
-1,11
+1,16
@@
#!/bin/bash
# usage $0 [MAIL_HOST]
#!/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
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 [[ ! $SUDO_USER || $EUID == 0 ]]; then
+ echo "$0: error: requires running as nonroot or sudo"
+ exit 1
+fi
if [[ $1 ]]; then
new_host=$1
if [[ $1 ]]; then
new_host=$1