From ecc83443bc688feb9fd9aef0aa44e50038a7ee2c Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Wed, 8 Feb 2017 21:03:15 +0100 Subject: [PATCH] Create ip2.sh (#125) * Create ip2.sh * remove bloat --- nextcloud-startup-script.sh | 36 +++----------------------------- static/ip2.sh | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 static/ip2.sh diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index ba44bbba..2dc3a8f1 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -456,39 +456,9 @@ then if [ "$IFACE" = "" ] then echo "IFACE is an emtpy value. Trying to set IFACE with another method..." - IFCONFIG="/sbin/ifconfig" - INTERFACES="/etc/network/interfaces" - IFACE=$(ip -o link show | awk '{print $2,$9}' | grep 'UP' | cut -d ':' -f 1) - ADDRESS=$(hostname -I | cut -d ' ' -f 1) - NETMASK=$($IFCONFIG | grep -w inet |grep -v 127.0.0.1| awk '{print $4}' | cut -d ":" -f 2) - GATEWAY=$(route -n|grep "UG"|grep -v "UGH"|cut -f 10 -d " ") - - cat <<-IPCONFIG > "$INTERFACES" - source /etc/network/interfaces.d/* - - # The loopback network interface - auto lo $IFACE - iface lo inet loopback - - # The primary network interface - iface $IFACE inet static - pre-up /sbin/ethtool -K $IFACE tso off - pre-up /sbin/ethtool -K $IFACE gso off - # Fixes https://github.com/nextcloud/vm/issues/92: - pre-up ip link set dev $IFACE mtu 1430 - - # Best practice is to change the static address - # to something outside your DHCP range. - address $ADDRESS - netmask $NETMASK - gateway $GATEWAY - - # This is an autoconfigured IPv6 interface - # iface $IFACE inet6 auto - - # Exit and save: [CTRL+X] + [Y] + [ENTER] - # Exit without saving: [CTRL+X] -IPCONFIG + wget -q $STATIC/ip2.sh -P $SCRIPTS + bash $SCRIPTS/ip2.sh + rm $SCRIPTS/ip2.sh fi ifdown $IFACE sleep 1 diff --git a/static/ip2.sh b/static/ip2.sh new file mode 100644 index 00000000..3ebf8a2e --- /dev/null +++ b/static/ip2.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# This file is only used if IFACE fail in the startup-script + +IFCONFIG="/sbin/ifconfig" +INTERFACES="/etc/network/interfaces" + +IFACE=$(ip -o link show | awk '{print $2,$9}' | grep 'UP' | cut -d ':' -f 1) +ADDRESS=$(hostname -I | cut -d ' ' -f 1) +NETMASK=$($IFCONFIG | grep -w inet |grep -v 127.0.0.1| awk '{print $4}' | cut -d ":" -f 2) +GATEWAY=$(route -n|grep "UG"|grep -v "UGH"|cut -f 10 -d " ") + +cat <<-IPCONFIG > "$INTERFACES" +source /etc/network/interfaces.d/* + +# The loopback network interface +auto lo $IFACE +iface lo inet loopback + +# The primary network interface +iface $IFACE inet static +pre-up /sbin/ethtool -K $IFACE tso off +pre-up /sbin/ethtool -K $IFACE gso off +# Fixes https://github.com/nextcloud/vm/issues/92: +pre-up ip link set dev $IFACE mtu 1430 + +# Best practice is to change the static address +# to something outside your DHCP range. +address $ADDRESS +netmask $NETMASK +gateway $GATEWAY + +# This is an autoconfigured IPv6 interface +# iface $IFACE inet6 auto + +# Exit and save: [CTRL+X] + [Y] + [ENTER] +# Exit without saving: [CTRL+X] + +IPCONFIG + +exit 0