sourcezap/bin/setup-sourcezap
0x1eef 988a5ba2a6
Some checks are pending
sourcezap / shellcheck (push) Waiting to run
Fix setup-sourcezap
2024-07-19 17:25:50 -03:00

38 lines
807 B
Bash
Executable file

#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/sourcezap
conf=$(cat "${localbase}"/share/sourcezap/doas.conf)
doas="${localbase}"/etc/doas.conf
##
# functions
. "${libexec}"/functions/print.sh
##
# main
if [ "$(id -u)" != "0" ]; then
printerr "you must be root"
exit 1
fi
if id -u _sourcezap > /dev/null 2>&1; then
printok "_sourcezap user exists"
else
pw useradd -n _sourcezap \
-c "sourcezap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_sourcezap/
printok "create _sourcezap user"
fi
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
printok "${doas} is up to date"
else
echo "$conf" >> "$doas"
printok "update ${doas} (note: review the update)"
fi