diff --git a/system_setup/configure.sh b/system_setup/configure.sh index abaf676..e51f426 100755 --- a/system_setup/configure.sh +++ b/system_setup/configure.sh @@ -52,7 +52,7 @@ do_configure() { echo "" source "$CONF_FILE" - VARS=("TLDOMAIN" "DOMAIN" "SERVERFQDN_IPA" "SERVERFQDN_NC" "CLIENTADMINGROUP" ) + VARS=("TLDOMAIN" "DOMAIN" "SERVERFQDN_IPA" "SERVERFQDN_NC" "CLIENTADMINGROUP" "IPAVAULTUSE" ) for ELE in "${VARS[@]}" do new_ELE=$(prompt_value "${ELE}" "${!ELE}") @@ -67,35 +67,41 @@ do_configure() { while true; do do_configure - # Load setup_system.inc.sh (which re-sources configure.conf and defines all functions). - # shellcheck disable=SC1090 - source "${SCRIPTDIR}/setup_system.inc.sh" - echo "" - echo "=== Testing: obtaining Nextcloud WebDAV token ===" - while true; do - # This makes the Token only available for this session, not written to disk - unset DAVTOKENFILENAME - #Sets a temporay Hostname for the Token - export HOSTNM="OEMDRV_TEST_TOKEN" - get_nc_token - current_user="$(id -un)" - if [[ "${DAVTOKEN_USER}" == "${current_user}" ]]; then - echo "Token obtained successfully for user '${DAVTOKEN_USER}'." - break - fi + echo "=== Testing: Nextcloud server ===" + NC_STATUS=$(curl -fsSL "https://${SERVERFQDN_NC}/status.php" 2>/dev/null) + if echo "$NC_STATUS" | grep -q '"installed":true'; then + NC_VERSION=$(echo "$NC_STATUS" | grep -oP '(?<="versionstring":")[^"]+') + echo "Nextcloud confirmed at ${SERVERFQDN_NC} (version ${NC_VERSION})." + else echo "" - if [[ -z "${DAVTOKEN_USER}" ]]; then - echo "Token could not be obtained (DAVTOKEN_USER is empty)." - else - echo "Token user '${DAVTOKEN_USER}' does not match current user '${current_user}'." - fi - read -rp "Retry get_nc_token (r) or quit (q)? [r/q]: " ans + echo "WARNING: '${SERVERFQDN_NC}' does not appear to be a valid Nextcloud server." + echo " Could not reach https://${SERVERFQDN_NC}/status.php or response was unexpected." + read -rp "Start configuration again (a) or quit (q)? [a/q]: " ans if [[ "${ans,,}" == "q" ]]; then echo "Quitting." exit 1 fi - done + continue + fi + + echo "" + echo "=== Testing: FreeIPA server ===" + IPA_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ + "https://${SERVERFQDN_IPA}/ipa/session/json" 2>/dev/null) + if [[ "$IPA_CODE" == "200" || "$IPA_CODE" == "401" ]]; then + echo "FreeIPA server confirmed at ${SERVERFQDN_IPA}." + else + echo "" + echo "WARNING: '${SERVERFQDN_IPA}' does not appear to be a valid FreeIPA server." + echo " https://${SERVERFQDN_IPA}/ipa/session/json returned: ${IPA_CODE:-no response}" + read -rp "Start configuration again (a) or quit (q)? [a/q]: " ans + if [[ "${ans,,}" == "q" ]]; then + echo "Quitting." + exit 1 + fi + continue + fi echo "" echo "=== Configuration complete ==="