Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-block/tgt/files/
Date: Sun, 27 Nov 2016 23:53:16
Message-Id: 1480290767.1a3287d53e9912ab1033b64fcafdc1c341fd21ef.vapier@gentoo
1 commit: 1a3287d53e9912ab1033b64fcafdc1c341fd21ef
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 27 23:52:47 2016 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 27 23:52:47 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a3287d5
7
8 sys-block/tgt: fix bashisms in init.d script
9
10 Also drop old unused init.d scripts.
11
12 sys-block/tgt/files/tgtd | 125 ---------------------------------
13 sys-block/tgt/files/tgtd-1.0.24.confd | 4 --
14 sys-block/tgt/files/tgtd-1.0.24.initd | 126 ----------------------------------
15 sys-block/tgt/files/tgtd.initd | 12 ++--
16 4 files changed, 6 insertions(+), 261 deletions(-)
17
18 diff --git a/sys-block/tgt/files/tgtd b/sys-block/tgt/files/tgtd
19 deleted file mode 100644
20 index 0d9d0709..00000000
21 --- a/sys-block/tgt/files/tgtd
22 +++ /dev/null
23 @@ -1,125 +0,0 @@
24 -#!/sbin/openrc-run
25 -# Copyright 1999-2011 Gentoo Foundation
26 -# Distributed under the terms of the GNU General Public License v2
27 -# $Id$
28 -
29 -TGTD_CONFIG=/etc/tgt/targets.conf
30 -
31 -TASK=$1
32 -
33 -depend() {
34 - need net
35 -}
36 -
37 -start() {
38 - ebegin "Starting target framework daemon"
39 - ebegin "Starting ${SVCNAME}"
40 - # Start tgtd first.
41 - start-stop-daemon --start --quiet \
42 - --name tgtd \
43 - --exec /usr/sbin/tgtd
44 - RETVAL=$?
45 - if [ "$RETVAL" -ne 0 ] ; then
46 - echo "Could not start tgtd (is tgtd already running?)"
47 - exit 1
48 - fi
49 - # We need to wait for 1 second before do anything with tgtd
50 - sleep 1
51 - # Put tgtd into "offline" state until all the targets are configured.
52 - # We don't want initiators to (re)connect and fail the connection
53 - # if it's not ready
54 - tgtadm --op update --mode sys --name State -v offline
55 - # Configure the targets.
56 - tgt-admin --update ALL -c $TGTD_CONFIG
57 - # Put tgtd into "ready" state.
58 - tgtadm --op update --mode sys --name State -v ready
59 - eend $?
60 -}
61 -
62 -stop() {
63 - ebegin "Stopping ${SVCNAME}"
64 - ebegin "Stopping target framework daemon"
65 - # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet
66 - if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
67 - forcedstop
68 - fi
69 - # Remove all targets. It only removes targets which are not in use.
70 - tgt-admin --update ALL -c /dev/null &>/dev/null
71 - # tgtd will exit if all targets were removed
72 - tgtadm --op delete --mode system &>/dev/null
73 - RETVAL=$?
74 - if [ "$RETVAL" -eq 107 ] ; then
75 - echo "tgtd is not running"
76 - if [ "$TASK" != "restart" ] ; then
77 - exit 1
78 - fi
79 - elif [ "$RETVAL" -ne 0 ] ; then
80 - echo "Some initiators are still connected - could not stop tgtd"
81 - exit 2
82 - fi
83 - # echo -n
84 - eend $?
85 -}
86 -
87 -forcedstop() {
88 - # NOTE: Forced shutdown of the iscsi target may cause data corruption
89 - # for initiators that are connected.
90 - echo "Force-stopping target framework daemon"
91 - # Offline everything first. May be needed if we're rebooting, but
92 - # expect the initiators to reconnect cleanly when we boot again
93 - # (i.e. we don't want them to reconnect to a tgtd which is still
94 - # working, but the target is gone).
95 - tgtadm --op update --mode sys --name State -v offline &>/dev/null
96 - RETVAL=$?
97 - if [ "$RETVAL" -eq 107 ] ; then
98 - echo "tgtd is not running"
99 - if [ "$TASK" != "restart" ] ; then
100 - exit 1
101 - fi
102 - else
103 - tgt-admin --offline ALL
104 - # Remove all targets, even if they are still in use.
105 - tgt-admin --update ALL -c /dev/null -f
106 - # It will shut down tgtd only after all targets were removed.
107 - tgtadm --op delete --mode system
108 - RETVAL=$?
109 - if [ "$RETVAL" -ne 0 ] ; then
110 - echo "Failed to shutdown tgtd"
111 - exit 1
112 - fi
113 - fi
114 - echo -n
115 -}
116 -
117 -reload() {
118 - echo "Updating target framework daemon configuration"
119 - # Update configuration for targets. Only targets which
120 - # are not in use will be updated.
121 - tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
122 - RETVAL=$?
123 - if [ "$RETVAL" -eq 107 ] ; then
124 - echo "tgtd is not running"
125 - exit 1
126 - fi
127 -}
128 -
129 -forcedreload() {
130 - echo "Force-updating target framework daemon configuration"
131 - # Update configuration for targets, even those in use.
132 - tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
133 - RETVAL=$?
134 - if [ "$RETVAL" -eq 107 ] ; then
135 - echo "tgtd is not running"
136 - exit 1
137 - fi
138 -}
139 -
140 -status() {
141 - # Don't name this script "tgtd"...
142 - TGTD_PROC=$(ps -C tgtd | grep -c tgtd)
143 - if [ "$TGTD_PROC" -eq 2 ] ; then
144 - echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info."
145 - else
146 - echo "tgtd is NOT running."
147 - fi
148 -}
149
150 diff --git a/sys-block/tgt/files/tgtd-1.0.24.confd b/sys-block/tgt/files/tgtd-1.0.24.confd
151 deleted file mode 100644
152 index fd4c098..00000000
153 --- a/sys-block/tgt/files/tgtd-1.0.24.confd
154 +++ /dev/null
155 @@ -1,4 +0,0 @@
156 -# Here you can specify options that are passed directly to tgt daemon
157 -TGTD_OPTS=""
158 -
159 -# vim: ft=gentoo-conf-d
160
161 diff --git a/sys-block/tgt/files/tgtd-1.0.24.initd b/sys-block/tgt/files/tgtd-1.0.24.initd
162 deleted file mode 100644
163 index c824c09..00000000
164 --- a/sys-block/tgt/files/tgtd-1.0.24.initd
165 +++ /dev/null
166 @@ -1,126 +0,0 @@
167 -#!/sbin/openrc-run
168 -# Copyright 1999-2012 Gentoo Foundation
169 -# Distributed under the terms of the GNU General Public License v2
170 -# $Id$
171 -
172 -TGTD_CONFIG=/etc/tgt/targets.conf
173 -
174 -TASK=$1
175 -
176 -depend() {
177 - need net
178 -}
179 -
180 -start() {
181 - ebegin "Starting target framework daemon"
182 - ebegin "Starting ${SVCNAME}"
183 - # Start tgtd first.
184 - start-stop-daemon --start --quiet \
185 - --name tgtd \
186 - --exec /usr/sbin/tgtd -- \
187 - ${TGTD_OPTS}
188 - RETVAL=$?
189 - if [ "$RETVAL" -ne 0 ] ; then
190 - echo "Could not start tgtd (is tgtd already running?)"
191 - exit 1
192 - fi
193 - # We need to wait for 1 second before do anything with tgtd
194 - sleep 1
195 - # Put tgtd into "offline" state until all the targets are configured.
196 - # We don't want initiators to (re)connect and fail the connection
197 - # if it's not ready
198 - tgtadm --op update --mode sys --name State -v offline
199 - # Configure the targets.
200 - tgt-admin --update ALL -c $TGTD_CONFIG
201 - # Put tgtd into "ready" state.
202 - tgtadm --op update --mode sys --name State -v ready
203 - eend $?
204 -}
205 -
206 -stop() {
207 - ebegin "Stopping ${SVCNAME}"
208 - ebegin "Stopping target framework daemon"
209 - # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet
210 - if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
211 - forcedstop
212 - fi
213 - # Remove all targets. It only removes targets which are not in use.
214 - tgt-admin --update ALL -c /dev/null &>/dev/null
215 - # tgtd will exit if all targets were removed
216 - tgtadm --op delete --mode system &>/dev/null
217 - RETVAL=$?
218 - if [ "$RETVAL" -eq 107 ] ; then
219 - echo "tgtd is not running"
220 - if [ "$TASK" != "restart" ] ; then
221 - exit 1
222 - fi
223 - elif [ "$RETVAL" -ne 0 ] ; then
224 - echo "Some initiators are still connected - could not stop tgtd"
225 - exit 2
226 - fi
227 - # echo -n
228 - eend $?
229 -}
230 -
231 -forcedstop() {
232 - # NOTE: Forced shutdown of the iscsi target may cause data corruption
233 - # for initiators that are connected.
234 - echo "Force-stopping target framework daemon"
235 - # Offline everything first. May be needed if we're rebooting, but
236 - # expect the initiators to reconnect cleanly when we boot again
237 - # (i.e. we don't want them to reconnect to a tgtd which is still
238 - # working, but the target is gone).
239 - tgtadm --op update --mode sys --name State -v offline &>/dev/null
240 - RETVAL=$?
241 - if [ "$RETVAL" -eq 107 ] ; then
242 - echo "tgtd is not running"
243 - if [ "$TASK" != "restart" ] ; then
244 - exit 1
245 - fi
246 - else
247 - tgt-admin --offline ALL
248 - # Remove all targets, even if they are still in use.
249 - tgt-admin --update ALL -c /dev/null -f
250 - # It will shut down tgtd only after all targets were removed.
251 - tgtadm --op delete --mode system
252 - RETVAL=$?
253 - if [ "$RETVAL" -ne 0 ] ; then
254 - echo "Failed to shutdown tgtd"
255 - exit 1
256 - fi
257 - fi
258 - echo -n
259 -}
260 -
261 -reload() {
262 - echo "Updating target framework daemon configuration"
263 - # Update configuration for targets. Only targets which
264 - # are not in use will be updated.
265 - tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
266 - RETVAL=$?
267 - if [ "$RETVAL" -eq 107 ] ; then
268 - echo "tgtd is not running"
269 - exit 1
270 - fi
271 -}
272 -
273 -forcedreload() {
274 - echo "Force-updating target framework daemon configuration"
275 - # Update configuration for targets, even those in use.
276 - tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
277 - RETVAL=$?
278 - if [ "$RETVAL" -eq 107 ] ; then
279 - echo "tgtd is not running"
280 - exit 1
281 - fi
282 -}
283 -
284 -status() {
285 - # Don't name this script "tgtd"...
286 - TGTD_PROC=$(ps -C tgtd | grep -c tgtd)
287 - if [ "$TGTD_PROC" -eq 2 ] ; then
288 - echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info."
289 - else
290 - echo "tgtd is NOT running."
291 - fi
292 -}
293
294 diff --git a/sys-block/tgt/files/tgtd.initd b/sys-block/tgt/files/tgtd.initd
295 index bf20870..a1934d4 100644
296 --- a/sys-block/tgt/files/tgtd.initd
297 +++ b/sys-block/tgt/files/tgtd.initd
298 @@ -41,13 +41,13 @@ stop() {
299 ebegin "Stopping ${SVCNAME}"
300 ebegin "Stopping target framework daemon"
301 # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet
302 - if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
303 + if [ "$RUNLEVEL" = 0 -o "$RUNLEVEL" = 6 ] ; then
304 forcedstop
305 fi
306 # Remove all targets. It only removes targets which are not in use.
307 - tgt-admin --update ALL -c /dev/null &>/dev/null
308 + tgt-admin --update ALL -c /dev/null >/dev/null 2>&1
309 # tgtd will exit if all targets were removed
310 - tgtadm --op delete --mode system &>/dev/null
311 + tgtadm --op delete --mode system >/dev/null 2>&1
312 RETVAL=$?
313 if [ "$RETVAL" -eq 107 ] ; then
314 echo "tgtd is not running"
315 @@ -70,7 +70,7 @@ forcedstop() {
316 # expect the initiators to reconnect cleanly when we boot again
317 # (i.e. we don't want them to reconnect to a tgtd which is still
318 # working, but the target is gone).
319 - tgtadm --op update --mode sys --name State -v offline &>/dev/null
320 + tgtadm --op update --mode sys --name State -v offline >/dev/null 2>&1
321 RETVAL=$?
322 if [ "$RETVAL" -eq 107 ] ; then
323 echo "tgtd is not running"
324 @@ -96,7 +96,7 @@ reload() {
325 echo "Updating target framework daemon configuration"
326 # Update configuration for targets. Only targets which
327 # are not in use will be updated.
328 - tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
329 + tgt-admin --update ALL -c $TGTD_CONFIG >/dev/null 2>&1
330 RETVAL=$?
331 if [ "$RETVAL" -eq 107 ] ; then
332 echo "tgtd is not running"
333 @@ -107,7 +107,7 @@ reload() {
334 forcedreload() {
335 echo "Force-updating target framework daemon configuration"
336 # Update configuration for targets, even those in use.
337 - tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
338 + tgt-admin --update ALL -f -c $TGTD_CONFIG >/dev/null 2>&1
339 RETVAL=$?
340 if [ "$RETVAL" -eq 107 ] ; then
341 echo "tgtd is not running"