blob: 24db3845baae30a73703735cb7f0b6109d450d9e (
plain)
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
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: ec2-init
# Required-Start: $network $local_fs
# Required-Stop:
# Should-Start: $named
# Should-Stop:
# Default-Start: S
# Default-Stop: 1
# Short-Description: Initialises system for use on Amazon EC2
# Description: Fetches login credentials and handles various quirks
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=ec2-init
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Fetching EC2 login credentials"
if ec2-fetch-credentials 2> /dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
log_daemon_msg "Running EC2 user data"
if [ -f /var/ec2/.already_ran ]
then
echo "Already ran";
else
if ec2-run-user-data 2> /dev/null
then
log_end_msg 0
touch /var/ec2/.already_ran
else
log_end_msg 1
fi
fi
if pgrep nash-hotplug > /dev/null
then
log_daemon_msg "Killing nash-hotplug"
if pkill nash-hotplug;
then
log_end_msg 0
else
log_end_msg 1
fi
fi
log_daemon_msg "Setting hostname to EC2 public_hostname"
if ec2-set-hostname 2> /dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
exit 0
;;
restart|force-reload)
exec $0 start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
|