summaryrefslogtreecommitdiffstats
path: root/ctdb/config/events/legacy/48.netbios.script
blob: 43204476d6b258800c227c34b0faff95568e6ce0 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# ctdb event script for Netbios Name Services

[ -n "$CTDB_BASE" ] || \
	CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")

. "${CTDB_BASE}/functions"

detect_init_style

case $CTDB_INIT_STYLE in
	suse)
		CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
		;;
	debian)
		CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmbd}
		;;
	*)
		# Use redhat style as default:
		CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
		;;
esac

service_name="netbios"

load_script_options

ctdb_setup_state_dir "service" "$service_name"

service_start ()
{
    # make sure nmbd is not already started
    service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
    killall -0 -q nmbd && {
	sleep 1
	# make absolutely sure nmbd is dead
	killall -q -9 nmbd
    }

    # start Samba nmbd service. Start it reniced, as under very heavy load
    # the number of smbd processes will mean that it leaves few cycles
    # for anything else
    nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start nmbd"
}

service_stop ()
{
    service "$CTDB_SERVICE_NMB" stop
}

###########################

case "$1" in
startup)
	service_start
	;;

shutdown)
	service_stop
	;;

esac

exit 0