2018-01-16 06:58:15 +01:00
|
|
|
#!/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"
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
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
|
2018-01-16 06:58:15 +01:00
|
|
|
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
|
2018-01-16 06:58:15 +01:00
|
|
|
# Configuration file
|
2018-01-17 13:08:43 +01:00
|
|
|
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_CONFIGURATION_FILE
|
|
|
|
chmod 0640 $FLECTRA_CONFIGURATION_FILE
|
2018-01-16 06:58:15 +01:00
|
|
|
# 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
|
2018-01-16 06:58:15 +01:00
|
|
|
# Data dir
|
2018-01-17 13:08:43 +01:00
|
|
|
chown $FLECTRA_USER:$FLECTRA_GROUP $FLECTRA_DATA_DIR
|
2018-01-16 06:58:15 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|