forgejo_debian_packager/debian/forgejo.preinst
Benjamin Renard a65bae33f0
Some checks failed
ci/woodpecker/tag/woodpecker Pipeline failed
Release 1.20.2-0
2023-07-31 23:16:54 +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#