]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/redhat/bacula-sd.in
d8c3440bcc1a351b704a4ea684c65516202ba560
[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        [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-sd
65        ;;
66     stop)
67        echo -n "Stopping Bacula Storage services: "
68        killproc @sbindir@/bacula-sd
69        RETVAL=$?
70        echo
71        [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-sd
72        ;;
73     restart)
74        $0 stop
75        sleep 5
76        $0 start
77        RETVAL=$?
78        ;;
79     status)
80        status @sbindir@/bacula-sd
81        RETVAL=$?
82        ;;
83     *)
84        echo "Usage: $0 {start|stop|restart|status}"
85        exit 1
86        ;;
87 esac
88 exit $RETVAL