]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/redhat/bacula-sd.in
Big backport from Enterprise
[bacula/bacula] / bacula / platforms / redhat / bacula-sd.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 Storage daemon.
8 #
9 # chkconfig: 2345 90 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 SD_USER=@sd_user@
21 SD_GROUP=@sd_group@
22 SD_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 SD_OPTIONS, SD_USER, SD_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 [ "${SD_USER}" != '' ]; then
43           SD_OPTIONS="${SD_OPTIONS} -u ${SD_USER}"
44        fi
45                                                                                    
46        if [ "${SD_GROUP}" != '' ]; then
47           SD_OPTIONS="${SD_OPTIONS} -g ${SD_GROUP}"
48        fi
49
50        if [ "${DAEMON_USER}" != '' -a "${SD_USER}" != '' ]; then
51           SD_OPTIONS=""
52           if [ "${SD_GROUP}" != '' ]; then
53              chown ${SD_USER}:${SD_GROUP} @working_dir@/bacula-sd* 2> /dev/null
54           else 
55              chown ${SD_USER} @working_dir@/bacula-sd* 2> /dev/null
56           fi
57           DAEMON_OPTIONS="--user ${SD_USER}"
58        fi
59
60        echo -n "Starting Bacula Storage services: "
61        daemon $DAEMON_OPTIONS @sbindir@/bacula-sd $2 ${SD_OPTIONS} -c @sysconfdir@/bacula-sd.conf
62        RETVAL=$?
63        echo
64        if [ $RETVAL -eq 0 ]; then
65           touch @subsysdir@/bacula-sd
66           logger -p daemon.info "bacula-sd started" >/dev/null 2>/dev/null
67        fi
68        ;;
69     stop)
70        echo -n "Stopping Bacula Storage services: "
71        killproc @sbindir@/bacula-sd
72        RETVAL=$?
73        echo
74        if [ $RETVAL -eq 0 ]; then
75           rm -f @subsysdir@/bacula-sd
76           logger -p daemon.info "bacula-sd stopped" >/dev/null 2>/dev/null
77        fi
78        ;;
79     restart)
80        $0 stop
81        sleep 5
82        $0 start
83        RETVAL=$?
84        ;;
85     status)
86        status @sbindir@/bacula-sd
87        RETVAL=$?
88        ;;
89     *)
90        echo "Usage: $0 {start|stop|restart|status}"
91        exit 1
92        ;;
93 esac
94 exit $RETVAL