fix debian scripts to match current parameters

This commit is contained in:
Ruslan Talpa
2015-11-04 16:23:02 +02:00
parent 28b7b80bbb
commit 37b1d7d692
2 changed files with 52 additions and 22 deletions
+14 -5
View File
@@ -7,17 +7,26 @@
# database host # database host
#POSTGREST_DBHOST=localhost #POSTGREST_DBHOST=localhost
# database host
#POSTGREST_DBPORT=5432
# database to use # database to use
#POSTGREST_DBNAME= #POSTGREST_DBNAME=app
# database user # database user
#POSTGREST_DBUSER=postgres #POSTGREST_DBUSER=authenticator
# database password # database password
#POSTGREST_DBPASS= #POSTGREST_DBPASS=
# database pool # database pool
#POSTGREST_DBPOOL=10 #POSTGREST_POOL=10
# additional options # jwt secret
#POSTGREST_OPTS= #POSTGREST_JWT_SECRET=secret
# default schema
#POSTGREST_SCHEMA=public
# secure (use 1 to enable, empty string to disable)
#POSTGREST_SECURE=
+38 -17
View File
@@ -13,31 +13,52 @@ if test -f /etc/default/postgrest; then
. /etc/default/postgrest . /etc/default/postgrest
fi fi
POSTGREST=/usr/local/bin/postgrest POSTGREST=/usr/local/bin/postgrest
CONNECTION_STRING="postgres://"
POSTGREST_OPTS=""
POSTGREST_USER=${POSTGREST_USER:-postgrest} POSTGREST_USER=${POSTGREST_USER:-postgrest}
POSTGREST_DBNAME=${POSTGREST_DBNAME:-postgres} POSTGREST_PORT=${POSTGREST_PORT:-3000}
POSTGREST_DBUSER=${POSTGREST_DBUSER:-postgres} POSTGREST_DBUSER=${POSTGREST_DBUSER:-authenticator}
if [ -n "$POSTGREST_DBHOST" ]; then #POSTGREST_DBPASS=${POSTGREST_DBPASS:-authenticator}
POSTGREST_OPTS="$POSTGREST_OPTS --db-host $POSTGREST_DBHOST" POSTGREST_DBHOST=${POSTGREST_DBHOST:-localhost}
fi POSTGREST_DBPORT=${POSTGREST_DBPORT:-5432}
if [ -n "$POSTGREST_DBNAME" ]; then POSTGREST_DBNAME=${POSTGREST_DBNAME:-app}
POSTGREST_OPTS="$POSTGREST_OPTS --db-name $POSTGREST_DBNAME" POSTGREST_DBPOOL=${POSTGREST_DBPOOL:-10}
fi POSTGREST_ANON=${POSTGREST_ANON:-anonymous}
if [ -n "$POSTGREST_DBUSER" ]; then POSTGREST_JWT_SECRET=${POSTGREST_JWT_SECRET:-secret}
POSTGREST_OPTS="$POSTGREST_OPTS --db-user $POSTGREST_DBUSER" POSTGREST_SCHEMA=${POSTGREST_SCHEMA:-public}
POSTGREST_OPTS="$POSTGREST_OPTS --anonymous $POSTGREST_DBUSER"
fi CONNECTION_STRING="$CONNECTION_STRING$POSTGREST_DBUSER"
if [ -n "$POSTGREST_DBPASS" ]; then if [ -n "$POSTGREST_DBPASS" ]; then
POSTGREST_OPTS="$POSTGREST_OPTS --db-pass $POSTGREST_DBPASS" CONNECTION_STRING="$CONNECTION_STRING:$POSTGREST_DBPASS"
fi fi
if [ -n "$POSTGREST_DBPOOL" ]; then CONNECTION_STRING="$CONNECTION_STRING@$POSTGREST_DBHOST:$POSTGREST_DBPORT/$POSTGREST_DBNAME"
POSTGREST_OPTS="$POSTGREST_OPTS --db-pool $POSTGREST_DBPOOL"
if [ -n "$POSTGREST_PORT" ]; then
POSTGREST_OPTS="$POSTGREST_OPTS --port $POSTGREST_PORT"
fi fi
POSTGREST_OPTS="$POSTGREST_OPTS --schema public"
if [ -n "$POSTGREST_POOL" ]; then
POSTGREST_OPTS="$POSTGREST_OPTS --pool $POSTGREST_POOL"
fi
if [ -n "$POSTGREST_JWT_SECRET" ]; then
#export POSTGREST_JWT_SECRET="$POSTGREST_JWT_SECRET"
POSTGREST_OPTS="$POSTGREST_OPTS --jwt-secret $POSTGREST_JWT_SECRET"
fi
if [ -n "$POSTGREST_SCHEMA" ]; then
POSTGREST_OPTS="$POSTGREST_OPTS --schema $POSTGREST_SCHEMA"
fi
if [ -n "$POSTGREST_ANON" ]; then
POSTGREST_OPTS="$POSTGREST_OPTS --anonymous $POSTGREST_ANON"
fi
#export CONNECTION_STRING="$CONNECTION_STRING"
START_PARAMS="$CONNECTION_STRING $POSTGREST_OPTS"
start() start()
{ {
log_daemon_msg "Starting PostgreSQL REST API daemon" "postgrest" || true log_daemon_msg "Starting PostgreSQL REST API daemon" "postgrest" || true
if start-stop-daemon --start --quiet --oknodo --chuid ${POSTGREST_USER} --startas /usr/local/bin/postgrest-wrapper --exec $POSTGREST -- $POSTGREST_OPTS; then if start-stop-daemon --start --quiet --oknodo --chuid ${POSTGREST_USER} --startas /usr/local/bin/postgrest-wrapper --exec $POSTGREST -- $START_PARAMS; then
log_end_msg 0 || true log_end_msg 0 || true
else else
log_end_msg 1 || true log_end_msg 1 || true