SolarisInstallation: coherence.sh

File coherence.sh, 1.8 kB (added by Mike, 5 months ago)

A start script (aka method script) for the OpenSolaris?? coherence services (SMF).

Line 
1 #!/bin/bash
2 #
3 #       /etc/rc.d/init.d/coherence
4 #
5 # Starts the coherence server
6 #
7 # chkconfig: 345 90 56
8 # description: An UPnP/DLNA MediaServer
9 # processname: coherence
10 # securlevel: 80
11 #
12 ### BEGIN INIT INFO
13 # Provides: coherence
14 # Default-Start: 3 4 5
15 # Required-Start: $network messagebus
16 # Required-Stop: $network messagebus
17 # Short-Description: Starts the coherence server
18 # Description: An UPnP/DLNA MediaServer
19 ### END INIT INFO
20
21 . /lib/svc/share/smf_include.sh
22
23 # Get the value of a property defined in the service xml.
24 getproparg() {
25         val=`svcprop -p $1 coherence`
26         [ -n "$val" ] && echo $val
27 }
28
29 PROGNAME=coherence
30 CONFIGFILE=`getproparg coherence/config`
31 DATADIR=`getproparg coherence/data`
32 LOCKFILE=${DATADIR}/`/usr/bin/uname -n`.lock
33
34 if [ -z ${DATADIR} ]; then
35         echo "coherence/data property not set"
36         exit $SMF_EXIT_ERR_CONFIG
37 fi
38
39 if [ ! -d ${DATADIR} ]; then
40         echo "coherence/data directory ${DATADIR} is not a valid directory"
41         exit $SMF_EXIT_ERR_CONFIG
42 fi
43
44 RETVAL=0
45
46 start() {
47         # Check if it is already running
48         if [ ! -f ${LOCKFILE} ]; then
49             echo "Starting: " /usr/bin/$PROGNAME -c $CONFIGFILE
50             $PROGNAME -c $CONFIGFILE &
51             RETVAL=$?
52             [ ${RETVAL} -eq 0 ] && touch ${LOCKFILE}
53             echo
54         fi
55         return $RETVAL
56 }
57
58 stop() {
59         echo "Stopping: " $PROGNAME
60         pkill -f /usr/bin/$PROGNAME
61         RETVAL=$?
62         [ ${RETVAL} -eq 0 ] && rm -f ${LOCKFILE}
63         return $RETVAL
64 }
65
66
67 restart() {
68         $0 stop
69         $0 start
70 }      
71
72 reload() {
73         trap "" SIGHUP
74         pkill -f /usr/bin/$PROGNAME
75         rm -f ${LOCKFILE}
76 }      
77
78 case "$1" in
79 start)
80         start
81         ;;
82 stop)
83         stop
84         ;;
85 reload)
86         reload
87         ;;
88 restart)
89         restart
90         ;;
91 condrestart)
92         if [ -f ${LOCKFILE} ]; then
93             restart
94         fi
95         ;;
96 status)
97         status $PROGNAME
98         ;;
99 *)
100         INITNAME=`basename $0`
101         gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" "$INITNAME"
102         exit 1
103 esac
104
105 exit $RETVAL