]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh
Move to the root the bundles which will be part of v1.4 and v2.2
[lgpl/argeo-commons.git] / dist / osgi-boot / src / main / rpm / etc / osgiboot / osgi-service-init-functions.sh
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 (file)
index 0000000..35bf970
--- /dev/null
@@ -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
+}