Revert "Add credential checks for known Gitea instances https://go-gitea.mywire.org and http://192.168.88.97:3000"
This reverts commit 2519fee6d5.
This commit is contained in:
@@ -15,13 +15,6 @@ NC='\033[0m' # No Color
|
|||||||
|
|
||||||
# Configuration file path
|
# Configuration file path
|
||||||
CONFIG_FILE="$(dirname "$0")/config.json"
|
CONFIG_FILE="$(dirname "$0")/config.json"
|
||||||
|
|
||||||
# Known Gitea URLs to check credentials for
|
|
||||||
KNOWN_GITEA_URLS=("https://go-gitea.mywire.org" "http://192.168.88.97:3000")
|
|
||||||
|
|
||||||
# Mode flags
|
|
||||||
CHECKS_MODE=false
|
|
||||||
|
|
||||||
# Function to print colored output
|
# Function to print colored output
|
||||||
print_status() {
|
print_status() {
|
||||||
echo -e "${BLUE}[INFO]${NC} $1"
|
echo -e "${BLUE}[INFO]${NC} $1"
|
||||||
@@ -74,118 +67,6 @@ install_tea_cli() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to show detailed credential status for known Gitea instances
|
|
||||||
show_gitea_credential_status() {
|
|
||||||
print_status "Checking credential status for known Gitea instances..."
|
|
||||||
|
|
||||||
for url in "${KNOWN_GITEA_URLS[@]}"; do
|
|
||||||
local domain=$(echo "$url" | sed 's|https://||' | sed 's|http://||')
|
|
||||||
echo
|
|
||||||
echo "Gitea Instance: $url"
|
|
||||||
echo "Domain: $domain"
|
|
||||||
echo "Credential Config Key: credential.https://$domain.helper"
|
|
||||||
|
|
||||||
local helper=$(git config --global credential."https://$domain".helper 2>/dev/null)
|
|
||||||
if [[ -n "$helper" ]]; then
|
|
||||||
echo "Configured Helper: $helper"
|
|
||||||
# Check if the helper command exists
|
|
||||||
case "$helper" in
|
|
||||||
"manager")
|
|
||||||
if command_exists git-credential-manager; then
|
|
||||||
echo "Helper Status: Available (Git Credential Manager)"
|
|
||||||
else
|
|
||||||
echo "Helper Status: Configured but not installed"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"osxkeychain")
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
echo "Helper Status: Available (macOS Keychain)"
|
|
||||||
else
|
|
||||||
echo "Helper Status: Not applicable on this OS"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"/usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring")
|
|
||||||
if command_exists gnome-keyring-daemon; then
|
|
||||||
echo "Helper Status: Available (GNOME Keyring)"
|
|
||||||
else
|
|
||||||
echo "Helper Status: Configured but GNOME Keyring not available"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if command_exists "$helper"; then
|
|
||||||
echo "Helper Status: Available (Custom: $helper)"
|
|
||||||
else
|
|
||||||
echo "Helper Status: Configured but command not found: $helper"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
print_success "Credentials configured for $url"
|
|
||||||
else
|
|
||||||
echo "Configured Helper: None"
|
|
||||||
echo "Helper Status: Not configured"
|
|
||||||
print_warning "No credentials configured for $url"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to check and setup credentials for known Gitea instances
|
|
||||||
check_and_setup_known_gitea_credentials() {
|
|
||||||
print_status "Checking credentials for known Gitea instances..."
|
|
||||||
|
|
||||||
local credential_helper=""
|
|
||||||
|
|
||||||
# Check for Git Credential Manager (GCM)
|
|
||||||
if command_exists git-credential-manager; then
|
|
||||||
credential_helper="manager"
|
|
||||||
print_success "Found Git Credential Manager"
|
|
||||||
# Check for platform-specific helpers
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]] && git config --global --get credential.helper 2>/dev/null | grep -q "osxkeychain"; then
|
|
||||||
credential_helper="osxkeychain"
|
|
||||||
print_success "Found macOS Keychain credential helper"
|
|
||||||
elif [[ "$OSTYPE" == "linux-gnu"* ]] && command_exists gnome-keyring-daemon; then
|
|
||||||
credential_helper="/usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring"
|
|
||||||
print_success "Found GNOME Keyring"
|
|
||||||
# Fallback to generic manager
|
|
||||||
elif git config --global --get credential.helper >/dev/null 2>&1; then
|
|
||||||
credential_helper=$(git config --global --get credential.helper)
|
|
||||||
print_success "Using existing credential helper: $credential_helper"
|
|
||||||
else
|
|
||||||
print_warning "No credential manager found"
|
|
||||||
|
|
||||||
# Offer to install Git Credential Manager
|
|
||||||
echo
|
|
||||||
read -p "Would you like to install Git Credential Manager for secure credential storage? (y/N): " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
if install_credential_manager; then
|
|
||||||
credential_helper="manager"
|
|
||||||
print_success "Git Credential Manager installed successfully"
|
|
||||||
else
|
|
||||||
print_warning "Failed to install Git Credential Manager"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
print_warning "Skipping credential setup for known instances"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
for url in "${KNOWN_GITEA_URLS[@]}"; do
|
|
||||||
local domain=$(echo "$url" | sed 's|https://||' | sed 's|http://||')
|
|
||||||
if git config --global credential."https://$domain".helper >/dev/null 2>&1; then
|
|
||||||
print_success "Credentials already configured for $url"
|
|
||||||
else
|
|
||||||
print_status "Configuring credentials for $url"
|
|
||||||
local cmd="git config --global credential.\"https://$domain\".helper \"$credential_helper\""
|
|
||||||
echo "Running: $cmd"
|
|
||||||
eval "$cmd"
|
|
||||||
print_success "Credentials configured for $url"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to detect and configure credential manager
|
# Function to detect and configure credential manager
|
||||||
setup_credential_manager() {
|
setup_credential_manager() {
|
||||||
print_status "Checking for Git credential managers..."
|
print_status "Checking for Git credential managers..."
|
||||||
@@ -526,23 +407,6 @@ prompt_with_default() {
|
|||||||
eval "$var_name='$input'"
|
eval "$var_name='$input'"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to parse command line arguments
|
|
||||||
parse_args() {
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--checks)
|
|
||||||
CHECKS_MODE=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_error "Unknown option: $1"
|
|
||||||
echo "Usage: $0 [--checks]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main script
|
# Main script
|
||||||
main() {
|
main() {
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
@@ -550,24 +414,12 @@ main() {
|
|||||||
echo "========================================"
|
echo "========================================"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Parse command line arguments
|
|
||||||
parse_args "$@"
|
|
||||||
|
|
||||||
# Check if git is installed
|
# Check if git is installed
|
||||||
if ! command_exists git; then
|
if ! command_exists git; then
|
||||||
print_error "Git is not installed. Please install Git first."
|
print_error "Git is not installed. Please install Git first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If checks mode, show status and exit
|
|
||||||
if [[ "$CHECKS_MODE" == "true" ]]; then
|
|
||||||
show_gitea_credential_status
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check and setup credentials for known Gitea instances
|
|
||||||
check_and_setup_known_gitea_credentials
|
|
||||||
|
|
||||||
# Load configuration if available
|
# Load configuration if available
|
||||||
CONFIG_LOADED=false
|
CONFIG_LOADED=false
|
||||||
if load_config; then
|
if load_config; then
|
||||||
|
|||||||
Reference in New Issue
Block a user