]>
Commit | Line | Data |
---|---|---|
1c21ebf8 MT |
1 | #!/bin/sh |
2 | ######################################################################## | |
ffb37e51 | 3 | # Begin $rc_base/init.d/cloud-init |
1c21ebf8 MT |
4 | ######################################################################## |
5 | ||
6 | . /etc/sysconfig/rc | |
7 | . ${rc_functions} | |
8 | ||
1c21ebf8 MT |
9 | case "${1}" in |
10 | start) | |
b9021f92 MT |
11 | # Check if we are running in the cloud |
12 | if running_on_ec2; then | |
13 | scriptname="/etc/rc.d/helper/aws-setup" | |
14 | elif running_on_azure; then | |
15 | scriptname="/etc/rc.d/helper/azure-setup" | |
16 | else | |
17 | # This system is not running in the cloud | |
18 | exit 0 | |
19 | fi | |
1c21ebf8 MT |
20 | |
21 | # Find the first interface to use | |
81e1e80e MT |
22 | for i in /sys/class/net/red* /sys/class/net/eth* \ |
23 | /sys/class/net/*; do | |
1c21ebf8 MT |
24 | [ -d "${i}" ] || continue |
25 | i=$(basename ${i}) | |
26 | ||
27 | # Skip loopback | |
28 | [ "${i}" = "lo" ] && continue | |
29 | ||
30 | # Use whatever we have found | |
31 | intf="${i}" | |
32 | break | |
33 | done | |
34 | ||
35 | # Check if we found a network interface | |
36 | if [ ! -n "${intf}" ]; then | |
37 | echo_failure | |
38 | ||
39 | boot_mesg -n "Could not find a network interface" ${FAILURE} | |
40 | boot_mesg "" ${NORMAL} | |
41 | fi | |
42 | ||
bd3bcb45 | 43 | # Run a DHCP client and set up the system accordingly |
b9021f92 | 44 | dhclient -sf "${scriptname}" "${intf}" |
1c21ebf8 | 45 | |
bd3bcb45 | 46 | # End DHCP client immediately |
b9021f92 | 47 | dhclient -sf "${scriptname}" -r "${intf}" &>/dev/null |
ba062943 | 48 | |
c5465a94 MT |
49 | # Rename network devices |
50 | udevadm trigger --action="add" --subsystem-match="net" | |
51 | ||
ba062943 | 52 | exit 0 |
1c21ebf8 MT |
53 | ;; |
54 | ||
55 | status) | |
d035f60c | 56 | # Check Amazon |
1c21ebf8 MT |
57 | if running_on_ec2; then |
58 | echo "This system is running on AWS EC2" | |
59 | exit 0 | |
d035f60c MT |
60 | |
61 | # Check Microsoft | |
62 | elif running_on_azure; then | |
63 | echo "This system is running on Microsoft Azure" | |
64 | exit 0 | |
65 | ||
66 | # The rest | |
1c21ebf8 | 67 | else |
d035f60c | 68 | echo "This system is NOT running in the cloud" |
1c21ebf8 MT |
69 | exit 1 |
70 | fi | |
71 | ;; | |
72 | ||
73 | *) | |
74 | echo "Usage: ${0} {start|status}" | |
75 | exit 1 | |
76 | ;; | |
77 | esac | |
78 | ||
ffb37e51 | 79 | # End $rc_base/init.d/cloud-init |