X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=init.d%2Fsfa;h=2fda7e0b7e30239835e9fcbe9b10255055d17e93;hb=98188608826b2833970a681ce8fe0090606b981a;hp=69cf6f6fa943d2ba28cbdcb1303a947ee2bb63c8;hpb=de35e18292a261afb4f8d420a3b3c13592d53a99;p=sfa.git diff --git a/init.d/sfa b/init.d/sfa index 69cf6f6f..2fda7e0b 100755 --- a/init.d/sfa +++ b/init.d/sfa @@ -10,8 +10,31 @@ # source function library . /etc/init.d/functions + +# + +# borrowed from postgresql +versions=() +for v in `ls /usr/lib/postgresql/ 2>/dev/null`; do + if [ -x /usr/lib/postgresql/$v/bin/pg_ctl ] && [ ! -x /etc/init.d/postgresql-$v ]; then + versions+=($v) + fi +done +if [[ ${#versions[*]} == "0" ]]; then + echo "E: Missing postgresql installation. Aborting." + exit +fi +if [[ ${#versions[*]} != "1" ]]; then + echo "E: Too many postgresql versions installed. Aborting." + exit +fi +pgver=${versions[0]} + +LOCKFILE=/var/run/sfa-start.py +# + # Default locations -PGDATA=/var/lib/pgsql/data +PGDATA=/etc/postgresql/$pgver/main/ postgresql_conf=$PGDATA/postgresql.conf pghba_conf=$PGDATA/pg_hba.conf postgresql_sysconfig=/etc/sysconfig/pgsql @@ -44,7 +67,7 @@ check () function postgresql_check () { # wait until postmaster is up and running - or 10s max - if status postmaster >& /dev/null && [ -f /var/lock/subsys/postgresql ] ; then + if status postgres >& /dev/null && [ -f /var/run/postgresql/$pgver-main.pid ] ; then # The only way we can be sure is if we can access it for i in $(seq 1 10) ; do # Must do this as the postgres user initially (before we @@ -276,7 +299,7 @@ function start() { [ "$SFA_FLASHPOLICY_ENABLED" == 1 ] && \ action "Flash Policy Server" daemon /usr/bin/sfa_flashpolicy.py --file="$SFA_FLASHPOLICY_CONFIG_FILE" --port=$SFA_FLASHPOLICY_PORT -d - touch /var/lock/subsys/sfa-start.py + touch $LOCKFILE } @@ -285,7 +308,7 @@ function stop() { db_stop - rm -f /var/lock/subsys/sfa-start.py + rm -f $LOCKFILE } @@ -295,7 +318,7 @@ case "$1" in reload) reload force ;; restart) stop; start ;; condrestart) - if [ -f /var/lock/subsys/sfa-start.py ]; then + if [ -f $LOCKFILE ]; then stop start fi