summaryrefslogtreecommitdiffstats
path: root/ctdb/config/events/legacy/49.winbind.script
blob: 852b54165cff2b140fb0d0bc340e7d754a4c81a3 (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
#!/bin/sh
# ctdb event script for winbind

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

. "${CTDB_BASE}/functions"

CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}

# service_name is used by various functions
# shellcheck disable=SC2034
service_name="winbind"

load_script_options

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

    service "$CTDB_SERVICE_WINBIND" start || \
	die "Failed to start winbind"
}

service_stop ()
{
    service "$CTDB_SERVICE_WINBIND" stop
}

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

case "$1" in
startup)
	service_start
	;;

shutdown)
	service_stop
	;;

monitor)
	if ! out=$(wbinfo -p 2>&1) ; then
		echo "ERROR: wbinfo -p returned error"
		echo "$out"
		exit 1
	fi
	;;
esac

exit 0