From fce7129b62bb0cf801f465f486f61a97f60602db Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Tue, 15 Nov 2016 12:14:51 +0100 Subject: [PATCH] Avoid overwriting interfaces when installing on VPS (#59) * Avoid overwriting interfaces when installing on VPS * Also backup the old interfaces file before overwriting it * typo * ifdown && ifup * Update nextcloud-startup-script.sh --- nextcloud-startup-script.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 9c7227fd..d027746b 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -39,16 +39,27 @@ then exit 1 fi + +# Check network +echo "Testing if network is OK..." +sleep 2 +service networking restart + wget -q --spider http://github.com +if [ $? -eq 0 ] +then + echo -e "\e[32mOnline!\e[0m" +else echo "Setting correct interface..." # Set correct interface { sed '/# The primary network interface/q' /etc/network/interfaces; printf 'auto %s\niface %s inet dhcp\n# This is an autoconfigured IPv6 interface\niface %s inet6 auto\n' "$IFACE" "$IFACE" "$IFACE"; } > /etc/network/interfaces.new mv /etc/network/interfaces.new /etc/network/interfaces service networking restart +fi # Check network echo "Testing if network is OK..." sleep 2 -sudo ifdown $IFACE && sudo ifup $IFACE +service networking restart wget -q --spider http://github.com if [ $? -eq 0 ] then @@ -266,8 +277,11 @@ echo -e "\e[0m" echo -e "Write this down, you will need it to set static IP" echo -e "in your router later. It's included in this guide:" echo -e "https://www.techandme.se/open-port-80-443/ (step 1 - 5)" +echo -e "Please note that we will backup the interfaces file to:" +echo -e "/etc/network/interfaces.backup" echo -e "\e[32m" read -p "Press any key to set static IP..." -n1 -s +cp /etc/network/interfaces /etc/network/interfaces.backup clear echo -e "\e[0m" ifdown $IFACE