]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/ubuntu/bacula-dir.in
Make Ubuntu autostart scripts LSB compliant
[bacula/bacula] / bacula / platforms / ubuntu / bacula-dir.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 ### BEGIN INIT INFO
13 # Provides:             bacula-dir
14 # Required-Start:       $local_fs $remote_fs $network $time
15 # Required-Stop:        $local_fs $remote_fs $network $time
16 # Default-Start:        2 3 4 5
17 # Default-Stop:         0 1 6
18 # Short-Description:    Bacula Director
19 # Description:          Bacula is a network backup and restore program
20 ### END INIT INFO
21
22
23 NAME="bacula-dir"
24 DESC="Bacula Director"
25 DAEMON=@sbindir@/${NAME}
26 BUSER=@dir_user@
27 BGROUP=@dir_group@
28 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
29 BPORT=@dir_port@
30
31 PATH=/sbin:/bin:/usr/sbin:/usr/bin
32
33 test -f $DAEMON || exit 0
34
35 #
36 # Disable Glibc malloc checks, it doesn't help and it keeps from getting
37 #   good dumps
38 MALLOC_CHECK_=0
39 export MALLOC_CHECK_
40
41 if [ -n "`getent services ${NAME}`" ]; then
42    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
43 fi
44
45 mkdir -p @piddir@
46 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
47
48 if [ "x${BUSER}" != "x" ]; then
49    BOPTIONS="${BOPTIONS} -u ${BUSER}"
50 fi
51 if [ "x${BGROUP}" != "x" ]; then
52    BOPTIONS="${BOPTIONS} -g ${BGROUP}"
53 fi
54
55 case "$1" in
56    start)
57       echo -n "Starting ${DESC}: "
58       start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- ${BOPTIONS}
59       RETVAL=$?
60       echo "${NAME}"
61       ;;
62    stop)
63       echo -n "Stopping ${DESC}: "
64       start-stop-daemon --oknodo --stop --quiet --exec ${DAEMON} -- ${BOPTIONS}
65       RETVAL=$?
66       echo "${NAME}"
67       ;;
68    restart|force-reload)
69       $0 stop
70       sleep 5
71       $0 start
72       ;;
73    *)
74       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
75       exit 1
76       ;;
77 esac
78 exit $RETVAL