Last active
April 8, 2021 22:16
-
-
Save paulc/59030e913c7163d96454707141b0730d to your computer and use it in GitHub Desktop.
Pot Startup Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -o pipefail errexit nounset | |
_NORMAL=$(printf "\033[0m") | |
_RED=$(printf "\033[0;31m") | |
_YELLOW=$(printf "\033[0;33m") | |
_CYAN=$(printf "\033[0;36m") | |
_COLOUR=1 | |
_log() { | |
local _cmd="$@" | |
printf "${_COLOUR:+${_YELLOW}}" | |
printf "%s [%s] %-40s\n" "$(date '+%b %d %T')" $name "CMD: $_cmd" | |
printf "${_COLOUR:+${_CYAN}}" | |
eval "$_cmd" 2>&1 | sed -e 's/^/ | /' | |
local _status=$? | |
if [ $_status -eq 0 ] | |
then | |
printf "${_COLOUR:+${_YELLOW}}[OK]\n" | |
else | |
printf "${_COLOUR:+${_RED}}[ERROR]\n" | |
fi | |
printf "${_COLOUR:+${_NORMAL}}" | |
return $_status | |
} | |
_err() { | |
echo ERROR: $@ >&1 | |
exit 1 | |
} | |
( | |
_log hostname | |
_log chsh -s /bin/sh root | |
_log "uname -a | tee /etc/motd" | |
_log "sysrc sshd_enable=YES sendmail_enable=NONE sshd_flags='-o PermitRootLogin=prohibit-password'" | |
_log service sshd start | |
) | tee -a /var/log/pot-init.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment