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 # description: It comes by night and sucks the vital essence from your computers.
14 # A function to stop a program.
19 echo "Usage: killproc {program} [signal]"
24 # check for third arg to be kill level
25 if [ "$3" != "" ] ; then
32 # Get base program name
36 pid=`pidofproc $base $2`
39 if [ "$pid" != "" ] ; then
40 if [ "$notset" = "1" ] ; then
41 if ps -p $pid>/dev/null 2>&1; then
42 # TERM first, then KILL if not dead
43 kill -TERM $pid 2>/dev/null
45 if ps -p $pid >/dev/null 2>&1 ; then
47 if ps -p $pid >/dev/null 2>&1 ; then
49 if ps -p $pid >/dev/null 2>&1 ; then
50 kill -KILL $pid 2>/dev/null
55 ps -p $pid >/dev/null 2>&1
57 [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
59 # use specified level only
61 if ps -p $pid >/dev/null 2>&1; then
62 kill $killlevel $pid 2>/dev/null
64 [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
68 failure "$base shutdown"
70 # Remove pid file if any.
71 if [ "$notset" = "1" ]; then
72 rm -f @piddir@/$base.$2.pid
77 # A function to find the pid of a program.
82 echo "Usage: pidofproc {program}"
86 # Get base program name
90 if [ -f @piddir@/$base.$2.pid ] ; then
91 pid=`head -1 @piddir@/$base.$2.pid`
92 if [ "$pid" != "" ] ; then
99 if [ -x /sbin/pidof ] ; then
102 if [ "$pid" != "" ] ; then
107 # Finally try to extract it from ps
108 ${PSCMD} | grep $1 | awk '{ print $1 }' | tr '\n' ' '
115 echo "Usage: status {program}"
119 # Get base program name
123 if [ -x /sbin/pidof ] ; then
126 if [ "$pid" != "" ] ; then
127 echo "$base (pid $pid) is running..."
130 pid=`${PSCMD} | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
131 { if ((prog == $2) || (("(" prog ")") == $2) ||
132 (("[" prog "]") == $2) ||
133 ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
134 if [ "$pid" != "" ] ; then
135 echo "$base (pid $pid) is running..."
140 # Next try the PID files
141 if [ -f @piddir@/$base.$2.pid ] ; then
142 pid=`head -1 @piddir@/$base.$2.pid`
143 if [ "$pid" != "" ] ; then
144 echo "$base dead but pid file exists"
148 # See if the subsys lock exists
149 if [ -f @subsysdir@/$base ] ; then
150 echo "$base dead but subsys locked"
153 echo "$base is stopped"
168 echo "Starting the Storage daemon"
169 @sbindir@/bacula-sd $2 -c @sysconfdir@/bacula-sd.conf
170 echo "Starting the File daemon"
171 @sbindir@/bacula-fd $2 -c @sysconfdir@/bacula-fd.conf
173 echo "Starting the Director daemon"
174 @sbindir@/bacula-dir $2 -c @sysconfdir@/bacula-dir.conf
177 echo "Stopping the File daemon"
178 killproc @sbindir@/bacula-fd @fd_port@
179 echo "Stopping the Storage daemon"
180 killproc @sbindir@/bacula-sd @sd_port@
181 echo "Stopping the Director daemon"
182 killproc @sbindir@/bacula-dir @dir_port@
191 status @sbindir@/bacula-sd @sd_port@
192 status @sbindir@/bacula-fd @fd_port@
193 status @sbindir@/bacula-dir @dir_port@
196 echo "Usage: $0 {start|stop|restart|status}"