README.Coding: Mention that PEP8 is the standard for Python code.
[ambi/samba-autobuild/.git] / packaging4 / Fedora / samba4.init
1 #!/bin/sh
2 #
3 # chkconfig: - 91 35
4 # description: Starts and stops the Samba smbd daemon \
5 #              used to provide SMB network services.
6 #
7 # pidfile: /var/run/samba4/smbd.pid
8 # config:  /etc/samba4/smb.conf
9
10 SAMBA_NAME=samba4
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 1
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_NAME ]; then
28    . /etc/sysconfig/$SAMBA_NAME
29 fi
30
31 # Check that networking is up.
32 [ ${NETWORKING} = "no" ] && exit 1
33
34 # Check that smb.conf exists.
35 [ -f /etc/$SAMBA_NAME/smb.conf ] || exit 6
36
37 RETVAL=0
38
39
40 start() {
41         echo -n $"Starting Samba services: "
42         daemon smbd $SMBDOPTIONS
43         RETVAL=$?
44         echo
45         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SAMBA_NAME || \
46            RETVAL=1
47         return $RETVAL
48 }       
49
50 stop() {
51         echo -n $"Shutting down Samba services: "
52         killproc smbd
53         RETVAL=$?
54         echo
55         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SAMBA_NAME
56         return $RETVAL
57 }       
58
59 restart() {
60         stop
61         start
62 }       
63
64 reload() {
65         echo -n $"Reloading smb.conf file: "
66         killproc smbd -HUP
67         RETVAL=$?
68         echo
69         return $RETVAL
70 }       
71
72 rhstatus() {
73         status smbd
74         return $?
75 }       
76
77
78 # Allow status as non-root.
79 if [ "$1" = status ]; then
80        rhstatus
81        exit $?
82 fi
83
84 # Check that we can write to it... so non-root users stop here
85 [ -w /etc/$SAMBA_NAME/smb.conf ] || exit 4
86
87
88
89 case "$1" in
90   start)
91         start
92         ;;
93   stop)
94         stop
95         ;;
96   restart)
97         restart
98         ;;
99   reload)
100         reload
101         ;;
102   status)
103         rhstatus
104         ;;
105   condrestart)
106         [ -f /var/lock/subsys/$SAMBA_NAME ] && restart || :
107         ;;
108   *)
109         echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
110         exit 2
111 esac
112
113 exit $?