summaryrefslogtreecommitdiff
path: root/source3/script/tests/functions
blob: 4cc8d4a2c0865f02f9ca464c2fd9b9178e9c0d96 (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
##
## library file for test functions
##

##
## start/stop smbd daemon
##
check_smbd_running()
{
	## the smbcontrol ping will return a 0 on success
	smbcontrol $CONFIGURATION smbd ping 2>&1 > /dev/null
}

start_smbd()
{
	echo "Starting smbd...."

	smbd $CONFIGURATION || return $?

	sleep 1

	smbcontrol $CONFIGURATION `cat $PIDDIR/smbd.pid` ping 2>&1 > /dev/null || return $?
}

stop_smbd()
{
	smbd_pid=`cat $PIDDIR/smbd.pid`
	echo "Shutting down smbd (pid $smbd_pid)..."

	## belt and braces; first kill and then send a shutdown message

	kill -TERM $smbd_pid
	smbcontrol $CONFIGURATION smbd shutdown

	## check to see if smbd is already running
	check_smbd_running
	if test $? == 0; then
		echo "Unable to stop smbd!"
		exit 2
	fi
}