Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: init.d/
Date: Wed, 09 Jul 2014 20:39:25
Message-Id: 1404583950.c1de8c09bf4895c6108d297fcebd63046e49e614.williamh@OpenRC
1 commit: c1de8c09bf4895c6108d297fcebd63046e49e614
2 Author: Thomas D <whissi <AT> whissi <DOT> de>
3 AuthorDate: Tue Jun 10 13:23:17 2014 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Sat Jul 5 18:12:30 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c1de8c09
7
8 Add support for verbose "local" service runscript
9
10 With this patch, the "local" service runscript will be verbose like the
11 "sysctl" service when 'rc_verbose="yes"' is set.
12
13 Example output successful start:
14
15 * Stopping local ...
16 * Executing "/etc/local.d/00will-stop.stop" ... [ ok ]
17 * Starting local ...
18 * Executing "/etc/local.d/00will-start.start" ... [ ok ]
19 * Executing "/etc/local.d/01 test.start" ... [ ok ]
20
21 Example output with failing executables:
22
23 * Stopping local ...
24 * Executing "/etc/local.d/00will-stop.stop" ... [ ok ]
25 * Executing "/etc/local.d/will-fail.stop" ...
26 mount: can't find foo in /etc/fstab
27 * Execution of "/etc/local.d/will-fail.stop" failed. [ !! ]
28 * Starting local ...
29 * Executing "/etc/local.d/00will-start.start" ... [ ok ]
30 * Executing "/etc/local.d/01 test.start" ... [ ok ]
31 * Executing "/etc/local.d/will-fail2.start" ...
32 mount: can't find bar in /etc/fstab
33 * Execution of "/etc/local.d/will-fail2.start" failed. [ !! ]
34 * Executing "/etc/local.d/will-fail.start" ...
35 mount: can't find foo in /etc/fstab
36 * Execution of "/etc/local.d/will-fail.start" failed. [ !! ]
37
38 X-Gentoo-Bug: 489274
39 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=489274
40
41 ---
42 init.d/local.in | 73 +++++++++++++++++++++++++++++++++++++++++++++------------
43 1 file changed, 58 insertions(+), 15 deletions(-)
44
45 diff --git a/init.d/local.in b/init.d/local.in
46 index 2f20568..06be25f 100644
47 --- a/init.d/local.in
48 +++ b/init.d/local.in
49 @@ -12,40 +12,83 @@ depend()
50
51 start()
52 {
53 - einfo "Starting local"
54 + ebegin "Starting local"
55
56 - local file
57 - for file in @SYSCONFDIR@/local.d/*.start ; do
58 - [ -x "$file" ] && "$file"
59 + local file has_errors retval
60 + eindent
61 + for file in @SYSCONFDIR@/local.d/*.start; do
62 + if [ -x "${file}" ]; then
63 + has_executables=1
64 + vebegin "Executing \"${file}\""
65 + "${file}" 2>&1 >/dev/null
66 + retval=$?
67 + if [ ${retval} -ne 0 ]; then
68 + has_errors=1
69 + ewend ${retval} "Execution of \"${file}\" failed."
70 + else
71 + vewend 0
72 + fi
73 + fi
74 done
75 + eoutdent
76
77 if command -v local_start >/dev/null 2>&1; then
78 - ewarn "@SYSCONFDIR@/conf.d/local should be removed."
79 + ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
80 ewarn "Please move the code from the local_start function"
81 - ewarn "to scripts with an .start extension"
82 - ewarn "in @SYSCONFDIR@/local.d"
83 + ewarn "to executable scripts with an .start extension"
84 + ewarn "in \"@SYSCONFDIR@/local.d\""
85 local_start
86 fi
87
88 - eend 0
89 + if [ -z "${has_errors}" ]; then
90 + eend 0
91 + fi
92 +
93 + # We have to end with a zero exit code, because a failed execution
94 + # of an executable @SYSCONFDIR@/local.d/*.start file shouldn't result in
95 + # marking the local service as failed. Otherwise we are unable to
96 + # execute any executable @SYSCONFDIR@/local.d/*.stop file, because a failed
97 + # marked service cannot be stopped (and the stop function would
98 + # actually call the executable @SYSCONFDIR@/local.d/*.stop file(s)).
99 + return 0
100 }
101
102 stop()
103 {
104 - einfo "Stopping local"
105 + ebegin "Stopping local"
106
107 - local file
108 + local file has_errors retval
109 + eindent
110 for file in @SYSCONFDIR@/local.d/*.stop; do
111 - [ -x "$file" ] && "$file"
112 + if [ -x "${file}" ]; then
113 + has_executables=1
114 + vebegin "Executing \"${file}\""
115 + "${file}" 2>&1 >/dev/null
116 + retval=$?
117 + if [ ${retval} -ne 0 ]; then
118 + has_errors=1
119 + ewend ${retval} "Execution of \"${file}\" failed."
120 + else
121 + vewend 0
122 + fi
123 + fi
124 done
125 + eoutdent
126
127 if command -v local_stop >/dev/null 2>&1; then
128 - ewarn "@SYSCONFDIR@/conf.d/local should be removed."
129 + ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
130 ewarn "Please move the code from the local_stop function"
131 - ewarn "to scripts with an .stop extension"
132 - ewarn "in @SYSCONFDIR@/local.d"
133 + ewarn "to executable scripts with an .stop extension"
134 + ewarn "in \"@SYSCONFDIR@/local.d\""
135 local_stop
136 fi
137
138 - eend 0
139 + if [ -z "${has_errors}" ]; then
140 + eend 0
141 + fi
142 +
143 + # An executable @SYSCONFDIR@/local.d/*.stop file which failed with a
144 + # non-zero exit status is not a reason to mark this service
145 + # as failed, therefore we have to end with a zero exit code.
146 + return 0
147 }