]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/redhat/bacula-dir.in
a36d4a461559519b1591a61510ff53e2bafa254a
[bacula/bacula] / bacula / platforms / redhat / 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
8 #
9 # chkconfig: 2345 92 9
10 # description: The Leading Open Source Backup Solution.
11 #
12 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
13 #
14
15 # Source function library
16 . /etc/rc.d/init.d/functions
17
18 DAEMON_OPTIONS=''
19 DAEMON_USER='yes'
20 DIR_USER=@dir_user@
21 DIR_GROUP=@dir_group@
22 DIR_OPTIONS=''
23 OS=`uname -s`
24
25 # if /lib/tls exists, force Bacula to use the glibc pthreads instead
26 if [ -d "/lib/tls" -a $OS = "Linux" -a `uname -r | cut -c1-3` = "2.4" ] ; then
27      export LD_ASSUME_KERNEL=2.4.19
28 fi
29
30 # pull in any user defined DIR_DIR_OPTIONS, DIR_USER, DIR_GROUP or DAEMON_USER
31 [ -f /etc/sysconfig/bacula ] && . /etc/sysconfig/bacula
32
33 #
34 # Disable Glibc malloc checks, it doesn't help and it keeps from getting
35 #   good dumps
36 MALLOC_CHECK_=0
37 export MALLOC_CHECK_
38
39 RETVAL=0
40 case "$1" in
41     start)
42        if [ "${DIR_USER}" != '' ]; then
43           DIR_OPTIONS="${DIR_OPTIONS} -u ${DIR_USER}"
44        fi
45                                                                                    
46        if [ "${DIR_GROUP}" != '' ]; then
47           DIR_OPTIONS="${DIR_OPTIONS} -g ${DIR_GROUP}"
48        fi
49
50        if [ "${DAEMON_USER}" != '' -a "${DIR_USER}" != '' ]; then
51           DIR_OPTIONS=""
52           if [ "${DIR_GROUP}" != '' ]; then
53              chown ${DIR_USER}:${DIR_GROUP} @working_dir@/bacula-dir* 2> /dev/null
54           else 
55              chown ${DIR_USER} @working_dir@/bacula-dir* 2> /dev/null
56           fi
57           DAEMON_OPTIONS="--user ${DIR_USER}"
58        fi
59        echo -n "Starting Bacula Director services: "
60        daemon $DAEMON_OPTIONS @sbindir@/bacula-dir $2 ${DIR_OPTIONS} -c @sysconfdir@/bacula-dir.conf
61        RETVAL=$?
62        echo
63        [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-dir
64        ;;
65     stop)
66        echo -n "Stopping Bacula Director services: "
67        killproc @sbindir@/bacula-dir
68        RETVAL=$?
69        echo
70        [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-dir
71        ;;
72     restart)
73        $0 stop
74        sleep 5
75        $0 start
76        RETVAL=$?
77        ;;
78     status)
79        status @sbindir@/bacula-dir
80        RETVAL=$?
81        ;;
82     *)
83        echo "Usage: $0 {start|stop|restart|status}"
84        exit 1
85        ;;
86 esac
87 exit $RETVAL