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 # lockfile: /var/lock/subsys/silhouetted
14 # /var/lock/subsys/schedulerd
15 # /var/lock/subsys/performerd
17 source /etc/rc.d/init.d/functions
18 source /etc/sysconfig/network
20 # For SELinux we need to use 'runuser' not 'su'
21 if [ -x /sbin/runuser ]; then
27 # Check that networking is up.
28 [ ${NETWORKING} = "no" ] && exit 1
34 sch_progd='schedulerd'
35 per_progd='performerd'
37 sysconfig="/etc/sysconfig/${progd}"
40 [ -r "${sysconfig}" ] && source "${sysconfig}"
42 if [ "x${PYTHON}" == "x" ]; then
47 conf="/etc/opt/${app}/${prog}.conf"
50 pidfile="/var/run/${progd}.pid"
51 lockfile="/var/lock/subsys/${progd}"
52 sch_pidfile="/var/run/${sch_progd}.pid"
53 sch_lockfile="/var/lock/subsys/${sch_progd}"
54 per_pidfile="/var/run/${per_progd}.pid"
55 per_lockfile="/var/lock/subsys/${per_progd}"
59 if [ "x${DAEMON}" = "xyes" ]; then
60 extra_args=${extra_args}" -d"
64 if [ "x${DEBUG}" = "xyes" ]; then
65 extra_args=${extra_args}" -v"
68 desc="${progd} (Daemon)"
71 CMD_ARGS="-p ${pidfile} -c ${conf} ${extra_args}"
75 echo -n $"Starting $desc: "
76 if [ -e ${pidfile} ]; then
77 echo "already running..."
81 touch ${pidfile} ${sch_pidfile} ${per_pidfile}
82 chown ${USER}:${GROUP} ${pidfile} ${sch_pidfile} ${per_pidfile}
83 if [ "x${PYTHON_SEARCH_PATH}" != "x" ]; then
84 env="PYTHONPATH=${PYTHON_SEARCH_PATH}:\$PYTHONPATH"
86 ${SU} -l ${USER} -c "${env} ${PYTHON} ${PREFIX}/opt/pysilhouette/bin/${prog}.py ${CMD_ARGS}"
88 if [ ${RETVAL} -eq 0 ]; then
89 touch ${lockfile} ${sch_lockfile} ${per_lockfile}
100 echo -n $"Shutting down $desc: "
101 if [ ! -e ${pidfile} ]; then
102 echo "not running..."
106 if [ "x${pid}" == "x" ]; then
107 echo "not running... - not pid"
111 killproc -p ${pidfile} -15
120 if [ ${SIL_RETVAL} -eq 0 ]; then
124 eval "/etc/rc.d/init.d/${sch_progd} stop"
126 if [ ${SCH_RETVAL} -eq 0 ]; then
127 rm -f ${sch_lockfile}
130 eval "/etc/rc.d/init.d/${per_progd} stop"
132 if [ ${PER_RETVAL} -eq 0 ]; then
133 rm -f ${per_lockfile}
136 # The return code of the performer daemon is the first digit.
137 # The return code of the scheduler daemon is the second digit.
138 # The return code of the silhouetted daemon is the third digit.
139 # All stop functions return only the exit code of 0(Normal) or 1(Abnormal).
140 RETVAL=`expr ${SIL_RETVAL} \* 100 + ${SCH_RETVAL} \* 10 + ${PER_RETVAL}`
162 [ -e ${lockfile} ] && restart
167 eval "/etc/rc.d/init.d/${sch_progd} status"
168 eval "/etc/rc.d/init.d/${per_progd} status"
172 echo $"Usage: $0 {start|stop|restart|condrestart|status}"