Create ip2.sh (#125)

* Create ip2.sh

* remove bloat
This commit is contained in:
Daniel Hansson 2017-02-08 21:03:15 +01:00 committed by GitHub
parent a1cf0952bc
commit ecc83443bc
2 changed files with 44 additions and 33 deletions

View File

@ -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

41
static/ip2.sh Normal file
View File

@ -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