]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/ubuntu/bacula-sd.in
Merge branch 'master' of ssh://bacula.git.sourceforge.net/gitroot/bacula/bacula
[bacula/bacula] / bacula / platforms / ubuntu / bacula-sd.in
1 #! /bin/sh
2 #
3 # bacula  This shell script takes care of starting and stopping
4 #         the bacula Director daemon on Debian/Ubuntu/Kubuntu 
5 #         systems. 
6 #
7 #   Kern E. Sibbald - 21 March 2008
8 #
9 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
10 #
11
12 NAME="bacula-sd"
13 DESC="Bacula Storage Daemon"
14 DAEMON=@sbindir@/${NAME}
15 BUSER=@sd_user@
16 BGROUP=@sd_group@
17 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
18 BPORT=@sd_port@
19
20 PATH=/sbin:/bin:/usr/sbin:/usr/bin
21
22 test -f $DAEMON || exit 0
23
24 #
25 # Disable Glibc malloc checks, it doesn't help and it keeps from getting
26 #   good dumps
27 MALLOC_CHECK_=0
28 export MALLOC_CHECK_
29
30 if [ -n "`getent services ${NAME}`" ]; then
31    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
32 fi
33
34 mkdir -p @piddir@
35 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
36
37 if [ "x${BUSER}" != "x" ]; then
38    BOPTIONS="${BOPTIONS} -u ${BUSER}"
39 fi
40 if [ "x${BGROUP}" != "x" ]; then
41    BOPTIONS="${BOPTIONS} -g ${BGROUP}"
42 fi
43
44 case "$1" in
45    start)
46       echo -n "Starting ${DESC}: "
47       start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- ${BOPTIONS}
48       echo "${NAME}"
49       ;;
50    stop)
51       echo -n "Stopping ${DESC}: "
52       start-stop-daemon --oknodo --stop --quiet --exec ${DAEMON} -- ${BOPTIONS}
53       echo "${NAME}"
54       ;;
55    restart|force-reload)
56       $0 stop
57       sleep 5
58       $0 start
59       ;;
60    *)
61       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
62       exit 1
63       ;;
64 esac
65 exit 0