-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscst_init
More file actions
92 lines (92 loc) · 2.38 KB
/
scst_init
File metadata and controls
92 lines (92 loc) · 2.38 KB
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
#!/bin/sh
#
# License: GNU General Public License (GPL)
# Support: schickdahin@localhost
# Written by: Matthias Ehrenfeuchter
#
# This script starts scst by init.d script
# It will load default /etc/scst.conf
#
# usage: $0 {start|stop|status|monitor|validate-all|meta-data}
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
: ${HELPERS_DIR=${OCF_ROOT}/lib/heartbeat/helpers}
# Set the variable below to '1' to enable logging.
# This is useful to determine how long these operations take on your system.
# DEBUG=0
DEBUGLOG="/var/log/scst_init.d_debug.log"
USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
#######################################################################
debug_log () {
if [ "$DEBUG" -eq 1 ]; then
echo "`date`:${OCF_RESKEY_pool}:" $@ >> "$DEBUGLOG"
fi
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="scst_init">
<version>1.0</version>
<longdesc lang="en">
This script starts scst by init.d script
It will load default /etc/scst.conf
</longdesc>
<shortdesc lang="en">Starts scst by init.d script</shortdesc>
<actions>
<action name="start" timeout="60s" />
<action name="stop" timeout="60s" />
<action name="monitor" depth="0" timeout="30s" interval="5s" />
<action name="validate-all" timeout="30s" />
<action name="meta-data" timeout="5s" />
</actions>
</resource-agent>
END
exit $OCF_SUCCESS
}
scst_status () {
/etc/init.d/scst status |grep "active (running)" > /dev/null
}
scst_start_init () {
/usr/sbin/iscsi-scstd > /dev/null
/etc/init.d/scst restart > /dev/null
/usr/sbin/iscsi-scstd > /dev/null
return $OCF_SUCCESS
}
scst_start () {
if scst_status
then
return $OCF_SUCCESS
else
scst_start_init
fi
}
scst_stop () {
/etc/init.d/scst stop > /dev/null
return $OCF_SUCCESS
}
scst_monitor () {
if scst_status
then
return $OCF_SUCCESS
else
return $OCF_NOT_RUNNING
fi
}
usage () {
echo $USAGE >&2
return $1
}
case $1 in
meta-data) meta_data;;
start) scst_start;;
stop) scst_stop;;
status|monitor) scst_monitor;;
validate-all) return $OCF_SUCCESS;;
usage) usage $OCF_SUCCESS;;
*) usage $OCF_ERR_UNIMPLEMENTED;;
esac
exit $?