portzap/bin/setup-portzap
0x1eef af917c0649 Replace script
Remove scripts that have been replaced by alternatives
2024-07-21 21:41:49 -03:00

36 lines
723 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
printerr "you must be root"
exit 1
fi
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
"${libexec}"/setup/setup-cron
echo
echo "If you haven't already, add users to the _portzap group: "
echo "root@$(hostname)# pw groupmod -n _portzap -m user1,user2"
echo