3 # bacula This shell script takes care of starting and stopping
6 # This is pretty much watered down version of the RedHat script
7 # that works on Solaris as well as Linux, but it won't work everywhere.
9 # Submitted by Volker Sauer <volker@volker-sauer.de> 21Feb04
10 # Tweaked a bit by Kern to convert it to a .in file
12 # description: It comes by night and sucks the vital essence from your computers.
16 # Required-Start: network mysql
20 # Description: run bacula daemon(s)
27 # A function to stop a program.
32 echo "Usage: killproc {program} [signal]"
37 # check for third arg to be kill level
38 if [ "$3" != "" ] ; then
45 # Get base program name
49 pid=`pidofproc $base $2`
52 if [ "$pid" != "" ] ; then
53 if [ "$notset" = "1" ] ; then
54 if ps -p $pid>/dev/null 2>&1; then
55 # TERM first, then KILL if not dead
56 kill -TERM $pid 2>/dev/null
58 if ps -p $pid >/dev/null 2>&1 ; then
60 if ps -p $pid >/dev/null 2>&1 ; then
62 if ps -p $pid >/dev/null 2>&1 ; then
63 kill -KILL $pid 2>/dev/null
68 ps -p $pid >/dev/null 2>&1
70 [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
72 # use specified level only
74 if ps -p $pid >/dev/null 2>&1; then
75 kill $killlevel $pid 2>/dev/null
77 [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
81 failure "$base shutdown"
83 # Remove pid file if any.
84 if [ "$notset" = "1" ]; then
85 rm -f ${PIDDIR}/$base.$2.pid
90 # A function to find the pid of a program.
95 echo "Usage: pidofproc {program}"
99 # Get base program name
103 if [ -f ${PIDDIR}/$base.$2.pid ] ; then
104 pid=`head -1 ${PIDDIR}/$base.$2.pid`
105 if [ "$pid" != "" ] ; then
112 if [ -x /sbin/pidof ] ; then
115 if [ "$pid" != "" ] ; then
120 # Finally try to extract it from ps
121 ${PSCMD} | grep $1 | awk '{ print $1 }' | tr '\n' ' '
128 echo "Usage: status {program}"
132 # Get base program name
136 if [ -x /sbin/pidof ] ; then
139 if [ "$pid" != "" ] ; then
140 echo "$base (pid $pid) is running..."
143 pid=`${PSCMD} | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
144 { if ((prog == $2) || (("(" prog ")") == $2) ||
145 (("[" prog "]") == $2) ||
146 ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
147 if [ "$pid" != "" ] ; then
148 echo "$base (pid $pid) is running..."
153 # Next try the PID files
154 if [ -f ${PIDDIR}/$base.$2.pid ] ; then
155 pid=`head -1 ${PIDDIR}/$base.$2.pid`
156 if [ "$pid" != "" ] ; then
157 echo "$base not running, but pid file exists"
161 # See if the subsys lock exists
162 if [ -f ${SUBSYSDIR}/$base ] ; then
163 echo "$base not running, but subsys locked"
166 echo "$base is stopped"
181 echo "Starting the Storage daemon"
182 @sbindir@/bacula-sd $2 -v -c @sysconfdir@//bacula-sd.conf
183 echo "Starting the File daemon"
184 @sbindir@/bacula-fd $2 -v -c @sysconfdir@//bacula-fd.conf
186 echo "Starting the Director daemon"
187 @sbindir@/bacula-dir $2 -v -c @sysconfdir@//bacula-dir.conf
190 echo "Stopping the File daemon"
191 killproc @sbindir@/bacula-fd 9102
192 echo "Stopping the Storage daemon"
193 killproc @sbindir@/bacula-sd 9103
194 echo "Stopping the Director daemon"
195 killproc @sbindir@/bacula-dir 9101
204 status @sbindir@/bacula-sd 9103
205 status @sbindir@/bacula-fd 9102
206 status @sbindir@/bacula-dir 9101
209 echo "Usage: $0 {start|stop|restart|status}"