Replace token test in configure.sh with server reachability checks

Instead of obtaining a Nextcloud WebDAV token, verify the configured
servers directly:
- Nextcloud: check /status.php for "installed":true and show version
- FreeIPA: check /ipa/session/json for HTTP 200 or 401

Both checks offer restart or quit on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 19:03:33 +02:00
parent 9cb2977527
commit d363a806c0
+30 -24
View File
@@ -52,7 +52,7 @@ do_configure() {
echo "" echo ""
source "$CONF_FILE" source "$CONF_FILE"
VARS=("TLDOMAIN" "DOMAIN" "SERVERFQDN_IPA" "SERVERFQDN_NC" "CLIENTADMINGROUP" ) VARS=("TLDOMAIN" "DOMAIN" "SERVERFQDN_IPA" "SERVERFQDN_NC" "CLIENTADMINGROUP" "IPAVAULTUSE" )
for ELE in "${VARS[@]}" for ELE in "${VARS[@]}"
do do
new_ELE=$(prompt_value "${ELE}" "${!ELE}") new_ELE=$(prompt_value "${ELE}" "${!ELE}")
@@ -67,35 +67,41 @@ do_configure() {
while true; do while true; do
do_configure 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 ""
echo "=== Testing: obtaining Nextcloud WebDAV token ===" echo "=== Testing: Nextcloud server ==="
while true; do NC_STATUS=$(curl -fsSL "https://${SERVERFQDN_NC}/status.php" 2>/dev/null)
# This makes the Token only available for this session, not written to disk if echo "$NC_STATUS" | grep -q '"installed":true'; then
unset DAVTOKENFILENAME NC_VERSION=$(echo "$NC_STATUS" | grep -oP '(?<="versionstring":")[^"]+')
#Sets a temporay Hostname for the Token echo "Nextcloud confirmed at ${SERVERFQDN_NC} (version ${NC_VERSION})."
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 ""
if [[ -z "${DAVTOKEN_USER}" ]]; then
echo "Token could not be obtained (DAVTOKEN_USER is empty)."
else else
echo "Token user '${DAVTOKEN_USER}' does not match current user '${current_user}'." echo ""
fi echo "WARNING: '${SERVERFQDN_NC}' does not appear to be a valid Nextcloud server."
read -rp "Retry get_nc_token (r) or quit (q)? [r/q]: " ans 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 if [[ "${ans,,}" == "q" ]]; then
echo "Quitting." echo "Quitting."
exit 1 exit 1
fi 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 ""
echo "=== Configuration complete ===" echo "=== Configuration complete ==="