X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=dist%2Fosgi-boot%2Fsrc%2Fmain%2Frpm%2Fetc%2Fosgiboot%2Fosgi-service-init-functions.sh;fp=dist%2Fosgi-boot%2Fsrc%2Fmain%2Frpm%2Fetc%2Fosgiboot%2Fosgi-service-init-functions.sh;h=35bf9703f0ea18ec70c23c26c149d4ed037e4e4c;hb=1df1bf64759d35d3d72b9d96b26b71118fdbe031;hp=0000000000000000000000000000000000000000;hpb=3a3d316af102ba410d1d9e6de349d0c8f7ac044f;p=lgpl%2Fargeo-commons.git diff --git a/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh b/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh new file mode 100644 index 000000000..35bf9703f --- /dev/null +++ b/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Source function library. +. /etc/rc.d/init.d/functions + +RETVAL=0 + +osgi_service_start() { + APP=$1 + # create log an run directories writable by the application user + USER=$APP + GROUP=$APP + RUN_DIR=/var/run/$APP + LOG_DIR=/var/log/$APP + if [ ! -d $LOG_DIR ];then + mkdir -m 0750 $LOG_DIR + chown -R $USER.$GROUP $LOG_DIR + fi + if [ ! -d $RUN_DIR ];then + mkdir -m 0750 $RUN_DIR + chown -R $USER.$GROUP $RUN_DIR + fi + + # call Argeo Commons OSGi utilities as the application user + daemon --user $USER /usr/sbin/osgi-service $APP start + + RETVAL=$? + #action $"Start $APP" /bin/true + if [ $RETVAL -eq 0 ];then + PID=`cat $RUN_DIR/$APP.pid` + action $"Started $APP with pid $PID" /bin/true + else + action $"Could not start $APP" /bin/false + fi + return $RETVAL +} + +osgi_service_stop() { + APP=$1 + USER=$APP + # call Argeo Commons OSGi utilities as the application user + runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP stop" + RETVAL=$? + if [ $RETVAL -eq 0 ];then + action $"Stopped $APP" /bin/true + else + action $"Could not stop $APP" /bin/false + fi + return $RETVAL +} + +osgi_service_status() { + APP=$1 + USER=$APP + # call Argeo Commons OSGi utilities as the application user + runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP status" + RETVAL=$? + return $RETVAL +}