diff --git a/templates/scripts/includes/check_installing_version.sh b/templates/scripts/includes/check_installing_version.sh new file mode 100755 index 0000000..da601fa --- /dev/null +++ b/templates/scripts/includes/check_installing_version.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e + +SIPWISE_REPO_HOST="deb.sipwise.com" +SIPWISE_REPO_TRANSPORT="https" + +CMD_LINE=$(cat /proc/cmdline) +stringInString() { + local to_test_="$1" # matching pattern + local source_="$2" # string to search in + case "${source_}" in *${to_test_}*) return 0;; esac + return 1 +} + +checkBootParam() { + stringInString " $1" "${CMD_LINE}" + return "$?" +} + +getBootParam() { + local param_to_search="$1" + local result='' + + stringInString " ${param_to_search}=" "${CMD_LINE}" || return 1 + result="${CMD_LINE##*$param_to_search=}" + result="${result%%[ ]*}" + echo "${result}" + return 0 +} + +if checkBootParam ngcppro ; then + if checkBootParam "sipwiserepotransport=" ; then + SIPWISE_REPO_TRANSPORT=$(getBootParam sipwiserepotransport) + fi + + if checkBootParam "sipwiserepo=" ; then + SIPWISE_REPO_HOST=$(getBootParam sipwiserepo) + fi + URL="${SIPWISE_REPO_TRANSPORT}://${SIPWISE_REPO_HOST}/sppro/" + accessible=$( curl -s -o /dev/null -w "%{http_code}" "${URL}" 2>/dev/null || true ) + err_message="You are installing Pro/Carrier version but ${SIPWISE_REPO_TRANSPORT}://${SIPWISE_REPO_HOST}/sppro/ repository not accessible. Please contact support@sipwise.com" + while [[ "${accessible}" != 200 ]]; do + if dialog --yes-label Retry --no-label Exit --yesno "${err_message}" 0 0 ; then + accessible=$( curl -s -o /dev/null -w "%{http_code}" "${URL}" 2>/dev/null || true ) + else + exit 1 + fi + done +fi diff --git a/templates/scripts/main.sh b/templates/scripts/main.sh index 5a5161a..5864211 100755 --- a/templates/scripts/main.sh +++ b/templates/scripts/main.sh @@ -155,9 +155,10 @@ deploy() { } install_sipwise_keyring +network_check +"${scripts_dir}/check_installing_version.sh" prompt_for_target check_for_existing_pvs -network_check report_ssh_password deploy