~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to sysvinit/redhat/cloud-final

  • Committer: Scott Moser
  • Date: 2016-08-10 15:06:15 UTC
  • Revision ID: smoser@ubuntu.com-20160810150615-ma2fv107w3suy1ma
README: Mention move of revision control to git.

cloud-init development has moved its revision control to git.
It is available at 
  https://code.launchpad.net/cloud-init

Clone with 
  git clone https://git.launchpad.net/cloud-init
or
  git clone git+ssh://git.launchpad.net/cloud-init

For more information see
  https://git.launchpad.net/cloud-init/tree/HACKING.rst

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
#
4
 
#    Copyright (C) 2012 Yahoo! Inc.
5
 
#
6
 
#    Author: Joshua Harlow <harlowja@yahoo-inc.com>
7
 
#
8
 
#    This program is free software: you can redistribute it and/or modify
9
 
#    it under the terms of the GNU General Public License version 3, as
10
 
#    published by the Free Software Foundation.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
 
21
 
# See: http://wiki.debian.org/LSBInitScripts
22
 
# See: http://tiny.cc/czvbgw
23
 
# See: http://www.novell.com/coolsolutions/feature/15380.html
24
 
# Also based on dhcpd in RHEL (for comparison)
25
 
 
26
 
### BEGIN INIT INFO
27
 
# Provides:          cloud-final
28
 
# Required-Start:    $all cloud-config
29
 
# Should-Start:      $time
30
 
# Required-Stop:
31
 
# Should-Stop:
32
 
# Default-Start:     2 3 4 5
33
 
# Default-Stop:      0 1 6
34
 
# Short-Description: The final cloud-init job
35
 
# Description:       Start cloud-init and runs the final phase
36
 
#       and any associated final modules as desired.
37
 
### END INIT INFO
38
 
 
39
 
# Return values acc. to LSB for all commands but status:
40
 
# 0       - success
41
 
# 1       - generic or unspecified error
42
 
# 2       - invalid or excess argument(s)
43
 
# 3       - unimplemented feature (e.g. "reload")
44
 
# 4       - user had insufficient privileges
45
 
# 5       - program is not installed
46
 
# 6       - program is not configured
47
 
# 7       - program is not running
48
 
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
49
 
50
 
# Note that starting an already running service, stopping
51
 
# or restarting a not-running service as well as the restart
52
 
# with force-reload (in case signaling is not supported) are
53
 
# considered a success.
54
 
 
55
 
RETVAL=0
56
 
 
57
 
prog="cloud-init"
58
 
cloud_init="/usr/bin/cloud-init"
59
 
conf="/etc/cloud/cloud.cfg"
60
 
 
61
 
# If there exist sysconfig/default variable override files use it...
62
 
[ -f /etc/sysconfig/cloud-init ] && . /etc/sysconfig/cloud-init
63
 
[ -f /etc/default/cloud-init ] && . /etc/default/cloud-init
64
 
 
65
 
start() {
66
 
    [ -x $cloud_init ] || return 5
67
 
    [ -f $conf ] || return 6
68
 
 
69
 
    echo -n $"Starting $prog: "
70
 
    $cloud_init $CLOUDINITARGS modules --mode final
71
 
    RETVAL=$?
72
 
    return $RETVAL
73
 
}
74
 
 
75
 
stop() {
76
 
    echo -n $"Shutting down $prog: "
77
 
    # No-op
78
 
    RETVAL=7
79
 
    return $RETVAL
80
 
}
81
 
 
82
 
case "$1" in
83
 
    start)
84
 
        start
85
 
        RETVAL=$?
86
 
        ;;
87
 
    stop)
88
 
        stop
89
 
        RETVAL=$?
90
 
        ;;
91
 
    restart|try-restart|condrestart)
92
 
        ## Stop the service and regardless of whether it was
93
 
        ## running or not, start it again.
94
 
        # 
95
 
        ## Note: try-restart is now part of LSB (as of 1.9).
96
 
        ## RH has a similar command named condrestart.
97
 
        start
98
 
        RETVAL=$?
99
 
        ;;
100
 
    reload|force-reload)
101
 
        # It does not support reload
102
 
        RETVAL=3
103
 
        ;;
104
 
    status)
105
 
        echo -n $"Checking for service $prog:"
106
 
        # Return value is slightly different for the status command:
107
 
        # 0 - service up and running
108
 
        # 1 - service dead, but /var/run/  pid  file exists
109
 
        # 2 - service dead, but /var/lock/ lock file exists
110
 
        # 3 - service not running (unused)
111
 
        # 4 - service status unknown :-(
112
 
        # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
113
 
        RETVAL=3
114
 
        ;;
115
 
    *)
116
 
        echo "Usage: $0 {start|stop|status|try-restart|condrestart|restart|force-reload|reload}"
117
 
        RETVAL=3
118
 
        ;;
119
 
esac
120
 
 
121
 
exit $RETVAL