2024-05-11 19:51:26 +02:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
2024-04-08 01:27:18 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
# variables
|
2024-05-23 05:41:21 +02:00
|
|
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
|
2024-05-23 03:37:34 +02:00
|
|
|
libexec="${localbase}"/libexec/portzap
|
2024-04-08 01:27:18 +02:00
|
|
|
|
2024-05-23 02:42:15 +02:00
|
|
|
##
|
|
|
|
# functions
|
2024-07-22 02:41:12 +02:00
|
|
|
. "${libexec}"/functions/print.sh
|
2024-05-23 02:42:15 +02:00
|
|
|
|
2024-04-08 01:27:18 +02:00
|
|
|
##
|
|
|
|
# main
|
2024-04-19 10:49:49 +02:00
|
|
|
if [ "$(id -u)" != "0" ]; then
|
2024-05-23 02:42:15 +02:00
|
|
|
printerr "you must be root"
|
2024-04-19 10:49:49 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-17 12:10:26 +02:00
|
|
|
if id -u _portzap > /dev/null 2>&1; then
|
2024-05-23 02:42:15 +02:00
|
|
|
printok "_portzap user exists"
|
2024-04-17 12:10:26 +02:00
|
|
|
else
|
2024-04-08 01:27:18 +02:00
|
|
|
pw useradd -n _portzap \
|
|
|
|
-c "portzap user" \
|
|
|
|
-m \
|
|
|
|
-s /sbin/nologin
|
|
|
|
chmod u=rwX,g=rX,o= /home/_portzap/
|
2024-06-30 09:23:57 +02:00
|
|
|
printok "_portzap user created"
|
2024-04-08 01:27:18 +02:00
|
|
|
fi
|
|
|
|
|
2024-06-30 09:23:57 +02:00
|
|
|
"${libexec}"/setup/setup-doas
|
|
|
|
"${libexec}"/setup/setup-cron
|
2024-06-30 09:37:15 +02:00
|
|
|
echo
|
|
|
|
echo "If you haven't already, add users to the _portzap group: "
|
|
|
|
echo "root@$(hostname)# pw groupmod -n _portzap -m user1,user2"
|
|
|
|
echo
|