From fc30bf19866ed1e460c8a6ed71cc5f2cf460332f Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Mon, 2 Sep 2019 14:21:06 +0200 Subject: [PATCH] add all the variables here in case the user doesn't have internet (#926) --- nextcloud-startup-script.sh | 1 + nextcloud_install_production.sh | 6 ++---- static/static_ip.sh | 27 ++++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 010cba5f..0ff38e9c 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -607,6 +607,7 @@ do "Static IP") clear run_static_script static_ip + rm -f $SCRIPTS/lib.sh ;; "Automatic updates") diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 317d30a6..e4fc480f 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -678,10 +678,8 @@ done 9< results rm -f results # Get needed scripts for first bootup -if [ ! -f "$SCRIPTS"/nextcloud-startup-script.sh ] -then - check_command curl_to_dir "$GITHUB_REPO" nextcloud-startup-script.sh "$SCRIPTS" -fi +check_command curl_to_dir "$GITHUB_REPO" nextcloud-startup-script.sh "$SCRIPTS" +check_command curl_to_dir "$GITHUB_REPO" lib.sh "$SCRIPTS" download_static_script instruction download_static_script history diff --git a/static/static_ip.sh b/static/static_ip.sh index add4e983..c9c0bff2 100644 --- a/static/static_ip.sh +++ b/static/static_ip.sh @@ -2,11 +2,34 @@ # T&M Hansson IT AB © - 2019, https://www.hanssonit.se/ +IRed='\e[0;91m' # Red +ICyan='\e[0;96m' # Cyan +Color_Off='\e[0m' # Text Reset +print_text_in_color() { + printf "%b%s%b\n" "$1" "$2" "$Color_Off" +} + +# Use local lib file in case there is no internet connection +if [ -f /var/scripts/lib.sh ] +then +# shellcheck disable=2034,2059 +true +# shellcheck source=lib.sh +FIRST_IFACE=1 source /var/scripts/lib.sh +unset FIRST_IFACE + # If we have internet, then use the latest variables from the lib remote file +elif print_text_in_color "$ICyan" "Testing internet connection..." && ping github.com -c 2 +then # shellcheck disable=2034,2059 true # shellcheck source=lib.sh FIRST_IFACE=1 . <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) unset FIRST_IFACE +else + print_text_in_color "$IRed" "You don't seem to have a working internet connection, and /var/scripts/lib.sh is missing so you can't run this script." + print_text_in_color "$ICyan" "Please report this to https://github.com/nextcloud/vm/issues/" + exit 1 +fi # Check for errors + debug code and abort if something isn't right # 1 = ON @@ -20,8 +43,6 @@ root_check # Check Ubuntu version check_distro_version -clear - # Copy old interfaces files msg_box "Copying old netplan.io config files file to: @@ -71,7 +92,7 @@ do cat << ENTERGATEWAY +-------------------------------------------------------+ | Please enter the gateway address you want to set, | -| Your current gateway is: $GATEWAY | +| Your current gateway is: $GATEWAY | +-------------------------------------------------------+ ENTERGATEWAY echo