3 # silhouetted The startup script for the Pysilhouette system.
5 # chkconfig: 2345 97 03
6 # description: Pysilhouette is an application running in the background system.
8 # processname: silhouetted
9 # config: /etc/sysconfig/silhouetted
10 # pidfile: /var/run/silhouetted.pid
11 # /var/run/schedulerd.pid
12 # /var/run/performerd.pid
13 # /var/run/asynperformerd.pid
14 # /var/run/asynschedulerd.pid
16 # lockfile: /var/lock/subsys/silhouetted
17 # /var/lock/subsys/schedulerd
18 # /var/lock/subsys/performerd
19 # /var/lock/subsys/asynperformerd
20 # /var/lock/subsys/asynschedulerd
23 source /etc/rc.d/init.d/functions
24 source /etc/sysconfig/network
26 # For SELinux we need to use 'runuser' not 'su'
27 if [ -x /sbin/runuser ]; then
33 # Check that networking is up.
34 [ ${NETWORKING} = "no" ] && exit 1
40 sch_progd='schedulerd'
41 per_progd='performerd'
42 asyn_sch_progd='asynschedulerd'
43 asyn_per_progd='asynperformerd'
45 sysconfig="/etc/sysconfig/${progd}"
48 [ -r "${sysconfig}" ] && source "${sysconfig}"
50 if [ "x${PYTHON}" == "x" ]; then
55 conf="/etc/opt/${app}/${prog}.conf"
58 pidfile="/var/run/${progd}.pid"
59 lockfile="/var/lock/subsys/${progd}"
60 sch_pidfile="/var/run/${sch_progd}.pid"
61 sch_lockfile="/var/lock/subsys/${sch_progd}"
62 per_pidfile="/var/run/${per_progd}.pid"
63 per_lockfile="/var/lock/subsys/${per_progd}"
64 asyn_sch_pidfile="/var/run/${asyn_sch_progd}.pid"
65 asyn_sch_lockfile="/var/lock/subsys/${asyn_sch_progd}"
66 asyn_per_pidfile="/var/run/${asyn_per_progd}.pid"
67 asyn_per_lockfile="/var/lock/subsys/${asyn_per_progd}"
71 if [ "x${DAEMON}" = "xyes" ]; then
72 extra_args=${extra_args}" -d"
76 if [ "x${DEBUG}" = "xyes" ]; then
77 extra_args=${extra_args}" -v"
80 desc="${progd} (Daemon)"
83 CMD_ARGS="-p ${pidfile} -c ${conf} ${extra_args}"
87 echo -n $"Starting $desc: "
88 if [ -e ${pidfile} ]; then
89 echo "already running..."
93 touch ${pidfile} ${sch_pidfile} ${per_pidfile} ${asyn_sch_pidfile} ${asyn_per_pidfile}
94 chown ${USER}:${GROUP} ${pidfile} ${sch_pidfile} ${per_pidfile} ${asyn_sch_pidfile} ${asyn_per_pidfile}
95 if [ "x${PYTHON_SEARCH_PATH}" != "x" ]; then
96 env="PYTHONPATH=${PYTHON_SEARCH_PATH}:\$PYTHONPATH"
98 ${SU} -l ${USER} -c "${env} ${PYTHON} ${PREFIX}/opt/pysilhouette/bin/${prog}.py ${CMD_ARGS}"
100 if [ ${RETVAL} -eq 0 ]; then
101 touch ${lockfile} ${sch_lockfile} ${per_lockfile} ${asyn_sch_lockfile} ${asyn_per_lockfile}
112 echo -n $"Shutting down $desc: "
113 if [ ! -e ${pidfile} ]; then
114 echo "not running..."
118 if [ "x${pid}" == "x" ]; then
119 echo "not running... - not pid"
123 killproc -p ${pidfile} -15
132 if [ ${SIL_RETVAL} -eq 0 ]; then
138 eval "/etc/rc.d/init.d/${sch_progd} stop"
140 if [ ${SCH_RETVAL} -eq 0 ]; then
141 rm -f ${sch_lockfile}
146 eval "/etc/rc.d/init.d/${per_progd} stop"
148 if [ ${PER_RETVAL} -eq 0 ]; then
149 rm -f ${per_lockfile}
154 eval "/etc/rc.d/init.d/${asyn_sch_progd} stop"
156 if [ ${ASYN_SCH_RETVAL} -eq 0 ]; then
157 rm -f ${asyn_sch_lockfile}
158 rm -f ${asyn_sch_pidfile}
162 eval "/etc/rc.d/init.d/${asyn_per_progd} stop"
164 if [ ${ASYN_PER_RETVAL} -eq 0 ]; then
165 rm -f ${asyn_per_lockfile}
166 rm -f ${asyn_per_pidfile}
169 # The return code of the performer daemon is the first digit.
170 # The return code of the scheduler daemon is the second digit.
171 # The return code of the silhouetted daemon is the third digit.
172 # All stop functions return only the exit code of 0(Normal) or 1(Abnormal).
173 #RETVAL=`expr ${SIL_RETVAL} \* 100 + ${SCH_RETVAL} \* 10 + ${PER_RETVAL}`
174 RETVAL=`expr ${SIL_RETVAL} \* 10000 + ${SCH_RETVAL} \* 1000 + ${PER_RETVAL} \* 100 + ${ASYN_SCH_RETVAL} \* 10 + ${ASYN_PER_RETVAL}`
196 [ -e ${lockfile} ] && restart
201 eval "/etc/rc.d/init.d/${sch_progd} status"
202 eval "/etc/rc.d/init.d/${per_progd} status"
203 eval "/etc/rc.d/init.d/${asyn_sch_progd} status"
204 eval "/etc/rc.d/init.d/${asyn_per_progd} status"
208 echo $"Usage: $0 {start|stop|restart|condrestart|status}"