]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/aws
2 ########################################################################
3 # Begin $rc_base/init.d/aws
4 ########################################################################
9 MD_URL
="http://169.254.169.254/latest/meta-data"
11 # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
15 # Check if the hypervisor UUID starts with ec2
16 if [ -r "/sys/hypervisor/uuid" ]; then
17 uuid
=$
(</sys
/hypervisor
/uuid
)
19 [ "${uuid:0:3}" = "ec2" ] && return 0
22 # Check if the DMI product UUID starts with EC2
23 if [ -r "/sys/devices/virtual/dmi/id/product_uuid" ]; then
24 uuid
=$
(</sys
/devices
/virtual
/dmi
/id
/product_uuid
)
26 [ "${uuid:0:3}" = "EC2" ] && return 0
29 # We are not running on AWS EC2
35 # Do nothing if we are not running on AWS EC2
36 running_on_ec2 ||
exit 0
38 boot_mesg
"Setting up system to run on AWS EC2..."
40 # Find the first interface to use
41 for i
in /sys
/class
/net
/*; do
42 [ -d "${i}" ] ||
continue
46 [ "${i}" = "lo" ] && continue
48 # Use whatever we have found
53 # Check if we found a network interface
54 if [ ! -n "${intf}" ]; then
57 boot_mesg
-n "Could not find a network interface" ${FAILURE}
58 boot_mesg
"" ${NORMAL}
61 # Assign ourselves an IP address to communicate with the meta-data service
62 ip addr add
169.254.169.1/24 dev
"${intf}"
63 ip link
set "${intf}" up
65 # Initialise system settings
66 if [ ! -s "/var/ipfire/main/settings" ]; then
67 hostname
=$
(curl
${MD_URL}/local-hostname
)
70 echo "HOSTNAME=${hostname%%.*}"
71 echo "DOMAINNAME=${hostname#*.}"
74 echo "KEYMAP=/lib/kbd/keymaps/i386/qwerty/us.map.gz"
75 echo "TIMEZONE=/usr/share/zoneinfo/posix/UTC"
76 ) > /var
/ipfire
/main
/settings
79 # Remove any IP addresses
80 ip addr flush dev
"${intf}"
83 # This script has now completed the first steps of setup
84 touch /var
/ipfire
/main
/firstsetup_ok
88 if running_on_ec2
; then
89 echo "This system is running on AWS EC2"
92 echo "This system is NOT running on AWS EC2"
98 echo "Usage: ${0} {start|status}"
103 # End $rc_base/init.d/aws