diff options
Diffstat (limited to 'modules.d/slx-network')
-rwxr-xr-x | modules.d/slx-network/hooks/s3-copy-network-files.sh | 53 | ||||
-rwxr-xr-x | modules.d/slx-network/hooks/s3-setup-bootif-network.sh | 14 |
2 files changed, 33 insertions, 34 deletions
diff --git a/modules.d/slx-network/hooks/s3-copy-network-files.sh b/modules.d/slx-network/hooks/s3-copy-network-files.sh index 5d28669e..46f4ab38 100755 --- a/modules.d/slx-network/hooks/s3-copy-network-files.sh +++ b/modules.d/slx-network/hooks/s3-copy-network-files.sh @@ -1,31 +1,30 @@ -#!/bin/bash +#!/bin/ash -type -p warn &> /dev/null || . /lib/dracut-lib.sh +# backup network configuration files found in stage4, copy ours +for file in "hostname" "hosts" "resolv.conf"; do + file="/etc/$file" + if ! [ -e "$file" ]; then + echo "Missing '$file' - can't move it to stage4. " + continue + fi + if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then + mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.renamed-by-stage3" + fi + cp -af -- "$file" "${NEWROOT}${file}" +done -if [ -n "$NEWROOT" ]; then - # backup network configuration files found in stage4 - for file in /etc/{hostname,hosts,resolv.conf}; do - if [ ! -e "$file" ]; then - warn "Missing '$file' - can't move it to stage4. " - continue - fi - if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then - mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.renamed-by-stage3" - fi - cp -af "$file" "${NEWROOT}/etc/" - done - # special handling for resolv.conf: - # move it to /opt/openslx to detect we are managing it - mkdir -p "${NEWROOT}/opt/openslx" - mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf" - ln -s "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf" +# special handling for resolv.conf: +# move it to /opt/openslx to detect we are managing it +mkdir -p "${NEWROOT}/opt/openslx" +mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf" +ln -nfs "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf" - # HACK: finally make sure we have rdns helper - # This should be done more elegantly one day... - rdns="$(type -p rdns)" - if [ -n "$rdns" ]; then - mkdir -p "${NEWROOT}/opt/openslx/bin" - cp -f "$rdns" "${NEWROOT}/opt/openslx/bin" - fi +# HACK: finally make sure we have rdns helper +# This should be done more elegantly one day... +rdns="$( command -p rdns )" +if [ -n "$rdns" ]; then + mkdir -p "${NEWROOT}/opt/openslx/bin" + cp -f "$rdns" "${NEWROOT}/opt/openslx/bin" fi -true + +exit 0 diff --git a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh index 6b75170d..1aeac9b6 100755 --- a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh +++ b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh @@ -70,7 +70,7 @@ wait_for_iface() { set -x if ! wait_for_iface "$SLX_PXE_NETIF" 30; then - warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway." + echo "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway." # TODO handle case where we waited for 30sec and it is still not up fi @@ -78,14 +78,14 @@ fi MAIN_NETIF="$SLX_PXE_NETIF" if [ -n "$SLX_VLAN_ID" ]; then # create VLAN interface - modprobe 8021q || warn "Loading '8021q' failed - missing module?" + modprobe 8021q || echo "Loading '8021q' failed - missing module?" ip link add link "$SLX_PXE_NETIF" name "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" \ type vlan id "$SLX_VLAN_ID" ip link set dev "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" up if wait_for_iface "${SLX_PXE_NETIF}.${SLX_VLAN_ID}"; then MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" else - warn "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..." + echo "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..." fi fi @@ -110,7 +110,7 @@ if [ -n "$SLX_BRIDGE" ]; then emergency_shell "Failed to setup main network bridge, giving up!" exit 1 fi - warn "Failed to setup main network bridge on try $try. Retrying ..." + echo "Failed to setup main network bridge on try $try. Retrying ..." # delete bridge, inc try and sleep 100ms before trying again if [ -e "/sys/class/net/${SLX_BRIDGE}" ]; then ip link set dev "$SLX_BRIDGE" down @@ -128,14 +128,14 @@ if [ -n "$SLX_PXE_CLIENT_IP" ] && [ -n "$SLX_PXE_NETMASK" ]; then # now if we got everything from the KCL and skip dhcp if so if [ -n "$SLX_PXE_GATEWAY" ] && [ -n "$SLX_PXE_DNS" ]; then - info "Got network configuration from KCL, skipping DHCP." + echo "Got network configuration from KCL, skipping DHCP." if ! interface="$MAIN_NETIF" \ ip="$SLX_PXE_CLIENT_IP" \ router="$SLX_PXE_GATEWAY" \ dns="$SLX_PXE_DNS" \ hostname="$SLX_PXE_HOSTNAME" \ /usr/local/bin/udhcpc-trigger bound; then - warn "Failed to launch DHCP trigger with KCL configuration - will DHCP." + echo "Failed to launch DHCP trigger with KCL configuration - will DHCP." fi exit 0 fi @@ -182,7 +182,7 @@ for i in 1 1 1 fail; do -s "/usr/local/bin/udhcpc-trigger" \ && break # failed, keep trying... - warn "DHCP failed, retrying in $i sec..." + echo "DHCP failed, retrying in $i sec..." sleep $i done |