summaryrefslogtreecommitdiff
path: root/pcr/samba4/samba4.rc
blob: 73d09fe30c76b6188fed9577747d2e57fc53bfd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

[ -f /etc/conf.d/samba4 ] && . /etc/conf.d/samba4

function call_samba4() {
	/opt/samba4/sbin/samba -D $SAMBA4_ARGS
}

case "$1" in
	start)
		stat_busy "Starting Samba4 Server"
		if [ ! -x /opt/samba4/var ] ; then
			install -m755 -d /opt/samba4/var
		fi
		if [ ! -x /opt/samba4/var/run ] ; then
			install -m755 -d /opt/samba4/var/run
		fi
		PID=`pidof -o %PPID /opt/samba4/sbin/samba`
		[ -z "$PID" ] && call_samba4
		if [ $? -gt 0 ]; then
			stat_fail
		else
			add_daemon samba4
			stat_done
		fi
		;;
	stop)
		stat_busy "Stopping Samba4 Server"
		PID=`pidof -o %PPID /opt/samba4/sbin/samba`
		[ -z "$PID" ] || kill $PID &> /dev/null
		if [ $? -gt 0 ]; then
			stat_fail
		else
			rm /opt/samba4/var/run/samba.pid &> /dev/null
			rm_daemon samba4
			stat_done
		fi
		;;
	restart)
		$0 stop
		sleep 1
		$0 start
		;;
	*)
		echo "usage: $0 {start|stop|restart}"
esac
exit 0