version 3 draft: POSIX shell port

This commit is contained in:
Scott B 2020-01-12 17:27:12 -08:00
parent fe28b7c099
commit 27cf664aeb
2 changed files with 25 additions and 27 deletions

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/sh
set -euo pipefail case "$(readlink /proc/$$/exe)" in */bash) set -euo pipefail ;; *) set -eu ;; esac
# pve-nag-buster (v03) https://github.com/foundObjects/pve-nag-buster # pve-nag-buster (v03) https://github.com/foundObjects/pve-nag-buster
# Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue) # Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue)
@ -22,12 +22,12 @@ set -euo pipefail
# ensure a predictable environment # ensure a predictable environment
PATH=/usr/sbin:/usr/bin:/sbin:/bin PATH=/usr/sbin:/usr/bin:/sbin:/bin
unalias -a \unalias -a
# installer main body: # installer main body:
_main() { _main() {
# ensure $1 exists so 'set -u' doesn't error out # ensure $1 exists so 'set -u' doesn't error out
(("$#" == 0)) && { set -- ""; } >&/dev/null [ "$#" -eq "0" ] && { set -- ""; } > /dev/null 2>&1
case "$1" in case "$1" in
"--emit") "--emit")
@ -62,7 +62,6 @@ _uninstall() {
rm -f "/usr/share/pve-nag-buster.sh" rm -f "/usr/share/pve-nag-buster.sh"
echo "Script and dpkg hooks removed, please manually remove /etc/apt/sources.list.d/pve-no-subscription.list if desired" echo "Script and dpkg hooks removed, please manually remove /etc/apt/sources.list.d/pve-no-subscription.list if desired"
exit 0
} }
_install() { _install() {
@ -95,7 +94,7 @@ _install() {
echo "Installing script to /usr/share/pve-nag-buster.sh" echo "Installing script to /usr/share/pve-nag-buster.sh"
temp='' temp=''
if [[ "$1" == "--offline" ]]; then if [ "$1" = "--offline" ]; then
# offline mode, emit stored script # offline mode, emit stored script
temp="$(mktemp)" && trap "rm -f $temp" EXIT temp="$(mktemp)" && trap "rm -f $temp" EXIT
emit_script > "$temp" emit_script > "$temp"
@ -126,29 +125,28 @@ _install() {
emit_script() { emit_script() {
base64 -d << 'Y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twK1mdM5b4bxNveo6nMz/MDlZ
eGWdGs/Uh8VjDbwrLQWX28XrWWdl9h4KG9xlwF9TjJMVriDhUp6gLrghCTahNreCWtGe0L2MNcMS Iuf4iF+nbiIhXIN8xfaBSOFUwxcANeaOxYLMfjMS05v1NtMOqEdIYzVXni0DHqtxs9dQaaM/jC4S
JbcIoThfZs0cxzKJDNtovQjxBP3vHaNBTxzZ5LWTW++C02FAx+7fkvk3FZsbxKCg4QE2HeLdPFPe mwrfKTTLKCewSTGVsFSOGNPwOAM5/Fxu3snKRlYeLwKC7uq9uTFR/L64HzG0TPfjmkH24hNsuhe7
OVRx+ZjPAmaPF1tx/qm2GzBPbNZHJRm6sQ/JegAAAAA8deMi83ilmAABqQf5CwAAJ/5duLHEZ/sC JtcdlRcbL5rHN9C5PNOpCqcEeRDmVsS0sgAAAMwFRS7YkAXGAAGmB/cLAADBO9SpscRn+wIAAAAA
AAAAAARZWg== BFla
YEET YEET
} }
assert_root() { [ $(id -u) -eq '0' ] || { echo "This action requires root." && exit 0; }; } assert_root() { [ "$(id -u)" -eq '0' ] || { echo "This action requires root." && exit 1; }; }
err() { echo "Err '${FUNCNAME[1]}': $*" >&2; }
_usage() { echo "Usage: $(basename "$0") (--emit|--offline|--uninstall)"; } _usage() { echo "Usage: $(basename "$0") (--emit|--offline|--uninstall)"; }
_main "$@" _main "$@"

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# pve-nag-buster.sh (v03) https://github.com/foundObjects/pve-nag-buster # pve-nag-buster.sh (v03) https://github.com/foundObjects/pve-nag-buster
# Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue) # Copyright (C) 2019 /u/seaQueue (reddit.com/u/seaQueue)