35 lines
961 B
Bash
35 lines
961 B
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
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)
|
|
if ! getent passwd | grep -q "^flectra:"; then
|
|
adduser --system --home $FLECTRA_DATA_DIR --quiet --group $FLECTRA_USER
|
|
fi
|
|
# 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
|
|
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_CONFIGURATION_FILE
|
|
chmod 0640 $FLECTRA_CONFIGURATION_FILE
|
|
# Log
|
|
mkdir -p $FLECTRA_LOG_DIR
|
|
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_LOG_DIR
|
|
chmod 0750 $FLECTRA_LOG_DIR
|
|
# Data dir
|
|
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_DATA_DIR
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|