This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree".
The branch, next has been updated via 4e4c122c58349a9cf7e496b1e61ea3f55e070681 (commit) via ba06294341bffb06c2842128fa52978e79fe972c (commit) from 04441d8a3c582aaed2a34f65934dfb7bda28b7e2 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 4e4c122c58349a9cf7e496b1e61ea3f55e070681 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Jul 20 16:19:46 2018 +0100
aws: Add support for a script that can be executed at first boot
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit ba06294341bffb06c2842128fa52978e79fe972c Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jul 17 18:05:07 2018 +0100
aws: Always exit the init script cleanly
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
-----------------------------------------------------------------------
Summary of changes: src/initscripts/helper/aws-setup | 33 +++++++++++++++++++++------------ src/initscripts/system/aws | 10 ++++++++++ 2 files changed, 31 insertions(+), 12 deletions(-)
Difference in files: diff --git a/src/initscripts/helper/aws-setup b/src/initscripts/helper/aws-setup index d8c7a358c..e16678339 100644 --- a/src/initscripts/helper/aws-setup +++ b/src/initscripts/helper/aws-setup @@ -6,7 +6,7 @@ get() { local file="${1}"
- wget -qO - "http://169.254.169.254/latest/meta-data/$%7Bfile%7D" + wget -qO - "http://169.254.169.254/latest/$%7Bfile%7D" }
to_address() { @@ -64,7 +64,7 @@ find_interface() { }
import_aws_configuration() { - local instance_id="$(get instance-id)" + local instance_id="$(get meta-data/instance-id)"
boot_mesg "Importing AWS configuration for instance ${instance_id}..."
@@ -72,7 +72,7 @@ import_aws_configuration() { echo "${instance_id}" > /var/run/aws-instance-id
# Initialise system settings - local hostname=$(get local-hostname) + local hostname=$(get meta-data/local-hostname)
# Set hostname if ! grep -q "^HOSTNAME=" /var/ipfire/main/settings; then @@ -94,10 +94,10 @@ import_aws_configuration() {
# Import SSH keys for setup user local line - for line in $(get "public-keys/"); do + for line in $(get "meta-data/public-keys/"); do local key_no="${line%=*}"
- local key="$(get public-keys/${key_no}/openssh-key)" + local key="$(get meta-data/public-keys/${key_no}/openssh-key)" if [ -n "${key}" ] && ! grep -q "^${key}$" "/home/setup/.ssh/authorized_keys" 2>/dev/null; then mkdir -p "/home/setup/.ssh" chmod 700 "/home/setup/.ssh" @@ -109,6 +109,9 @@ import_aws_configuration() { fi done
+ # Download user-data + local user_data="$(get user-data)" + # Import any DNS server settings eval $(/usr/local/bin/readhash <(grep -E "^DNS([0-9])=" /var/ipfire/ethernet/settings 2>/dev/null))
@@ -119,24 +122,24 @@ import_aws_configuration() { : > /var/ipfire/ethernet/settings
local mac - for mac in $(get network/interfaces/macs/); do + for mac in $(get meta-data/network/interfaces/macs/); do # Remove trailing slash mac="${mac////}"
- local device_number="$(get "network/interfaces/macs/${mac}/device-number")" - local interface_id="$(get "network/interfaces/macs/${mac}/interface-id")" + local device_number="$(get "meta-data/network/interfaces/macs/${mac}/device-number")" + local interface_id="$(get "meta-data/network/interfaces/macs/${mac}/interface-id")"
# First IPv4 address - local ipv4_address="$(get "network/interfaces/macs/${mac}/local-ipv4s" | head -n1)" + local ipv4_address="$(get "meta-data/network/interfaces/macs/${mac}/local-ipv4s" | head -n1)" local ipv4_address_num="$(to_integer "${ipv4_address}")"
# Get VPC subnet - local vpc="$(get "network/interfaces/macs/${mac}/vpc-ipv4-cidr-block")" + local vpc="$(get "meta-data/network/interfaces/macs/${mac}/vpc-ipv4-cidr-block")" local vpc_netaddress="${vpc%/*}" local vpc_netaddress_num="$(to_integer "${vpc_netaddress}")"
# Get subnet size - local subnet="$(get "network/interfaces/macs/${mac}/subnet-ipv4-cidr-block")" + local subnet="$(get "meta-data/network/interfaces/macs/${mac}/subnet-ipv4-cidr-block")"
local prefix="${subnet#*/}" local netmask="$(prefix2netmask "${prefix}")" @@ -174,7 +177,7 @@ import_aws_configuration() { ) >> /var/ipfire/ethernet/settings
# Import aliases for RED - for alias in $(get "network/interfaces/macs/${mac}/local-ipv4s" | tail -n +2); do + for alias in $(get "meta-data/network/interfaces/macs/${mac}/local-ipv4s" | tail -n +2); do echo "${alias},on," done > /var/ipfire/ethernet/aliases ;; @@ -246,6 +249,12 @@ import_aws_configuration() {
# This script has now completed the first steps of setup touch /var/ipfire/main/firstsetup_ok + + # Save user-data script to be executed later + if [ "${user_data:0:2}" = "#!" ]; then + echo "${user_data}" > /tmp/aws-user-data.script + chmod 700 /tmp/aws-user-data.script + fi fi
# All done diff --git a/src/initscripts/system/aws b/src/initscripts/system/aws index f2a5c7cb7..896b3b17a 100644 --- a/src/initscripts/system/aws +++ b/src/initscripts/system/aws @@ -59,6 +59,16 @@ case "${1}" in
# End DHCP client immediately dhclient -sf /etc/rc.d/helper/aws-setup -r "${intf}" &>/dev/null + + # Run AWS user-data script + if [ -x "/tmp/aws-user-data.script" ]; then + /tmp/aws-user-data.script + + # Delete the script right away + rm /tmp/aws-user-data.script + fi + + exit 0 ;;
status)
hooks/post-receive -- IPFire 2.x development tree