forgejo_runner_debian_packager/debian/forgejo-runner.preinst

51 lines
1.2 KiB
Text
Raw Permalink Normal View History

2024-03-10 12:06:16 +01:00
#!/bin/bash
SERVER_HOME=/var/cache/forgejo-runner
SERVER_USER=forgejo-runner
SERVER_NAME="Forgejo runner"
SERVER_GROUP=forgejo-runner
case "$1" in
install|upgrade)
# Create group if not existing
if ! getent group | grep -q "^$SERVER_GROUP:" ; then
echo -n "Adding group $SERVER_GROUP..."
addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true
echo " done."
fi
# Create homedir if not existing
test -d $SERVER_HOME || mkdir $SERVER_HOME
# Create user if not existing
if ! getent passwd | grep -q "^$SERVER_USER:"; then
echo -n "Adding system user $SERVER_USER..."
adduser --quiet \
--system \
--ingroup $SERVER_GROUP \
--home $SERVER_HOME \
--no-create-home \
--disabled-password \
$SERVER_USER 2>/dev/null || true
echo " done."
fi
# Adjust file and directory permissions
if ! dpkg-statoverride --list $SERVER_HOME >/dev/null
then
chown -R $SERVER_USER:adm $SERVER_HOME
chmod u=rwx,g=rxs,o= $SERVER_HOME
fi
# Add user to docker group (if exists)
if getent group docker >/dev/null
then
adduser $SERVER_USER docker
fi
;;
esac
#DEBHELPER#