Merge ~rjschwei/cloud-init:sysvinitSUSE into cloud-init:master

Proposed by Robert Schweikert
Status: Merged
Merged at revision: 243ec59fb62a8710430f9ba1e2490ee964c1abc0
Proposed branch: ~rjschwei/cloud-init:sysvinitSUSE
Merge into: cloud-init:master
Diff against target: 497 lines (+455/-0)
5 files modified
setup.py (+2/-0)
sysvinit/suse/cloud-config (+113/-0)
sysvinit/suse/cloud-final (+113/-0)
sysvinit/suse/cloud-init (+114/-0)
sysvinit/suse/cloud-init-local (+113/-0)
Reviewer Review Type Date Requested Status
Scott Moser Needs Fixing
Review via email: mp+331142@code.launchpad.net

Description of the change

Integrate sys-v-init support for SUSE LP#1718649

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

this looks fine, but i'd like to drop the extended GPL header content either entirely (the systemd and upstart units do not have any license info) or at least replace it with the simple:

  # This file is part of cloud-init. See LICENSE file for license information.

if you want i'm willing to keep Author and Copyright in place:

  # Copyright (C) 2012 Yahoo! Inc.
  # Copyright (C) 2013 SUSE LLC
  #
  # Author: Joshua Harlow <email address hidden>
  # Author: Robert Schweikert <email address hidden>
  #
  # This file is part of cloud-init. See LICENSE file for license information.

But I'd prefer the first option.

review: Needs Fixing
Revision history for this message
Robert Schweikert (rjschwei) wrote :

OK, fixed with cd6cc9b

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/setup.py b/setup.py
2index 9199317..bf697d7 100755
3--- a/setup.py
4+++ b/setup.py
5@@ -121,6 +121,7 @@ INITSYS_FILES = {
6 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)],
7 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)],
8 'sysvinit_openrc': [f for f in glob('sysvinit/gentoo/*') if is_f(f)],
9+ 'sysvinit_suse': [f for f in glob('sysvinit/suse/*') if is_f(f)],
10 'systemd': [render_tmpl(f)
11 for f in (glob('systemd/*.tmpl') +
12 glob('systemd/*.service') +
13@@ -133,6 +134,7 @@ INITSYS_ROOTS = {
14 'sysvinit_freebsd': 'usr/local/etc/rc.d',
15 'sysvinit_deb': 'etc/init.d',
16 'sysvinit_openrc': 'etc/init.d',
17+ 'sysvinit_suse': 'etc/init.d',
18 'systemd': pkg_config_read('systemd', 'systemdsystemunitdir'),
19 'systemd.generators': pkg_config_read('systemd',
20 'systemdsystemgeneratordir'),
21diff --git a/sysvinit/suse/cloud-config b/sysvinit/suse/cloud-config
22new file mode 100644
23index 0000000..8c3abbb
24--- /dev/null
25+++ b/sysvinit/suse/cloud-config
26@@ -0,0 +1,113 @@
27+#!/bin/sh
28+
29+#
30+# Copyright (C) 2017 SUSE LLC
31+#
32+# This file is part of cloud-init. See LICENSE file for license information.
33+
34+# See: http://wiki.debian.org/LSBInitScripts
35+# See: http://tiny.cc/czvbgw
36+# See: http://www.novell.com/coolsolutions/feature/15380.html
37+# Also based on dhcpd in RHEL (for comparison)
38+
39+### BEGIN INIT INFO
40+# Provides: cloud-config
41+# Required-Start: cloud-init cloud-init-local
42+# Should-Start: $time
43+# Required-Stop: $null
44+# Should-Stop: $null
45+# Default-Start: 2 3 5
46+# Default-Stop: 0 1 6
47+# Short-Description: The config cloud-init job
48+# Description: Start cloud-init and runs the config phase
49+# and any associated config modules as desired.
50+### END INIT INFO
51+
52+# Return values acc. to LSB for all commands but status:
53+# 0 - success
54+# 1 - generic or unspecified error
55+# 2 - invalid or excess argument(s)
56+# 3 - unimplemented feature (e.g. "reload")
57+# 4 - user had insufficient privileges
58+# 5 - program is not installed
59+# 6 - program is not configured
60+# 7 - program is not running
61+# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
62+#
63+# Note that starting an already running service, stopping
64+# or restarting a not-running service as well as the restart
65+# with force-reload (in case signaling is not supported) are
66+# considered a success.
67+
68+RETVAL=0
69+
70+prog="cloud-init"
71+cloud_init="/usr/bin/cloud-init"
72+conf="/etc/cloud/cloud.cfg"
73+
74+# If there exist sysconfig/default variable override files use it...
75+[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
76+[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
77+
78+. /etc/rc.status
79+rc_reset
80+
81+start() {
82+ [ -x $cloud_init ] || return 5
83+ [ -f $conf ] || return 6
84+
85+ echo -n $"Starting $prog: "
86+ $cloud_init $CLOUDINITARGS modules --mode config
87+ RETVAL=$?
88+ return $RETVAL
89+}
90+
91+stop() {
92+ echo -n $"Shutting down $prog: "
93+ # No-op
94+ RETVAL=7
95+ return $RETVAL
96+}
97+
98+case "$1" in
99+ start)
100+ start
101+ RETVAL=$?
102+ ;;
103+ stop)
104+ stop
105+ RETVAL=$?
106+ ;;
107+ restart|try-restart|condrestart)
108+ ## Stop the service and regardless of whether it was
109+ ## running or not, start it again.
110+ #
111+ ## Note: try-restart is now part of LSB (as of 1.9).
112+ ## RH has a similar command named condrestart.
113+ start
114+ RETVAL=$?
115+ ;;
116+ reload|force-reload)
117+ # It does not support reload
118+ RETVAL=3
119+ ;;
120+ status)
121+ echo -n $"Checking for service $prog:"
122+ # Return value is slightly different for the status command:
123+ # 0 - service up and running
124+ # 1 - service dead, but /var/run/ pid file exists
125+ # 2 - service dead, but /var/lock/ lock file exists
126+ # 3 - service not running (unused)
127+ # 4 - service status unknown :-(
128+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
129+ RETVAL=3
130+ ;;
131+ *)
132+ echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
133+ RETVAL=3
134+ ;;
135+esac
136+
137+_rc_status=$RETVAL
138+rc_status -v
139+rc_exit
140diff --git a/sysvinit/suse/cloud-final b/sysvinit/suse/cloud-final
141new file mode 100644
142index 0000000..714a066
143--- /dev/null
144+++ b/sysvinit/suse/cloud-final
145@@ -0,0 +1,113 @@
146+#!/bin/sh
147+
148+#
149+# Copyright (C) 2017 SUSE LLC
150+#
151+# This file is part of cloud-init. See LICENSE file for license information.
152+
153+# See: http://wiki.debian.org/LSBInitScripts
154+# See: http://tiny.cc/czvbgw
155+# See: http://www.novell.com/coolsolutions/feature/15380.html
156+# Also based on dhcpd in RHEL (for comparison)
157+
158+### BEGIN INIT INFO
159+# Provides: cloud-final
160+# Required-Start: cloud-config
161+# Should-Start: $time
162+# Required-Stop: $null
163+# Should-Stop: $null
164+# Default-Start: 2 3 5
165+# Default-Stop: 0 1 6
166+# Short-Description: The final cloud-init job
167+# Description: Start cloud-init and runs the final phase
168+# and any associated final modules as desired.
169+### END INIT INFO
170+
171+# Return values acc. to LSB for all commands but status:
172+# 0 - success
173+# 1 - generic or unspecified error
174+# 2 - invalid or excess argument(s)
175+# 3 - unimplemented feature (e.g. "reload")
176+# 4 - user had insufficient privileges
177+# 5 - program is not installed
178+# 6 - program is not configured
179+# 7 - program is not running
180+# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
181+#
182+# Note that starting an already running service, stopping
183+# or restarting a not-running service as well as the restart
184+# with force-reload (in case signaling is not supported) are
185+# considered a success.
186+
187+RETVAL=0
188+
189+prog="cloud-init"
190+cloud_init="/usr/bin/cloud-init"
191+conf="/etc/cloud/cloud.cfg"
192+
193+# If there exist sysconfig/default variable override files use it...
194+[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
195+[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
196+
197+. /etc/rc.status
198+rc_reset
199+
200+start() {
201+ [ -x $cloud_init ] || return 5
202+ [ -f $conf ] || return 6
203+
204+ echo -n $"Starting $prog: "
205+ $cloud_init $CLOUDINITARGS modules --mode final
206+ RETVAL=$?
207+ return $RETVAL
208+}
209+
210+stop() {
211+ echo -n $"Shutting down $prog: "
212+ # No-op
213+ RETVAL=7
214+ return $RETVAL
215+}
216+
217+case "$1" in
218+ start)
219+ start
220+ RETVAL=$?
221+ ;;
222+ stop)
223+ stop
224+ RETVAL=$?
225+ ;;
226+ restart|try-restart|condrestart)
227+ ## Stop the service and regardless of whether it was
228+ ## running or not, start it again.
229+ #
230+ ## Note: try-restart is now part of LSB (as of 1.9).
231+ ## RH has a similar command named condrestart.
232+ start
233+ RETVAL=$?
234+ ;;
235+ reload|force-reload)
236+ # It does not support reload
237+ RETVAL=3
238+ ;;
239+ status)
240+ echo -n $"Checking for service $prog:"
241+ # Return value is slightly different for the status command:
242+ # 0 - service up and running
243+ # 1 - service dead, but /var/run/ pid file exists
244+ # 2 - service dead, but /var/lock/ lock file exists
245+ # 3 - service not running (unused)
246+ # 4 - service status unknown :-(
247+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
248+ RETVAL=3
249+ ;;
250+ *)
251+ echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
252+ RETVAL=3
253+ ;;
254+esac
255+
256+_rc_status=$RETVAL
257+rc_status -v
258+rc_exit
259diff --git a/sysvinit/suse/cloud-init b/sysvinit/suse/cloud-init
260new file mode 100644
261index 0000000..7126753
262--- /dev/null
263+++ b/sysvinit/suse/cloud-init
264@@ -0,0 +1,114 @@
265+#!/bin/sh
266+
267+#
268+# Copyright (C) 2017 SUSE LLC
269+#
270+# This file is part of cloud-init. See LICENSE file for license information.
271+
272+# See: http://wiki.debian.org/LSBInitScripts
273+# See: http://tiny.cc/czvbgw
274+# See: http://www.novell.com/coolsolutions/feature/15380.html
275+# Also based on dhcpd in RHEL (for comparison)
276+
277+### BEGIN INIT INFO
278+# Provides: cloud-init
279+# Required-Start: $local_fs $network $named $remote_fs cloud-init-local
280+# Should-Start: $time
281+# Required-Stop: $null
282+# Should-Stop: $null
283+# Default-Start: 2 3 5
284+# Default-Stop: 0 1 6
285+# Short-Description: The initial cloud-init job (net and fs contingent)
286+# Description: Start cloud-init and runs the initialization phase
287+# and any associated initial modules as desired.
288+### END INIT INFO
289+
290+# Return values acc. to LSB for all commands but status:
291+# 0 - success
292+# 1 - generic or unspecified error
293+# 2 - invalid or excess argument(s)
294+# 3 - unimplemented feature (e.g. "reload")
295+# 4 - user had insufficient privileges
296+# 5 - program is not installed
297+# 6 - program is not configured
298+# 7 - program is not running
299+# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
300+#
301+# Note that starting an already running service, stopping
302+# or restarting a not-running service as well as the restart
303+# with force-reload (in case signaling is not supported) are
304+# considered a success.
305+
306+RETVAL=0
307+
308+prog="cloud-init"
309+cloud_init="/usr/bin/cloud-init"
310+conf="/etc/cloud/cloud.cfg"
311+
312+# If there exist sysconfig/default variable override files use it...
313+[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
314+[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
315+
316+. /etc/rc.status
317+rc_reset
318+
319+start() {
320+ [ -x $cloud_init ] || return 5
321+ [ -f $conf ] || return 6
322+
323+ echo -n $"Starting $prog: "
324+ $cloud_init $CLOUDINITARGS init
325+ RETVAL=$?
326+ return $RETVAL
327+}
328+
329+stop() {
330+ echo -n $"Shutting down $prog: "
331+ # No-op
332+ RETVAL=7
333+ return $RETVAL
334+}
335+
336+case "$1" in
337+ start)
338+ start
339+ RETVAL=$?
340+ ;;
341+ stop)
342+ stop
343+ RETVAL=$?
344+ ;;
345+ restart|try-restart|condrestart)
346+ ## Stop the service and regardless of whether it was
347+ ## running or not, start it again.
348+ #
349+ ## Note: try-restart is now part of LSB (as of 1.9).
350+ ## RH has a similar command named condrestart.
351+ start
352+ RETVAL=$?
353+ ;;
354+ reload|force-reload)
355+ # It does not support reload
356+ RETVAL=3
357+ ;;
358+ status)
359+ echo -n $"Checking for service $prog:"
360+ RETVAL=3
361+ [ -e /root/.ssh/authorized_keys ] && RETVAL=0
362+ # Return value is slightly different for the status command:
363+ # 0 - service up and running
364+ # 1 - service dead, but /var/run/ pid file exists
365+ # 2 - service dead, but /var/lock/ lock file exists
366+ # 3 - service not running (unused)
367+ # 4 - service status unknown :-(
368+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
369+ ;;
370+ *)
371+ echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
372+ RETVAL=3
373+ ;;
374+esac
375+
376+_rc_status=$RETVAL
377+rc_status -v
378+rc_exit
379diff --git a/sysvinit/suse/cloud-init-local b/sysvinit/suse/cloud-init-local
380new file mode 100644
381index 0000000..fd3980e
382--- /dev/null
383+++ b/sysvinit/suse/cloud-init-local
384@@ -0,0 +1,113 @@
385+#!/bin/sh
386+
387+#
388+# Copyright (C) 2017 SUSE LLC
389+#
390+# This file is part of cloud-init. See LICENSE file for license information.
391+
392+# See: http://wiki.debian.org/LSBInitScripts
393+# See: http://tiny.cc/czvbgw
394+# See: http://www.novell.com/coolsolutions/feature/15380.html
395+# Also based on dhcpd in RHEL (for comparison)
396+
397+### BEGIN INIT INFO
398+# Provides: cloud-init-local
399+# Required-Start: $local_fs $remote_fs
400+# Should-Start: $time
401+# Required-Stop: $null
402+# Should-Stop: $null
403+# Default-Start: 2 3 5
404+# Default-Stop: 0 1 6
405+# Short-Description: The initial cloud-init job (local fs contingent)
406+# Description: Start cloud-init and runs the initialization phases
407+# and any associated initial modules as desired.
408+### END INIT INFO
409+
410+# Return values acc. to LSB for all commands but status:
411+# 0 - success
412+# 1 - generic or unspecified error
413+# 2 - invalid or excess argument(s)
414+# 3 - unimplemented feature (e.g. "reload")
415+# 4 - user had insufficient privileges
416+# 5 - program is not installed
417+# 6 - program is not configured
418+# 7 - program is not running
419+# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
420+#
421+# Note that starting an already running service, stopping
422+# or restarting a not-running service as well as the restart
423+# with force-reload (in case signaling is not supported) are
424+# considered a success.
425+
426+RETVAL=0
427+
428+prog="cloud-init"
429+cloud_init="/usr/bin/cloud-init"
430+conf="/etc/cloud/cloud.cfg"
431+
432+# If there exist sysconfig/default variable override files use it...
433+[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
434+[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
435+
436+. /etc/rc.status
437+rc_reset
438+
439+start() {
440+ [ -x $cloud_init ] || return 5
441+ [ -f $conf ] || return 6
442+
443+ echo -n $"Starting $prog: "
444+ $cloud_init $CLOUDINITARGS init --local
445+ RETVAL=$?
446+ return $RETVAL
447+}
448+
449+stop() {
450+ echo -n $"Shutting down $prog: "
451+ # No-op
452+ RETVAL=7
453+ return $RETVAL
454+}
455+
456+case "$1" in
457+ start)
458+ start
459+ RETVAL=$?
460+ ;;
461+ stop)
462+ stop
463+ RETVAL=$?
464+ ;;
465+ restart|try-restart|condrestart)
466+ ## Stop the service and regardless of whether it was
467+ ## running or not, start it again.
468+ #
469+ ## Note: try-restart is now part of LSB (as of 1.9).
470+ ## RH has a similar command named condrestart.
471+ start
472+ RETVAL=$?
473+ ;;
474+ reload|force-reload)
475+ # It does not support reload
476+ RETVAL=3
477+ ;;
478+ status)
479+ echo -n $"Checking for service $prog:"
480+ # Return value is slightly different for the status command:
481+ # 0 - service up and running
482+ # 1 - service dead, but /var/run/ pid file exists
483+ # 2 - service dead, but /var/lock/ lock file exists
484+ # 3 - service not running (unused)
485+ # 4 - service status unknown :-(
486+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
487+ RETVAL=3
488+ ;;
489+ *)
490+ echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
491+ RETVAL=3
492+ ;;
493+esac
494+
495+_rc_status=$RETVAL
496+rc_status -v
497+rc_exit

Subscribers

People subscribed via source and target branches