portzap/bin/setup-portzap
2024-07-21 21:59:36 -03:00

30 lines
621 B
Bash
Executable file

#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/portzap
##
# functions
. "${libexec}"/functions/print.sh
##
# main
if [ "$(id -u)" = "0" ]; then
if id -u _portzap > /dev/null 2>&1; then
printok "_portzap user exists"
else
pw useradd -n _portzap \
-c "portzap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_portzap/
printok "_portzap user created"
fi
"${libexec}"/setup/setup-doas
else
printerr "you must be root"
exit 1
fi