• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/samba-3.5.8/packaging/RHEL-CTDB/setup/
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.
13if [ -f /etc/init.d/functions ] ; then
14  . /etc/init.d/functions
15elif [ -f /etc/rc.d/init.d/functions ] ; then
16  . /etc/rc.d/init.d/functions
17else
18  exit 0
19fi
20
21# Avoid using root's TMPDIR
22unset TMPDIR
23
24# Source networking configuration.
25. /etc/sysconfig/network
26
27if [ -f /etc/sysconfig/samba ]; then
28   . /etc/sysconfig/samba
29fi
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
46ISNETBIOSDISABLED=Yes
47
48RETVAL=0
49
50
51start() {
52	KIND="SMB"
53	echo -n $"Starting $KIND services: "
54	daemon smbd $SMBDOPTIONS
55	RETVAL=$?
56	echo
57	KIND="NMB"
58	if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
59		echo -n $"Starting $KIND services: "
60		daemon nmbd $NMBDOPTIONS
61		RETVAL2=$?
62		echo
63		[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \
64			RETVAL=1
65	else
66		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb || \
67			RETVAL=1
68	fi
69	return $RETVAL
70}	
71
72stop() {
73	KIND="SMB"
74	echo -n $"Shutting down $KIND services: "
75	killproc smbd
76	RETVAL=$?
77	[ $RETVAL -eq 0 ] && rm -f /var/run/smbd.pid
78	echo
79	KIND="NMB"
80	if [ x"$ISNETBIOSDISABLED" != x"Yes" ]; then
81		echo -n $"Shutting down $KIND services: "
82		killproc nmbd 
83		RETVAL2=$?
84		[ $RETVAL2 -eq 0 ] && rm -f /var/run/nmbd.pid
85		[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb 
86		echo ""
87	else
88		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smb 
89		echo ""
90	fi
91	return $RETVAL
92}	
93
94restart() {
95	stop
96	start
97}	
98
99reload() {
100        echo -n $"Reloading smb.conf file: "
101	killproc smbd -HUP
102	RETVAL=$?
103	echo
104	return $RETVAL
105}	
106
107rhstatus() {
108	status smbd
109	status nmbd
110}	
111
112case "$1" in
113  start)
114  	start
115	;;
116  stop)
117  	stop
118	;;
119  restart)
120  	restart
121	;;
122  reload)
123  	reload
124	;;
125  status)
126  	rhstatus
127	;;
128  condrestart)
129  	[ -f /var/lock/subsys/smb ] && restart || :
130	;;
131  *)
132	echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
133	exit 1
134esac
135
136exit $?
137