blob: b057ef3e329a32fad4de0af13b75ca796e6fc875 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/gnbd/files/gnbd-srv-1.0x.rc,v 1.1 2008/03/17 16:59:57 xmerlin Exp $
depend() {
use dns logger
need net
need fenced
}
GNBD_SRV_TIMEOUT=5
start() {
local GNBD
if [ ! -f /etc/gnbdtab ] ; then
eerror "Please create /etc/gnbdtab"
eerror "Sample conf: /etc/gnbdtab"
return 1
fi
ebegin "Loading needed kernel modules for gnbd"
modprobe gnbd
eend $? "Failed to load needed kernel modules for gnbd"
ebegin "Starting gnbd_serv"
start-stop-daemon --start --quiet --exec /sbin/gnbd_serv -- -q
eend $? "Failed to start gnbd_serv"
GNBD=`cat /etc/gnbdtab | egrep '^export'`
if [ -n "$GNBD" ] ; then
ebegin "Exporting all GNBDs devices"
einfo "$(awk '/^export/ { print "--> device:", $4, "as", $3 }' /etc/gnbdtab )"
cat /etc/gnbdtab | awk '/^export/ { print "-d", $4, "-e", $3 }' | xargs -l gnbd_export ${GNBD_SRV_OPTS} > /dev/null
eend $? "Failed to export gnbd devices"
fi
}
stop() {
local GNBD_SRV_PROCS GNBD_CLUSTERD_PROC
ebegin "Unexporting all GNBDs devices"
gnbd_export -q -R &> /dev/null
eend $?
if [ "$?" -ne 0 ]
then
ewend 1 "Failed to unexport all gnbd devices"
else
eend 0
fi
ebegin "Stopping gnbd_serv"
GNBD_SRV_PROCS="$(pgrep gnbd_serv)"
while [ -n "${GNBD_SRV_PROCS}" ] && [ ${GNBD_SRV_TIMEOUT} -gt 0 ] ; do
gnbd_serv -k &> /dev/null
sleep 1
GNBD_SRV_TIMEOUT=$(( ${GNBD_SRV_TIMEOUT}-1 ))
GNBD_SRV_PROCS="$(pgrep gnbd_serv)"
done
if [ -n "${GNBD_SRV_PROCS}" ]; then
gnbd_serv -K &> /dev/null
fi
eend $? "Failed to stop gnbd_serv"
GNBD_CLUSTERD_PROC="$(pgrep gnbd_clusterd)"
if [ -n "${GNBD_CLUSTERD_PROC}" ]; then
ebegin "Stopping gnbd_clusterd"
killall gnbd_clusterd &> /dev/null
eend $?
fi
ebegin "Unloading gnbd kernel module"
modprobe -r gnbd
eend $? "Failed to unload gnbd kernel module"
}
|