blob: 9c9e7a39b7bae6e6e80f8f448d9d5927064d60be (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/sbin/runscript
extra_started_commands="reload"
depend() {
need net
}
chkconfig() {
[ -z "${ROLES}" ] && { eerror "No role defined !"; return 1;}
for ROLE in ${ROLES}; do
if [ ! -f /etc/mfs/${ROLE}.cfg ]; then
eerror "Missing configuration file for role ${ROLE} !"
return 1
fi
done
return 0
}
autorestore() {
einfo "AUTORESTORE set, trying to restore metadata files"
mfsmetarestore -a &>/dev/null
return $?
}
start_role() {
local ROLE=$1
local RETURN=0
ebegin "${ROLE}"
start-stop-daemon -q --start --exec "${ROLE}" -- start >/dev/null
RETURN=$?
eend ${RETURN}
return ${RETURN}
}
start_roles() {
local RETURN=0
eindent
for ROLE in ${ROLES}; do
start_role ${ROLE} || RETURN=$?
eend ${RETURN}
if [ "${RETURN}" != "0" ] && [ "${ROLE}" == "mfsmaster" ] && [ ${AUTORESTORE} -eq 1 ]; then
eindent
autorestore && start_role ${ROLE}
RETURN=$?
eoutdent
fi
[ "${RETURN}" != "0" ] && break
done
eoutdent
return ${RETURN}
}
start() {
ebegin "Starting mfs node"
chkconfig && start_roles
eend $?
}
stop() {
local RETURN=0
ebegin "Stopping mfs node"
eindent
local REVERSE=$(echo ${ROLES} | tac -s' ')
for ROLE in ${REVERSE}; do
ebegin "${ROLE}"
start-stop-daemon -q --stop -n ${ROLE} || RETURN=$?
eend ${RETURN}
done
eoutdent
eend ${RETURN}
}
reload() {
local RETURN=0
ebegin "Reloading mfs node"
eindent
for ROLE in ${ROLES}; do
ebegin "${ROLE}"
start-stop-daemon --signal HUP -n ${ROLE}
eend ${RETURN}
done
eoutdent
eend ${RETURN}
}
|