forked from ripienaar/ec2-boot-init
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ec2-boot-init.init
95 lines (86 loc) · 1.68 KB
/
ec2-boot-init.init
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
#!/bin/sh
#
# ec2-boot-init Bootstrapper for EC2
#
# chkconfig: 345 60 76
#
# description: Bootstraps EC2 instances in a way that enables you to
# customise a standard image into different configurations
# via structured user data
#
### BEGIN INIT INFO
# Provides: ec2-boot-init
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
prog="/usr/sbin/ec2-boot-init"
# Lockfile
if [ -d /var/lock/subsys ]; then
# RedHat/CentOS/etc who use subsys
lock="/var/lock/subsys/ec2-boot-init"
else
# The rest of them
lock="/var/lock/ec2-boot-init"
fi
# Source function library.
. /lib/lsb/init-functions
# Check that binary exists
if ! [ -f $prog ]
then
echo "ec2-boot-init binary not found"
exit 0
fi
# See how we were called.
case "$1" in
start)
echo -n "Starting ec2-boot-init: "
cp /etc/ec2-boot-init/motd.unprovisioned /etc/motd
${prog}
if [ $? = 0 ]; then
log_success_msg
touch $lock
exit 0
else
log_failure_msg
exit 1
fi
;;
stop)
log_success_msg
rm -f $lock
;;
restart)
$0 stop
sleep 2
$0 start
;;
condrestart)
if [ -f $lock ]; then
$0 stop
# avoid race
sleep 2
$0 start
fi
;;
status)
if [ -f ${lock} ]; then
echo "ec2-boot-init ran"
exit 0
else
echo "ec2-boot-init: service not started"
exit 1
fi
;;
force-reload)
echo "not implemented"
;;
*)
echo "Usage: ec2-boot-init {start|stop|restart|condrestart|status}"
exit 1
;;
esac
exit 0