blob: d0755a22b67a7400bbe5f8dfbe4b764e4342ea7b (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: leofs
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
#
# /etc/rc.conf variables:
#
# leofs_enable (bool): Set it to "YES" to enable swift.
# Default is "NO".
# leofs_servers (list): Specify servers to run as a space separated
# list of possible values:
# gateway,
# manager,
# manager_slave,
# storage.
# The aliase ALL may be used to run all servers.
# Also the list can be overriden in command line:
# any arguments but the first (if there are) are
# treated as the server list.
# Default is "ALL".
# leofs_user (string): Set it to a user name the servers are run as.
# Default is "%%LEOFS_USER%%".
. /etc/rc.subr
name=leofs
rcvar=leofs_enable
load_rc_config $name
: ${leofs_enable:="NO"}
: ${leofs_servers:="ALL"}
: ${leofs_user=%%LEOFS_USER%%}
extra_commands="status"
restart_cdm=leofs_restart
start_cmd=leofs_start
status_cmd=leofs_status
stop_cmd=leofs_stop
leofs_restart()
{
leofs_stop
leofs_start
}
leofs_start()
{
local status=0
local s
for s in ${leofs_servers}; do
echo -n "Starting leofs ${s}... "
%%PREFIX%%/sbin/leofs ${s} start
if [ $? = 0 ]; then
echo "done."
else
status=1
fi
done
return $status
}
leofs_stop()
{
local status=0
for s in ${leofs_servers}; do
echo -n "Stopping leofs ${s}... "
%%PREFIX%%/sbin/leofs ${s} stop
if [ $? = 0 ]; then
echo "done."
else
status=1
fi
done
return $status
}
leofs_status()
{
local status=0
for s in ${leofs_servers}; do
%%PREFIX%%/sbin/leofs ${s} ping > /dev/null 2>&1
if [ $? != 0 ]; then
echo "leofs ${s} is not running."
status=1
else
echo "leofs ${s} is running."
fi
done
return $status
}
cmd=$1 ; shift
if [ $# -gt 0 ]; then
leofs_servers="$@"
fi
for s in ${leofs_servers}; do
case "${s}" in
ALL)
leofs_servers="manager manager_slave storage gateway"
break
;;
gateway|manager|manager_slave|storage)
;;
*)
warn "unknown leofs server: ${s}"
exit 1
;;
esac
done
for s in ${leofs_servers}; do
required_files=%%LEOFS_ETCDIR%%/leo_${s}.conf
done
run_rc_command "$cmd"
|