]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/ubuntu/bacula-dir.in
Backport from Bacula Enterprise
[bacula/bacula] / bacula / platforms / ubuntu / bacula-dir.in
1 #! /bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # bacula  This shell script takes care of starting and stopping
7 #         the bacula Director daemon on Debian/Ubuntu/Kubuntu 
8 #         systems. 
9 #
10 #   Kern E. Sibbald - 21 March 2008
11 #
12 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
13 #
14
15 ### BEGIN INIT INFO
16 # Provides:             bacula-dir
17 # Required-Start:       $local_fs $remote_fs $network $time
18 # Required-Stop:        $local_fs $remote_fs $network $time
19 # Default-Start:        2 3 4 5
20 # Default-Stop:         0 1 6
21 # Short-Description:    Bacula Director
22 # Description:          Bacula is a network backup and restore program
23 ### END INIT INFO
24
25
26 NAME="bacula-dir"
27 DESC="Bacula Director"
28 DAEMON=@sbindir@/${NAME}
29 BUSER=@dir_user@
30 BGROUP=@dir_group@
31 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
32 BPORT=@dir_port@
33
34 PATH=/sbin:/bin:/usr/sbin:/usr/bin
35
36 test -f $DAEMON || exit 0
37
38 #
39 # Disable Glibc malloc checks, it doesn't help and it keeps from getting
40 #   good dumps
41 MALLOC_CHECK_=0
42 export MALLOC_CHECK_
43
44 if [ -n "`getent services ${NAME}`" ]; then
45    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
46 fi
47
48 if [ -f /etc/default/$NAME ]; then
49    . /etc/default/$NAME
50 fi
51
52 mkdir -p @piddir@
53 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
54
55 if [ "x${BUSER}" != "x" ]; then
56    USERGRP="--chuid ${BUSER}"
57    if [ "x${BGROUP}" != "x" ]; then
58       USERGRP="${USERGRP}:${BGROUP}"
59    fi
60 fi
61
62 RETVAL=0
63 case "$1" in
64    start)
65       echo -n "Starting ${DESC}: "
66       start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
67       RETVAL=$?
68       echo "${NAME}"
69       ;;
70    stop)
71       echo -n "Stopping ${DESC}: "
72       start-stop-daemon --oknodo --stop --quiet  ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
73       RETVAL=$?
74       echo "${NAME}"
75       ;;
76    restart|force-reload)
77       $0 stop
78       sleep 5
79       $0 start
80       RETVAL=$?
81       ;;
82    *)
83       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
84       exit 1
85       ;;
86 esac
87 exit $RETVAL