LibrePortal/scripts/update/git/check_git_details.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

82 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
gitCheckGitDetails()
{
# Source all config files to get current values
sourceScanFiles "libreportal_configs"
CFG_GIT_USER="${CFG_GIT_USER:-changeme}"
if [[ -z "$CFG_GIT_USER" ]] || [[ "$CFG_GIT_USER" == "changeme" ]]; then
echo ""
echo "Git Authentication Method:"
echo "1) Login required (username + token)"
echo "2) Authenticationless (public repos / SSH keys)"
echo ""
while true; do
read -p "Choose option [1-2]: " git_auth_choice
case "$git_auth_choice" in
1)
while true; do
echo "Enter Git username:"
read -r NEW_GIT_USER
if [[ -n "$NEW_GIT_USER" ]]; then
updateConfigOption "CFG_GIT_USER" "$NEW_GIT_USER"
echo "Updating Git Username"
break
else
echo "Username cannot be empty for login authentication."
fi
done
break
;;
2)
updateConfigOption "CFG_GIT_USER" "empty"
updateConfigOption "CFG_GIT_KEY" "empty"
echo "Using authenticationless Git access."
break
;;
*)
echo "Invalid option. Choose 1 or 2."
;;
esac
done
fi
# Only ask for token if user is not empty and token is missing
if [[ "$CFG_GIT_USER" != "empty" && "$CFG_GIT_USER" != "" ]]; then
CFG_GIT_KEY="${CFG_GIT_KEY:-changeme}"
if [[ -z "$CFG_GIT_KEY" ]] || [[ "$CFG_GIT_KEY" == "changeme" ]]; then
while true; do
echo "Please enter your Git access token:"
read -rs NEW_GIT_KEY
if [[ -n "$NEW_GIT_KEY" ]]; then
updateConfigOption "CFG_GIT_KEY" "$NEW_GIT_KEY"
echo "Updating Git Token"
break
else
echo "Git token cannot be empty for login authentication."
fi
done
fi
fi
CFG_GIT_URL="${CFG_GIT_URL:-changeme}"
if [[ -z "$CFG_GIT_URL" ]] || [[ "$CFG_GIT_URL" == "changeme" ]]; then
while true; do
echo "Please enter your Git repository URL:"
read -r NEW_GIT_URL
if [[ -n "$NEW_GIT_URL" ]]; then
# Validate and fix Git URL
NEW_GIT_URL=$(validateAndFixGitUrl "$NEW_GIT_URL")
updateConfigOption "CFG_GIT_URL" "$NEW_GIT_URL"
echo "Updating Git URL"
break
else
echo "Git URL cannot be empty"
fi
done
fi
# Reload updated config
sourceScanFiles "libreportal_configs"
}