~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to packaging/RHEL/setup/smb.init

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# chkconfig: - 91 35
 
4
# description: Starts and stops the Samba smbd and nmbd daemons \
 
5
#              used to provide SMB network services.
 
6
#
 
7
# pidfile: /var/run/samba/smbd.pid
 
8
# pidfile: /var/run/samba/nmbd.pid
 
9
# config:  /etc/samba/smb.conf
 
10
 
 
11
 
 
12
# Source function library.
 
13
if [ -f /etc/init.d/functions ] ; then
 
14
  . /etc/init.d/functions
 
15
elif [ -f /etc/rc.d/init.d/functions ] ; then
 
16
  . /etc/rc.d/init.d/functions
 
17
else
 
18
  exit 0
 
19
fi
 
20
 
 
21
# Avoid using root's TMPDIR
 
22
unset TMPDIR
 
23
 
 
24
# Source networking configuration.
 
25
. /etc/sysconfig/network
 
26
 
 
27
if [ -f /etc/sysconfig/samba ]; then
 
28
   . /etc/sysconfig/samba
 
29
fi
 
30
 
 
31
# Check that networking is up.
 
32
[ ${NETWORKING} = "no" ] && exit 0
 
33
 
 
34
# Check that smb.conf exists.
 
35
[ -f /etc/samba/smb.conf ] || exit 0
 
36
 
 
37
# Check that we can write to it... so non-root users stop here
 
38
[ -w /etc/samba/smb.conf ] || exit 0
 
39
 
 
40
# Check whether "netbios disabled" is true
 
41
ISNETBIOSDISABLED=$(testparm -s 2>/dev/null | \
 
42
        sed -n '/\[global\]/,/^$/p' | \
 
43
        grep "disable netbios = Yes" | \
 
44
        awk 'BEGIN{FS=" = "}{print $2}')
 
45
 
 
46
 
 
47
RETVAL=0
 
48
 
 
49
 
 
50
start() {
 
51
        KIND="SMB"
 
52
        echo -n $"Starting $KIND services: "
 
53
        daemon smbd $SMBDOPTIONS
 
54
        RETVAL=$?
 
55
        echo
 
56
        KIND="NMB"
 
57
        if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
 
58
                echo -n $"Starting $KIND services: "
 
59
                daemon nmbd $NMBDOPTIONS
 
60
                RETVAL2=$?
 
61
                echo
 
62
                [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
 
63
                        RETVAL=1
 
64
        else
 
65
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
 
66
                        RETVAL=1
 
67
        fi
 
68
        return $RETVAL
 
69
}       
 
70
 
 
71
stop() {
 
72
        KIND="SMB"
 
73
        echo -n $"Shutting down $KIND services: "
 
74
        killproc smbd
 
75
        RETVAL=$?
 
76
        [ $RETVAL -eq 0 ] && rm -f /var/run/smbd.pid
 
77
        echo
 
78
        KIND="NMB"
 
79
        if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
 
80
                echo -n $"Shutting down $KIND services: "
 
81
                killproc nmbd 
 
82
                RETVAL2=$?
 
83
                [ $RETVAL2 -eq 0 ] && rm -f /var/run/nmbd.pid
 
84
                [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb 
 
85
                echo ""
 
86
        else
 
87
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb 
 
88
                echo ""
 
89
        fi
 
90
        return $RETVAL
 
91
}       
 
92
 
 
93
restart() {
 
94
        stop
 
95
        start
 
96
}       
 
97
 
 
98
reload() {
 
99
        echo -n $"Reloading smb.conf file: "
 
100
        killproc smbd -HUP
 
101
        RETVAL=$?
 
102
        echo
 
103
        return $RETVAL
 
104
}       
 
105
 
 
106
rhstatus() {
 
107
        status smbd
 
108
        status nmbd
 
109
}       
 
110
 
 
111
case "$1" in
 
112
  start)
 
113
        start
 
114
        ;;
 
115
  stop)
 
116
        stop
 
117
        ;;
 
118
  restart)
 
119
        restart
 
120
        ;;
 
121
  reload)
 
122
        reload
 
123
        ;;
 
124
  status)
 
125
        rhstatus
 
126
        ;;
 
127
  condrestart)
 
128
        [ -f /var/lock/subsys/smb ] && restart || :
 
129
        ;;
 
130
  *)
 
131
        echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
 
132
        exit 1
 
133
esac
 
134
 
 
135
exit $?