]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi-service-init-functions.sh
35bf9703f0ea18ec70c23c26c149d4ed037e4e4c
[lgpl/argeo-commons.git] / osgi-service-init-functions.sh
1 #!/bin/bash
2
3 # Source function library.
4 . /etc/rc.d/init.d/functions
5
6 RETVAL=0
7
8 osgi_service_start() {
9 APP=$1
10 # create log an run directories writable by the application user
11 USER=$APP
12 GROUP=$APP
13 RUN_DIR=/var/run/$APP
14 LOG_DIR=/var/log/$APP
15 if [ ! -d $LOG_DIR ];then
16 mkdir -m 0750 $LOG_DIR
17 chown -R $USER.$GROUP $LOG_DIR
18 fi
19 if [ ! -d $RUN_DIR ];then
20 mkdir -m 0750 $RUN_DIR
21 chown -R $USER.$GROUP $RUN_DIR
22 fi
23
24 # call Argeo Commons OSGi utilities as the application user
25 daemon --user $USER /usr/sbin/osgi-service $APP start
26
27 RETVAL=$?
28 #action $"Start $APP" /bin/true
29 if [ $RETVAL -eq 0 ];then
30 PID=`cat $RUN_DIR/$APP.pid`
31 action $"Started $APP with pid $PID" /bin/true
32 else
33 action $"Could not start $APP" /bin/false
34 fi
35 return $RETVAL
36 }
37
38 osgi_service_stop() {
39 APP=$1
40 USER=$APP
41 # call Argeo Commons OSGi utilities as the application user
42 runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP stop"
43 RETVAL=$?
44 if [ $RETVAL -eq 0 ];then
45 action $"Stopped $APP" /bin/true
46 else
47 action $"Could not stop $APP" /bin/false
48 fi
49 return $RETVAL
50 }
51
52 osgi_service_status() {
53 APP=$1
54 USER=$APP
55 # call Argeo Commons OSGi utilities as the application user
56 runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP status"
57 RETVAL=$?
58 return $RETVAL
59 }