forgejo_debian_packager/debian/forgejo.preinst
Benjamin Renard 2594a6b28d
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
Release 1.20.2-0
2023-08-01 00:18:04 +02:00

44 lines
1 KiB
Bash

#!/bin/bash
SERVER_HOME=/var/lib/forgejo
SERVER_USER=git
SERVER_NAME="Git"
SERVER_GROUP=git
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
;;
esac
#DEBHELPER#