flectra/debian/postinst

35 lines
961 B
Plaintext
Raw Normal View History

#!/bin/sh
set -e
2018-01-17 13:08:43 +01:00
FLECTRA_CONFIGURATION_FILE=/etc/flectra/flectra.conf
FLECTRA_GROUP="flectra"
FLECTRA_DATA_DIR=/var/lib/flectra
FLECTRA_LOG_DIR=/var/log/flectra
FLECTRA_USER="flectra"
case "${1}" in
configure)
2018-01-17 13:08:43 +01:00
if ! getent passwd | grep -q "^flectra:"; then
adduser --system --home $FLECTRA_DATA_DIR --quiet --group $FLECTRA_USER
fi
2018-01-17 13:08:43 +01:00
# Register "$FLECTRA_USER" as a postgres user with "Create DB" role attribute
su - postgres -c "createuser -d -R -S $FLECTRA_USER" 2> /dev/null || true
# Configuration file
2018-01-17 13:08:43 +01:00
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_CONFIGURATION_FILE
chmod 0640 $FLECTRA_CONFIGURATION_FILE
# Log
2018-01-17 13:08:43 +01:00
mkdir -p $FLECTRA_LOG_DIR
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_LOG_DIR
chmod 0750 $FLECTRA_LOG_DIR
# Data dir
2018-01-17 13:08:43 +01:00
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_DATA_DIR
;;
*)
;;
esac
#DEBHELPER#
exit 0