AWS: Import aws setup script

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2018-06-25 10:55:39 +01:00
parent 563c502163
commit bd3bcb45d6
7 changed files with 226 additions and 32 deletions

View File

@@ -6,8 +6,6 @@
. /etc/sysconfig/rc
. ${rc_functions}
MD_URL="http://169.254.169.254/latest/meta-data"
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
running_on_ec2() {
local uuid
@@ -33,9 +31,7 @@ running_on_ec2() {
case "${1}" in
start)
# Do nothing if we are not running on AWS EC2
running_on_ec2 || exit 0
boot_mesg "Setting up system to run on AWS EC2..."
#running_on_ec2 || exit 0
# Find the first interface to use
for i in /sys/class/net/*; do
@@ -58,30 +54,14 @@ case "${1}" in
boot_mesg "" ${NORMAL}
fi
# Assign ourselves an IP address to communicate with the meta-data service
ip addr add 169.254.169.1/24 dev "${intf}"
ip link set "${intf}" up
# Run a DHCP client and set up the system accordingly
dhclient -sf /etc/rc.d/helper/aws-setup "${intf}"
# Initialise system settings
if [ ! -s "/var/ipfire/main/settings" ]; then
hostname=$(curl ${MD_URL}/local-hostname)
# End DHCP client immediately
dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}"
(
echo "HOSTNAME=${hostname%%.*}"
echo "DOMAINNAME=${hostname#*.}"
echo "THEME=ipfire"
echo "LANGUAGE=en"
echo "KEYMAP=/lib/kbd/keymaps/i386/qwerty/us.map.gz"
echo "TIMEZONE=/usr/share/zoneinfo/posix/UTC"
) > /var/ipfire/main/settings
fi
# Remove any IP addresses
ip addr flush dev "${intf}"
echo_ok
# This script has now completed the first steps of setup
touch /var/ipfire/main/firstsetup_ok
# Trigger udev again to rename interfaces
udevadm trigger && udevadm settle
;;
status)