Compare commits
17 Commits
e9373ba1e1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97f224746c | ||
|
|
c727d8e1f2 | ||
|
|
85fec83f2c | ||
|
|
1c682a338c | ||
|
|
62cb59e645 | ||
|
|
b60850ef14 | ||
|
|
e7e64f6838 | ||
|
|
4f27a626a6 | ||
|
|
e2a3cf4c5d | ||
|
|
811f1b800c | ||
|
|
979977d16e | ||
|
|
fbaebfaae2 | ||
|
|
e48dec460b | ||
|
|
6c4892e961 | ||
|
|
445d8050a6 | ||
|
|
2519fee6d5 | ||
|
|
a71fa38da0 |
44
AGENTS.md
Normal file
44
AGENTS.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Agent Instructions for GitHub Binary Installers
|
||||
|
||||
## When to Use the Installer Creation Guide
|
||||
|
||||
When a user requests the creation of an installer script for a binary hosted on GitHub releases, follow these steps:
|
||||
|
||||
1. **Check Existing Installers**: First, verify if an installer for the requested tool already exists in the repository by checking the project files.
|
||||
|
||||
2. **Use the Guide**: If no installer exists, use the `INSTALLER_CREATION_GUIDE.md` as the primary reference for creating the new installer.
|
||||
|
||||
3. **Follow the Template**: Strictly adhere to the structure, functions, and patterns outlined in the guide. Do not deviate from the established conventions.
|
||||
|
||||
4. **Adapt Placeholders**: Replace all placeholders (`[tool]`, `[Tool Name]`, `[TOOL]`, `[owner]/[repo]`) with the actual values for the requested binary.
|
||||
|
||||
5. **Verify GitHub Releases**: Ensure the binary naming convention and download URLs match the actual GitHub release assets.
|
||||
|
||||
6. **Test the Script**: After creation, the script should be tested to ensure it works correctly on the target systems.
|
||||
|
||||
7. **Update Documentation**: Add appropriate usage examples and next steps specific to the tool being installed.
|
||||
|
||||
## Key Requirements
|
||||
|
||||
- **System-Wide Preference**: Always prefer system-wide installation (`/usr/local/bin`) over user-specific installation.
|
||||
- **Binary-Only**: Disable package manager installation to ensure the latest version from GitHub is used.
|
||||
- **Version Management**: Implement proper version symlinks for multiple version support.
|
||||
- **Conflict Resolution**: Detect and offer to remove conflicting user bin installations.
|
||||
- **Command-Line Options**: Support `--version`, `--force`, and `--reinstall` options.
|
||||
- **Error Handling**: Include comprehensive error checking and user-friendly messages.
|
||||
|
||||
## File Naming Convention
|
||||
|
||||
Name the installer script as `install-[tool-name].sh` (e.g., `install-my-tool.sh`).
|
||||
|
||||
## Integration
|
||||
|
||||
After creating the installer:
|
||||
1. Add it to the repository
|
||||
2. Update any relevant README files to reference the new installer
|
||||
3. Ensure the script is executable (`chmod +x install-[tool-name].sh`)
|
||||
|
||||
## Reference
|
||||
|
||||
See `INSTALLER_CREATION_GUIDE.md` for complete implementation details and code templates.</content>
|
||||
<parameter name="filePath">AGENTS.md
|
||||
621
INSTALLER_CREATION_GUIDE.md
Normal file
621
INSTALLER_CREATION_GUIDE.md
Normal file
@@ -0,0 +1,621 @@
|
||||
# GitHub Binary Installer Template
|
||||
|
||||
This document provides instructions for creating a new installer script for binaries hosted on GitHub releases, following the patterns established in the git-credential-manager, borg-cli, and tea-cli installers.
|
||||
|
||||
## Overview
|
||||
|
||||
The installer should:
|
||||
- Prefer system-wide installation (/usr/local/bin) for all users
|
||||
- Fall back to user-specific installation ($HOME/bin) if no sudo access
|
||||
- Handle version management with symlinks
|
||||
- Warn about and offer to remove conflicting user bin installations
|
||||
- Support command-line options for version specification and reinstallation
|
||||
- Always use GitHub releases for the latest binaries (avoid package managers)
|
||||
|
||||
## Script Structure
|
||||
|
||||
### 1. Header and Configuration
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# [Tool Name] Installer
|
||||
# Downloads and installs the latest [Tool Name] binary
|
||||
# Supports multiple platforms and installation methods
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
GITHUB_REPO="[owner]/[repo]" # e.g., "git-ecosystem/git-credential-manager"
|
||||
USER_BIN_DIR="$HOME/bin"
|
||||
SYSTEM_INSTALL_DIR="/usr/local/bin"
|
||||
TEMP_DIR="/tmp/[tool]-install"
|
||||
```
|
||||
|
||||
### 2. Core Utility Functions
|
||||
|
||||
```bash
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
```
|
||||
|
||||
### 3. System Detection Functions
|
||||
|
||||
```bash
|
||||
# Function to detect OS and package manager
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS="$ID"
|
||||
OS_VERSION="$VERSION_ID"
|
||||
else
|
||||
print_error "Cannot detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect package manager
|
||||
if command_exists apt; then
|
||||
PKG_MANAGER="apt"
|
||||
elif command_exists yum; then
|
||||
PKG_MANAGER="yum"
|
||||
elif command_exists dnf; then
|
||||
PKG_MANAGER="dnf"
|
||||
elif command_exists pacman; then
|
||||
PKG_MANAGER="pacman"
|
||||
elif command_exists zypper; then
|
||||
PKG_MANAGER="zypper"
|
||||
else
|
||||
PKG_MANAGER="unknown"
|
||||
fi
|
||||
|
||||
print_status "Detected OS: $OS $OS_VERSION"
|
||||
print_status "Package manager: $PKG_MANAGER"
|
||||
}
|
||||
|
||||
# Function to get system architecture
|
||||
get_arch() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
x86_64)
|
||||
echo "amd64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
echo "arm64"
|
||||
;;
|
||||
armv7l)
|
||||
echo "arm"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Version Management Functions
|
||||
|
||||
```bash
|
||||
# Function to get current installed version and location
|
||||
get_current_version() {
|
||||
if command_exists [tool]; then
|
||||
CURRENT_VERSION=$([tool] --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
if [[ -z "$CURRENT_VERSION" ]]; then
|
||||
CURRENT_VERSION="unknown"
|
||||
fi
|
||||
|
||||
# Determine installation location
|
||||
[TOOL]_PATH=$(which [tool])
|
||||
if [[ "$[TOOL]_PATH" == "$USER_BIN_DIR"* ]]; then
|
||||
INSTALL_TYPE="user"
|
||||
elif [[ "$[TOOL]_PATH" == "/usr/local/bin"* ]] || [[ "$[TOOL]_PATH" == "/usr/bin"* ]]; then
|
||||
INSTALL_TYPE="system"
|
||||
else
|
||||
INSTALL_TYPE="other"
|
||||
fi
|
||||
else
|
||||
CURRENT_VERSION="not_installed"
|
||||
INSTALL_TYPE="none"
|
||||
fi
|
||||
echo "$CURRENT_VERSION:$INSTALL_TYPE"
|
||||
}
|
||||
|
||||
# Function to compare versions
|
||||
compare_versions() {
|
||||
local version1="$1"
|
||||
local version2="$2"
|
||||
|
||||
# Remove 'v' prefix if present
|
||||
version1=${version1#v}
|
||||
version2=${version2#v}
|
||||
|
||||
# Split versions into arrays
|
||||
IFS='.' read -ra V1 <<< "$version1"
|
||||
IFS='.' read -ra V2 <<< "$version2"
|
||||
|
||||
# Compare major, minor, patch
|
||||
for i in {0..2}; do
|
||||
local v1=${V1[$i]:-0}
|
||||
local v2=${V2[$i]:-0}
|
||||
|
||||
if (( v1 > v2 )); then
|
||||
return 0 # version1 > version2
|
||||
elif (( v1 < v2 )); then
|
||||
return 1 # version1 < version2
|
||||
fi
|
||||
done
|
||||
|
||||
return 0 # versions are equal
|
||||
}
|
||||
|
||||
# Function to get latest release info
|
||||
get_latest_release() {
|
||||
print_status "Fetching latest [Tool Name] release information..."
|
||||
|
||||
if command_exists curl; then
|
||||
RELEASE_INFO=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
elif command_exists wget; then
|
||||
RELEASE_INFO=$(wget -qO- "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$RELEASE_INFO" ]]; then
|
||||
print_error "Failed to fetch release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version and download URLs
|
||||
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": *"[^"]*"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
print_error "Failed to parse release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Latest version: $LATEST_VERSION"
|
||||
}
|
||||
|
||||
# Function to check if update is needed
|
||||
check_update_needed() {
|
||||
local latest_version="$1"
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
print_status "Current version: $current_version ($install_type)"
|
||||
print_status "Latest version: $latest_version"
|
||||
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_status "[Tool Name] is not installed"
|
||||
return 0 # Need to install
|
||||
fi
|
||||
|
||||
if [[ "$current_version" == "unknown" ]]; then
|
||||
print_warning "Cannot determine current version, proceeding with update"
|
||||
return 0 # Assume update needed
|
||||
fi
|
||||
|
||||
# Clean version strings for comparison
|
||||
local clean_current="${current_version#v}"
|
||||
local clean_latest="${latest_version#v}"
|
||||
|
||||
if compare_versions "$clean_latest" "$clean_current"; then
|
||||
if [[ "$clean_latest" == "$clean_current" ]]; then
|
||||
print_success "You already have the latest version ($current_version) installed at $install_type location"
|
||||
if [[ "$force_reinstall" == "true" ]]; then
|
||||
print_status "Force reinstall requested, proceeding..."
|
||||
return 0
|
||||
else
|
||||
return 1 # No update needed
|
||||
fi
|
||||
else
|
||||
print_status "Newer version available: $latest_version > $current_version"
|
||||
return 0 # Update needed
|
||||
fi
|
||||
else
|
||||
print_success "Your version ($current_version) is newer than latest release ($latest_version)"
|
||||
return 1 # No update needed
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Installation Strategy Functions
|
||||
|
||||
```bash
|
||||
# Function to check if user bin directory exists and is in PATH
|
||||
check_user_bin_setup() {
|
||||
if [[ ! -d "$USER_BIN_DIR" ]]; then
|
||||
print_status "User bin directory doesn't exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if user bin is in PATH
|
||||
if [[ ":$PATH:" != *":$USER_BIN_DIR:"* ]]; then
|
||||
print_warning "User bin directory ($USER_BIN_DIR) is not in PATH"
|
||||
print_status "Add to PATH: export PATH=\"$USER_BIN_DIR:\$PATH\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to check for version-specific symlink
|
||||
check_version_symlink() {
|
||||
local [tool]_path=$(which [tool] 2>/dev/null)
|
||||
if [[ -z "$[tool]_path" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if it's a symlink
|
||||
if [[ -L "$[tool]_path" ]]; then
|
||||
SYMLINK_TARGET=$(readlink "$[tool]_path")
|
||||
# Extract version from symlink target
|
||||
if [[ "$SYMLINK_TARGET" =~ [tool]-([0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
||||
CURRENT_SYMLINK_VERSION="${BASH_REMATCH[1]}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to determine installation strategy
|
||||
determine_install_strategy() {
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
# Strategy: Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]] || sudo -n true 2>/dev/null; then
|
||||
print_status "Installing system-wide for all users"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
|
||||
# Warn if user bin has [tool]
|
||||
if [[ -f "$USER_BIN_DIR/[tool]" ]]; then
|
||||
print_warning "[Tool Name] found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
fi
|
||||
else
|
||||
print_status "No sudo access, checking user bin directory"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
|
||||
# Check if [tool] exists in user bin
|
||||
if [[ -f "$USER_BIN_DIR/[tool]" ]]; then
|
||||
print_status "[Tool Name] found in user bin directory"
|
||||
|
||||
# Check for version symlink
|
||||
if check_version_symlink; then
|
||||
print_status "Version symlink found: $CURRENT_SYMLINK_VERSION"
|
||||
INSTALL_STRATEGY="user_update"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
else
|
||||
print_status "No version symlink found, will create one"
|
||||
INSTALL_STRATEGY="user_upgrade"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_status "[Tool Name] not found in user bin, will install there"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_error "Cannot install system-wide (no sudo) and user bin not available"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
print_status "Installation strategy: $INSTALL_STRATEGY"
|
||||
print_status "Target directory: $TARGET_DIR"
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Download and Installation Functions
|
||||
|
||||
```bash
|
||||
# Function to download file
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local filename="$2"
|
||||
|
||||
print_status "Downloading $filename..."
|
||||
|
||||
if command_exists curl; then
|
||||
curl -L -o "$TEMP_DIR/$filename" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$TEMP_DIR/$filename" "$url"
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$TEMP_DIR/$filename" ]]; then
|
||||
print_error "Failed to download $filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Downloaded $filename"
|
||||
}
|
||||
|
||||
# Function to install [Tool Name] from binary
|
||||
install_[tool]_from_binary() {
|
||||
local arch="$1"
|
||||
local version="$2"
|
||||
|
||||
# Determine binary name pattern from GitHub releases
|
||||
local binary_name="[tool]-${version#v}-linux-${arch}"
|
||||
|
||||
local download_url="https://github.com/$GITHUB_REPO/releases/download/$version/$binary_name"
|
||||
|
||||
download_file "$download_url" "$binary_name"
|
||||
|
||||
# Determine installation command based on target directory
|
||||
local install_cmd="install -m 755"
|
||||
local symlink_cmd="ln -sf"
|
||||
|
||||
if [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
install_cmd="sudo $install_cmd"
|
||||
symlink_cmd="sudo $symlink_cmd"
|
||||
fi
|
||||
|
||||
print_status "Installing [Tool Name] binary to $TARGET_DIR..."
|
||||
|
||||
# Install the binary with version suffix
|
||||
$install_cmd "$TEMP_DIR/$binary_name" "$TARGET_DIR/[tool]-$version"
|
||||
|
||||
# Verify installation
|
||||
if [[ ! -f "$TARGET_DIR/[tool]-$version" ]]; then
|
||||
print_error "Failed to install [Tool Name] binary"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Remove any existing [tool] symlink or file to avoid conflicts
|
||||
rm -f "$TARGET_DIR/[tool]"
|
||||
|
||||
# Create/update symlink to point to this version
|
||||
$symlink_cmd "$TARGET_DIR/[tool]-$version" "$TARGET_DIR/[tool]"
|
||||
|
||||
print_success "[Tool Name] binary installed successfully"
|
||||
print_status "Version symlink: [tool] -> [tool]-$version"
|
||||
}
|
||||
|
||||
# Function to verify [Tool Name] installation
|
||||
verify_[tool]_installation() {
|
||||
print_status "Verifying [Tool Name] installation..."
|
||||
|
||||
if command_exists [tool]; then
|
||||
local version=$([tool] --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
print_success "[Tool Name] installed: $version"
|
||||
|
||||
# Check for user bin versions and offer removal
|
||||
if [[ -d "$USER_BIN_DIR" ]] && [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
local user_versions=()
|
||||
for file in "$USER_BIN_DIR"/[tool]*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
user_versions+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#user_versions[@]} -gt 0 ]]; then
|
||||
print_warning "Found [tool] binaries in user bin directory:"
|
||||
for file in "${user_versions[@]}"; do
|
||||
echo " $file"
|
||||
done
|
||||
echo
|
||||
read -p "Would you like to remove these user bin versions? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for file in "${user_versions[@]}"; do
|
||||
rm -f "$file"
|
||||
print_status "Removed $file"
|
||||
done
|
||||
print_success "Removed all user bin versions"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "[Tool Name] installation verification failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
### 7. Utility Functions
|
||||
|
||||
```bash
|
||||
# Function to cleanup
|
||||
cleanup() {
|
||||
if [[ -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
print_status "Cleaned up temporary files"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "[Tool Name] Installer"
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " -v, --version Install specific version (default: latest)"
|
||||
echo " -f, --force Force reinstall even if up-to-date"
|
||||
echo " -r, --reinstall Reinstall the current installed version"
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " $0 # Install latest version using best method"
|
||||
echo " $0 -v v1.0.0 # Install specific version"
|
||||
echo " $0 --reinstall # Reinstall current version"
|
||||
}
|
||||
```
|
||||
|
||||
### 8. Main Function
|
||||
|
||||
```bash
|
||||
# Main installation function
|
||||
main() {
|
||||
local target_version=""
|
||||
local force_reinstall=false
|
||||
local reinstall_current=false
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
target_version="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--force)
|
||||
force_reinstall=true
|
||||
shift
|
||||
;;
|
||||
-r|--reinstall)
|
||||
reinstall_current=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "========================================"
|
||||
echo "[Tool Name] Installer"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# Check if running as root for system installation
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_warning "Not running as root. Some operations may require sudo."
|
||||
fi
|
||||
|
||||
# Detect system
|
||||
detect_os
|
||||
ARCH=$(get_arch)
|
||||
|
||||
# Handle reinstall current version
|
||||
if [[ "$reinstall_current" == "true" ]]; then
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_error "No current version installed to reinstall"
|
||||
exit 1
|
||||
fi
|
||||
target_version="$current_version"
|
||||
force_reinstall=true
|
||||
print_status "Reinstalling current version: $target_version"
|
||||
fi
|
||||
|
||||
# Get latest version if not specified
|
||||
if [[ -z "$target_version" ]]; then
|
||||
get_latest_release
|
||||
target_version="$LATEST_VERSION"
|
||||
else
|
||||
print_status "Using specified version: $target_version"
|
||||
fi
|
||||
|
||||
# Determine installation strategy
|
||||
determine_install_strategy
|
||||
|
||||
# Check if update is needed
|
||||
if ! check_update_needed "$target_version"; then
|
||||
print_success "No installation needed. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Install from binary
|
||||
install_[tool]_from_binary "$ARCH" "$target_version"
|
||||
verify_[tool]_installation
|
||||
|
||||
# Installation completed successfully
|
||||
echo
|
||||
print_success "Installation completed successfully!"
|
||||
echo
|
||||
echo "Installation details:"
|
||||
echo "- Strategy: $INSTALL_STRATEGY"
|
||||
echo "- Location: $TARGET_DIR"
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "- Binary: [tool] (symlink to [tool]-$target_version)"
|
||||
echo "- Version: $target_version"
|
||||
fi
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo "1. Test installation: [tool] --version"
|
||||
echo "2. [Add tool-specific usage instructions]"
|
||||
echo
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "User-specific installation notes:"
|
||||
echo "- Binary installed in: $USER_BIN_DIR"
|
||||
echo "- Ensure $USER_BIN_DIR is in your PATH"
|
||||
echo "- You can have multiple versions side-by-side"
|
||||
fi
|
||||
echo
|
||||
echo "For more information, visit: https://github.com/$GITHUB_REPO"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
```
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
1. **Replace Placeholders**: Replace `[tool]`, `[Tool Name]`, `[TOOL]`, `[owner]/[repo]` with actual values.
|
||||
|
||||
2. **Binary Naming Convention**: Adjust the `binary_name` in `install_[tool]_from_binary` to match the actual GitHub release asset names.
|
||||
|
||||
3. **Version Detection**: Modify the version extraction in `get_current_version` and `verify_[tool]_installation` to match the tool's `--version` output format.
|
||||
|
||||
4. **Package Manager**: Since we disable package manager installation, the script will always use the binary method.
|
||||
|
||||
5. **Testing**: Test the script on different systems and with different scenarios (system vs user installation, reinstall, etc.).
|
||||
|
||||
6. **Error Handling**: Ensure all error conditions are properly handled with appropriate exit codes.
|
||||
|
||||
7. **Documentation**: Update the usage examples and next steps section with tool-specific information.
|
||||
|
||||
This template ensures consistency across all installer scripts and provides a robust installation experience for users.</content>
|
||||
<parameter name="filePath">INSTALLER_CREATION_GUIDE.md
|
||||
130
README.md
130
README.md
@@ -5,23 +5,137 @@ This script helps you create a git repository from existing codebase and configu
|
||||
## Features
|
||||
|
||||
- **Multiple Authentication Methods**:
|
||||
- SSH (passwordless after key setup)
|
||||
- HTTPS (with token/password)
|
||||
- Tea CLI (Gitea's official command-line tool)
|
||||
- SSH (passwordless with key generation)
|
||||
- HTTPS (with Git Credential Manager)
|
||||
- Tea CLI (full Gitea API integration)
|
||||
|
||||
- **Advanced Installation Management**:
|
||||
- **Tea CLI**: User-specific installations with version symlinks
|
||||
- **Git Credential Manager**: Automatic detection and setup
|
||||
- **Borg CLI**: Backup tool with smart version management
|
||||
- **Smart Updates**: Only downloads when newer versions available
|
||||
|
||||
- **Automatic Setup**:
|
||||
- Git repository initialization
|
||||
- SSH key generation (if needed)
|
||||
- SSH key generation and display
|
||||
- Tea CLI installation and configuration
|
||||
- Remote repository creation
|
||||
- Connection testing
|
||||
|
||||
## Usage
|
||||
|
||||
1. Make the script executable:
|
||||
```bash
|
||||
chmod +x setup-git-repo.sh
|
||||
```
|
||||
```bash
|
||||
# Interactive setup
|
||||
./setup-git-repo.sh
|
||||
|
||||
# With configuration file
|
||||
echo '{"gitea": {"server_url": "https://your-gitea.com"}}' > config.json
|
||||
./setup-git-repo.sh
|
||||
```
|
||||
|
||||
## Available Installers
|
||||
|
||||
### Tea CLI Installer
|
||||
```bash
|
||||
# Install latest Tea CLI
|
||||
./install-tea-cli.sh
|
||||
|
||||
# Install specific version
|
||||
./install-tea-cli.sh -v v0.11.1
|
||||
|
||||
# Force reinstall
|
||||
./install-tea-cli.sh --force
|
||||
```
|
||||
|
||||
### Borg CLI Installer
|
||||
```bash
|
||||
# Install latest Borg CLI
|
||||
./install-borg-cli.sh
|
||||
|
||||
# Install specific version
|
||||
./install-borg-cli.sh -v 1.4.2
|
||||
|
||||
# Force reinstall
|
||||
./install-borg-cli.sh --force
|
||||
```
|
||||
|
||||
### Git Credential Manager Installer
|
||||
```bash
|
||||
# Install latest GCM
|
||||
./install-git-credential-manager.sh
|
||||
|
||||
# Install specific version
|
||||
./install-git-credential-manager.sh -v v2.6.1
|
||||
|
||||
# Force reinstall
|
||||
./install-git-credential-manager.sh --force
|
||||
|
||||
# Check configuration without installing
|
||||
./install-git-credential-manager.sh --checks
|
||||
```
|
||||
|
||||
## Installation Strategies
|
||||
|
||||
All installers implement smart installation strategies:
|
||||
|
||||
### User-Specific Installations (Preferred)
|
||||
- **Location**: `~/bin/` directory
|
||||
- **Requirements**: `~/bin` exists and is in PATH
|
||||
- **Benefits**: No sudo required, user isolation, multiple versions
|
||||
- **Structure**:
|
||||
```
|
||||
~/bin/
|
||||
├── tea -> tea-v0.11.1 # Active version
|
||||
├── tea-v0.11.0 # Previous version
|
||||
└── tea-v0.11.1 # Current version
|
||||
```
|
||||
|
||||
### System-Wide Installations (Fallback)
|
||||
- **Location**: `/usr/local/bin/`
|
||||
- **Requirements**: sudo access
|
||||
- **Benefits**: Available to all users
|
||||
- **Structure**:
|
||||
```
|
||||
/usr/local/bin/
|
||||
├── tea -> tea-v0.11.1
|
||||
├── tea-v0.11.0
|
||||
└── tea-v0.11.1
|
||||
```
|
||||
|
||||
### Version Management
|
||||
- **Symlinks**: Automatic version switching
|
||||
- **Multiple Versions**: Keep old versions for rollback
|
||||
- **Smart Updates**: Only download when newer version available
|
||||
|
||||
## Configuration
|
||||
|
||||
The script supports JSON configuration for automation:
|
||||
|
||||
```json
|
||||
{
|
||||
"gitea": {
|
||||
"server_url": "https://your-gitea.com",
|
||||
"default_login_name": "$USER",
|
||||
"login_method": "token",
|
||||
"has_access_token": true,
|
||||
"default_auth_method": "3"
|
||||
},
|
||||
"git": {
|
||||
"default_branch": "main",
|
||||
"auto_init": false
|
||||
},
|
||||
"ssh": {
|
||||
"key_type": "ed25519",
|
||||
"key_path": "~/.ssh/id_ed25519"
|
||||
},
|
||||
"repository": {
|
||||
"default_private": false,
|
||||
"auto_add_files": false,
|
||||
"auto_commit": false,
|
||||
"auto_push": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. Run the script:
|
||||
```bash
|
||||
|
||||
57
credential-manager-demo.sh
Executable file
57
credential-manager-demo.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Demo: Git Credential Manager in Console Mode
|
||||
# This script demonstrates how credential managers work without GUI
|
||||
|
||||
echo "=== Git Credential Manager Console Demo ==="
|
||||
echo
|
||||
|
||||
# Check available credential managers
|
||||
echo "1. Checking available credential managers..."
|
||||
if command -v git-credential-manager >/dev/null 2>&1; then
|
||||
echo "✓ Git Credential Manager (GCM) found: $(git-credential-manager --version)"
|
||||
else
|
||||
echo "✗ Git Credential Manager not found"
|
||||
fi
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if git config --global --get credential.helper 2>/dev/null | grep -q "osxkeychain"; then
|
||||
echo "✓ macOS Keychain helper configured"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
if command -v gnome-keyring-daemon >/dev/null 2>&1; then
|
||||
echo "✓ GNOME Keyring available"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "2. Current Git credential configuration:"
|
||||
git config --global --show-origin --get credential.helper 2>/dev/null || echo "No global credential helper configured"
|
||||
|
||||
echo
|
||||
echo "3. Testing credential storage (console mode)..."
|
||||
echo "This demonstrates how credentials are stored/retrieved without GUI"
|
||||
|
||||
# Create a test credential input
|
||||
cat << 'EOF' | git credential-manager get 2>/dev/null || echo "Credential manager ready for input"
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=testuser
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo "4. How it works in console:"
|
||||
echo " - First 'git push/pull' prompts for username/token"
|
||||
echo " - Credential manager stores them securely"
|
||||
echo " - Subsequent operations use stored credentials automatically"
|
||||
echo " - No GUI required - all terminal-based"
|
||||
|
||||
echo
|
||||
echo "5. Available commands (all console-based):"
|
||||
echo " git credential-manager configure # Configure settings"
|
||||
echo " git credential-manager erase # Remove stored credentials"
|
||||
echo " git credential-manager approve # Approve credential storage"
|
||||
echo " git credential-manager reject # Reject credential storage"
|
||||
|
||||
echo
|
||||
echo "=== Demo Complete ==="
|
||||
629
install-borg-cli.sh
Executable file
629
install-borg-cli.sh
Executable file
@@ -0,0 +1,629 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Borg CLI Installer
|
||||
# Downloads and installs the latest Borg CLI binary
|
||||
# Supports multiple platforms and installation methods
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
GITHUB_REPO="borgbackup/borg"
|
||||
USER_BIN_DIR="$HOME/bin"
|
||||
SYSTEM_INSTALL_DIR="/usr/local/bin"
|
||||
TEMP_DIR="/tmp/borg-install"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to detect OS and package manager
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS="$ID"
|
||||
OS_VERSION="$VERSION_ID"
|
||||
else
|
||||
print_error "Cannot detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect package manager
|
||||
if command_exists apt; then
|
||||
PKG_MANAGER="apt"
|
||||
elif command_exists yum; then
|
||||
PKG_MANAGER="yum"
|
||||
elif command_exists dnf; then
|
||||
PKG_MANAGER="dnf"
|
||||
elif command_exists pacman; then
|
||||
PKG_MANAGER="pacman"
|
||||
elif command_exists zypper; then
|
||||
PKG_MANAGER="zypper"
|
||||
else
|
||||
PKG_MANAGER="unknown"
|
||||
fi
|
||||
|
||||
print_status "Detected OS: $OS $OS_VERSION"
|
||||
print_status "Package manager: $PKG_MANAGER"
|
||||
}
|
||||
|
||||
# Function to get system architecture
|
||||
get_arch() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
x86_64)
|
||||
echo "x86_64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
echo "aarch64"
|
||||
;;
|
||||
armv7l)
|
||||
echo "armv7"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to get current installed version and location
|
||||
get_current_version() {
|
||||
if command_exists borg; then
|
||||
CURRENT_VERSION=$(borg --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
if [[ -z "$CURRENT_VERSION" ]]; then
|
||||
CURRENT_VERSION="unknown"
|
||||
fi
|
||||
|
||||
# Determine installation location
|
||||
BORG_PATH=$(which borg)
|
||||
if [[ "$BORG_PATH" == "$USER_BIN_DIR"* ]]; then
|
||||
INSTALL_TYPE="user"
|
||||
elif [[ "$BORG_PATH" == "/usr/local/bin"* ]] || [[ "$BORG_PATH" == "/usr/bin"* ]]; then
|
||||
INSTALL_TYPE="system"
|
||||
else
|
||||
INSTALL_TYPE="other"
|
||||
fi
|
||||
else
|
||||
CURRENT_VERSION="not_installed"
|
||||
INSTALL_TYPE="none"
|
||||
fi
|
||||
echo "$CURRENT_VERSION:$INSTALL_TYPE"
|
||||
}
|
||||
|
||||
# Function to compare versions
|
||||
compare_versions() {
|
||||
local version1="$1"
|
||||
local version2="$2"
|
||||
|
||||
# Remove 'v' prefix if present
|
||||
version1=${version1#v}
|
||||
version2=${version2#v}
|
||||
|
||||
# Split versions into arrays
|
||||
IFS='.' read -ra V1 <<< "$version1"
|
||||
IFS='.' read -ra V2 <<< "$version2"
|
||||
|
||||
# Compare major, minor, patch
|
||||
for i in {0..2}; do
|
||||
local v1=${V1[$i]:-0}
|
||||
local v2=${V2[$i]:-0}
|
||||
|
||||
if (( v1 > v2 )); then
|
||||
return 0 # version1 > version2
|
||||
elif (( v1 < v2 )); then
|
||||
return 1 # version1 < version2
|
||||
fi
|
||||
done
|
||||
|
||||
return 0 # versions are equal
|
||||
}
|
||||
|
||||
# Function to get latest release info
|
||||
get_latest_release() {
|
||||
print_status "Fetching latest Borg CLI release information..."
|
||||
|
||||
if command_exists curl; then
|
||||
RELEASE_INFO=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
elif command_exists wget; then
|
||||
RELEASE_INFO=$(wget -qO- "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$RELEASE_INFO" ]]; then
|
||||
print_error "Failed to fetch release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version and download URLs
|
||||
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": *"[^"]*"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
print_error "Failed to parse release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Latest version: $LATEST_VERSION"
|
||||
}
|
||||
|
||||
# Function to check if update is needed
|
||||
check_update_needed() {
|
||||
local latest_version="$1"
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
print_status "Current version: $current_version ($install_type)"
|
||||
print_status "Latest version: $latest_version"
|
||||
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_status "Borg CLI is not installed"
|
||||
return 0 # Need to install
|
||||
fi
|
||||
|
||||
if [[ "$current_version" == "unknown" ]]; then
|
||||
print_warning "Cannot determine current version, proceeding with update"
|
||||
return 0 # Assume update needed
|
||||
fi
|
||||
|
||||
# Clean version strings for comparison
|
||||
local clean_current="${current_version#v}"
|
||||
local clean_latest="${latest_version#v}"
|
||||
|
||||
if compare_versions "$clean_latest" "$clean_current"; then
|
||||
if [[ "$clean_latest" == "$clean_current" ]]; then
|
||||
print_success "You already have the latest version ($current_version) installed at $install_type location"
|
||||
if [[ "$force_reinstall" == "true" ]]; then
|
||||
print_status "Force reinstall requested, proceeding..."
|
||||
return 0
|
||||
else
|
||||
return 1 # No update needed
|
||||
fi
|
||||
else
|
||||
print_status "Newer version available: $latest_version > $current_version"
|
||||
return 0 # Update needed
|
||||
fi
|
||||
else
|
||||
print_success "Your version ($current_version) is newer than latest release ($latest_version)"
|
||||
return 1 # No update needed
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download file
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local filename="$2"
|
||||
|
||||
print_status "Downloading $filename..."
|
||||
|
||||
if command_exists curl; then
|
||||
curl -L -o "$TEMP_DIR/$filename" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$TEMP_DIR/$filename" "$url"
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$TEMP_DIR/$filename" ]]; then
|
||||
print_error "Failed to download $filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Downloaded $filename"
|
||||
}
|
||||
|
||||
# Function to check if user bin directory exists and is in PATH
|
||||
check_user_bin_setup() {
|
||||
if [[ ! -d "$USER_BIN_DIR" ]]; then
|
||||
print_status "User bin directory doesn't exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if user bin is in PATH
|
||||
if [[ ":$PATH:" != *":$USER_BIN_DIR:"* ]]; then
|
||||
print_warning "User bin directory ($USER_BIN_DIR) is not in PATH"
|
||||
print_status "Add to PATH: export PATH=\"$USER_BIN_DIR:\$PATH\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to check for version-specific symlink
|
||||
check_version_symlink() {
|
||||
local borg_path=$(which borg 2>/dev/null)
|
||||
if [[ -z "$borg_path" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if it's a symlink
|
||||
if [[ -L "$borg_path" ]]; then
|
||||
SYMLINK_TARGET=$(readlink "$borg_path")
|
||||
# Extract version from symlink target
|
||||
if [[ "$SYMLINK_TARGET" =~ borg-([0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
||||
CURRENT_SYMLINK_VERSION="${BASH_REMATCH[1]}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to determine installation strategy
|
||||
determine_install_strategy() {
|
||||
local local_install="$1"
|
||||
|
||||
# Strategy: Check installation type preference
|
||||
if [[ "$local_install" == "true" ]]; then
|
||||
print_status "Local installation requested"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
else
|
||||
print_error "User bin directory not available for local installation"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
print_status "Running as root, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
elif sudo -n true 2>/dev/null; then
|
||||
print_status "Passwordless sudo available, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
elif command_exists sudo; then
|
||||
print_status "Testing sudo access (you may be prompted for password)..."
|
||||
if sudo -v 2>/dev/null; then
|
||||
print_success "Sudo access confirmed, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
else
|
||||
print_error "Sudo access failed. Use --local to install to user bin directory"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_error "Sudo not available. Use --local to install to user bin directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Warn if user bin has borg (only for system installs)
|
||||
if [[ "$INSTALL_STRATEGY" == "system_install" ]] && [[ -f "$USER_BIN_DIR/borg" ]]; then
|
||||
print_warning "Borg CLI found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_status "Installation strategy: $INSTALL_STRATEGY"
|
||||
print_status "Target directory: $TARGET_DIR"
|
||||
}
|
||||
|
||||
# Function to install Borg CLI from package manager
|
||||
install_borg_from_package_manager() {
|
||||
# Package manager versions are often outdated, use binary from GitHub instead
|
||||
print_warning "Package manager installation skipped for Borg CLI to ensure latest version, using binary instead"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to install Borg CLI from binary
|
||||
install_borg_from_binary() {
|
||||
local arch="$1"
|
||||
local version="$2"
|
||||
|
||||
# Borg uses different naming conventions based on architecture
|
||||
local binary_name
|
||||
case "$arch" in
|
||||
x86_64)
|
||||
binary_name="borg-linux-glibc231-x86_64"
|
||||
;;
|
||||
aarch64)
|
||||
binary_name="borg-linux-glibc235-arm64-gh"
|
||||
;;
|
||||
armv7)
|
||||
binary_name="borg-linux-glibc231-armv7"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported architecture: $arch"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
local download_url="https://github.com/$GITHUB_REPO/releases/download/$version/$binary_name"
|
||||
|
||||
download_file "$download_url" "$binary_name"
|
||||
|
||||
# Determine installation command based on target directory
|
||||
local install_cmd="install -m 755"
|
||||
local symlink_cmd="ln -sf"
|
||||
|
||||
if [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
install_cmd="sudo $install_cmd"
|
||||
symlink_cmd="sudo $symlink_cmd"
|
||||
fi
|
||||
|
||||
print_status "Installing Borg CLI binary to $TARGET_DIR..."
|
||||
|
||||
# Install the binary with version suffix
|
||||
$install_cmd "$TEMP_DIR/$binary_name" "$TARGET_DIR/borg-$version"
|
||||
|
||||
# Verify installation
|
||||
if [[ ! -f "$TARGET_DIR/borg-$version" ]]; then
|
||||
print_error "Failed to install Borg CLI binary"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Remove any existing borg symlink or file to avoid conflicts
|
||||
if [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
sudo rm -f "$TARGET_DIR/borg"
|
||||
else
|
||||
rm -f "$TARGET_DIR/borg"
|
||||
fi
|
||||
|
||||
# Create/update symlink to point to this version
|
||||
$symlink_cmd "$TARGET_DIR/borg-$version" "$TARGET_DIR/borg"
|
||||
|
||||
print_success "Borg CLI binary installed successfully"
|
||||
print_status "Version symlink: borg -> borg-$version"
|
||||
}
|
||||
|
||||
# Function to verify Borg CLI installation
|
||||
verify_borg_installation() {
|
||||
print_status "Verifying Borg CLI installation..."
|
||||
|
||||
if command_exists borg; then
|
||||
local version=$(borg --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
print_success "Borg CLI installed: $version"
|
||||
|
||||
# Check for user bin versions and offer removal
|
||||
if [[ -d "$USER_BIN_DIR" ]] && [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
local user_versions=()
|
||||
for file in "$USER_BIN_DIR"/borg*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
user_versions+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#user_versions[@]} -gt 0 ]]; then
|
||||
print_warning "Found borg binaries in user bin directory:"
|
||||
for file in "${user_versions[@]}"; do
|
||||
echo " $file"
|
||||
done
|
||||
echo
|
||||
read -p "Would you like to remove these user bin versions? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for file in "${user_versions[@]}"; do
|
||||
rm -f "$file"
|
||||
print_status "Removed $file"
|
||||
done
|
||||
print_success "Removed all user bin versions"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Borg CLI installation verification failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to cleanup
|
||||
cleanup() {
|
||||
if [[ -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
print_status "Cleaned up temporary files"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Borg CLI Installer"
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " -v, --version Install specific version (default: latest)"
|
||||
echo " -f, --force Force reinstall even if up-to-date"
|
||||
echo " -r, --reinstall Reinstall the current installed version"
|
||||
echo " -l, --local Force installation to user bin directory (~/.bin)"
|
||||
echo " -p, --package Force installation from package manager"
|
||||
echo " -b, --binary Force installation from binary"
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " $0 # Install latest version using best method"
|
||||
echo " $0 -v v1.2.7 # Install specific version"
|
||||
echo " $0 --reinstall # Reinstall current version"
|
||||
echo " $0 --local # Force installation to user bin"
|
||||
echo " $0 --package # Force installation from package manager"
|
||||
echo " $0 --binary # Force installation from binary"
|
||||
echo
|
||||
}
|
||||
|
||||
# Main installation function
|
||||
main() {
|
||||
local target_version=""
|
||||
local force_reinstall=false
|
||||
local reinstall_current=false
|
||||
local local_install=false
|
||||
local install_method="auto"
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
target_version="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--force)
|
||||
force_reinstall=true
|
||||
shift
|
||||
;;
|
||||
-r|--reinstall)
|
||||
reinstall_current=true
|
||||
shift
|
||||
;;
|
||||
-l|--local)
|
||||
local_install=true
|
||||
shift
|
||||
;;
|
||||
-p|--package)
|
||||
install_method="package"
|
||||
shift
|
||||
;;
|
||||
-b|--binary)
|
||||
install_method="binary"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "========================================"
|
||||
echo "Borg CLI Installer"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# Check if running as root for system installation
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_warning "Not running as root. Some operations may require sudo."
|
||||
fi
|
||||
|
||||
# Detect system
|
||||
detect_os
|
||||
ARCH=$(get_arch)
|
||||
|
||||
# Handle reinstall current version
|
||||
if [[ "$reinstall_current" == "true" ]]; then
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_error "No current version installed to reinstall"
|
||||
exit 1
|
||||
fi
|
||||
target_version="$current_version"
|
||||
force_reinstall=true
|
||||
print_status "Reinstalling current version: $target_version"
|
||||
fi
|
||||
|
||||
# Get latest version if not specified
|
||||
if [[ -z "$target_version" ]]; then
|
||||
get_latest_release
|
||||
target_version="$LATEST_VERSION"
|
||||
else
|
||||
print_status "Using specified version: $target_version"
|
||||
fi
|
||||
|
||||
# Determine installation strategy
|
||||
determine_install_strategy "$local_install"
|
||||
|
||||
# Check if update is needed
|
||||
if ! check_update_needed "$target_version"; then
|
||||
print_success "No installation needed. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Installation logic based on method and strategy
|
||||
case $install_method in
|
||||
auto)
|
||||
# For user installations, prefer binary over package manager
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
print_status "Using binary installation for user directory"
|
||||
install_borg_from_binary "$ARCH" "$target_version"
|
||||
verify_borg_installation
|
||||
else
|
||||
# Try package manager first for system installations
|
||||
if install_borg_from_package_manager; then
|
||||
verify_borg_installation
|
||||
else
|
||||
install_borg_from_binary "$ARCH" "$target_version"
|
||||
verify_borg_installation
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
package)
|
||||
if ! install_borg_from_package_manager; then
|
||||
print_error "Package manager installation failed"
|
||||
exit 1
|
||||
fi
|
||||
verify_borg_installation
|
||||
;;
|
||||
binary)
|
||||
install_borg_from_binary "$ARCH" "$target_version"
|
||||
verify_borg_installation
|
||||
;;
|
||||
esac
|
||||
|
||||
# Installation completed successfully
|
||||
echo
|
||||
print_success "Installation completed successfully!"
|
||||
echo
|
||||
echo "Installation details:"
|
||||
echo "- Strategy: $INSTALL_STRATEGY"
|
||||
echo "- Location: $TARGET_DIR"
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "- Binary: borg (symlink to borg-$target_version)"
|
||||
echo "- Version: $target_version"
|
||||
fi
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo "1. Test installation: borg --version"
|
||||
echo "2. Initialize repository: borg init --encryption=repokey /path/to/repo"
|
||||
echo "3. Create backup: borg create /path/to/repo::backup-name /path/to/backup"
|
||||
echo "4. Use Borg CLI: borg --help"
|
||||
echo
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "User-specific installation notes:"
|
||||
echo "- Binary installed in: $USER_BIN_DIR"
|
||||
echo "- Ensure $USER_BIN_DIR is in your PATH"
|
||||
echo "- You can have multiple versions side-by-side"
|
||||
fi
|
||||
echo
|
||||
echo "For more information, visit: https://borgbackup.readthedocs.io/"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
718
install-git-credential-manager.sh
Executable file
718
install-git-credential-manager.sh
Executable file
@@ -0,0 +1,718 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Git Credential Manager Installer
|
||||
# Supports Debian, Ubuntu, RHEL, CentOS, Fedora, and other Linux distributions
|
||||
# Downloads and installs the latest version from GitHub releases
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
GITHUB_REPO="git-ecosystem/git-credential-manager"
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
USER_BIN_DIR="$HOME/bin"
|
||||
TEMP_DIR="/tmp/gcm-install"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to detect OS and package manager
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS="$ID"
|
||||
OS_VERSION="$VERSION_ID"
|
||||
else
|
||||
print_error "Cannot detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect package manager
|
||||
if command_exists apt; then
|
||||
PKG_MANAGER="apt"
|
||||
elif command_exists yum; then
|
||||
PKG_MANAGER="yum"
|
||||
elif command_exists dnf; then
|
||||
PKG_MANAGER="dnf"
|
||||
elif command_exists pacman; then
|
||||
PKG_MANAGER="pacman"
|
||||
elif command_exists zypper; then
|
||||
PKG_MANAGER="zypper"
|
||||
else
|
||||
PKG_MANAGER="unknown"
|
||||
fi
|
||||
|
||||
print_status "Detected OS: $OS $OS_VERSION"
|
||||
print_status "Package manager: $PKG_MANAGER"
|
||||
}
|
||||
|
||||
# Function to get system architecture
|
||||
get_arch() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
x86_64)
|
||||
echo "amd64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
echo "arm64"
|
||||
;;
|
||||
armv7l)
|
||||
echo "arm"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to get current installed version and location
|
||||
get_current_version() {
|
||||
if command_exists git-credential-manager; then
|
||||
# Extract version from output like "2.6.1+786ab03440ddc82e807a97c0e540f5247e44cec6"
|
||||
local version_output=$(git-credential-manager --version 2>/dev/null)
|
||||
CURRENT_VERSION=$(echo "$version_output" | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
if [[ -n "$CURRENT_VERSION" ]]; then
|
||||
CURRENT_VERSION="v$CURRENT_VERSION"
|
||||
else
|
||||
CURRENT_VERSION="unknown"
|
||||
fi
|
||||
|
||||
# Determine installation location
|
||||
GCM_PATH=$(which git-credential-manager)
|
||||
if [[ "$GCM_PATH" == "$HOME/bin"* ]]; then
|
||||
INSTALL_TYPE="user"
|
||||
elif [[ "$GCM_PATH" == "/usr/local/bin"* ]] || [[ "$GCM_PATH" == "/usr/bin"* ]]; then
|
||||
INSTALL_TYPE="system"
|
||||
else
|
||||
INSTALL_TYPE="other"
|
||||
fi
|
||||
else
|
||||
CURRENT_VERSION="not_installed"
|
||||
INSTALL_TYPE="none"
|
||||
fi
|
||||
echo "$CURRENT_VERSION:$INSTALL_TYPE"
|
||||
}
|
||||
|
||||
# Function to compare versions (returns 0 if first >= second, 1 if first < second)
|
||||
compare_versions() {
|
||||
local version1="$1"
|
||||
local version2="$2"
|
||||
|
||||
# Remove 'v' prefix if present
|
||||
version1=${version1#v}
|
||||
version2=${version2#v}
|
||||
|
||||
# Split versions into arrays
|
||||
IFS='.' read -ra V1 <<< "$version1"
|
||||
IFS='.' read -ra V2 <<< "$version2"
|
||||
|
||||
# Compare major, minor, patch
|
||||
for i in {0..2}; do
|
||||
local v1=${V1[$i]:-0}
|
||||
local v2=${V2[$i]:-0}
|
||||
|
||||
if (( v1 > v2 )); then
|
||||
return 0 # version1 > version2
|
||||
elif (( v1 < v2 )); then
|
||||
return 1 # version1 < version2
|
||||
fi
|
||||
done
|
||||
|
||||
return 0 # versions are equal
|
||||
}
|
||||
|
||||
# Function to get latest release info
|
||||
get_latest_release() {
|
||||
print_status "Fetching latest release information..."
|
||||
|
||||
if command_exists curl; then
|
||||
RELEASE_INFO=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
elif command_exists wget; then
|
||||
RELEASE_INFO=$(wget -qO- "https://api.github.com/repos/$GITHUB_REPO/releases/latest")
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$RELEASE_INFO" ]]; then
|
||||
print_error "Failed to fetch release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version and download URLs
|
||||
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": *"[^"]*"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
print_error "Failed to parse release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Latest version: $LATEST_VERSION"
|
||||
}
|
||||
|
||||
# Function to check if update is needed
|
||||
check_update_needed() {
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
local latest_version="$1"
|
||||
|
||||
print_status "Current version: $current_version ($install_type)"
|
||||
print_status "Latest version: $latest_version"
|
||||
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_status "git-credential-manager is not installed"
|
||||
return 0 # Need to install
|
||||
fi
|
||||
|
||||
if [[ "$current_version" == "unknown" ]]; then
|
||||
print_warning "Cannot determine current version, proceeding with update"
|
||||
return 0 # Assume update needed
|
||||
fi
|
||||
|
||||
if compare_versions "$latest_version" "$current_version"; then
|
||||
if [[ "$latest_version" == "$current_version" ]]; then
|
||||
print_success "You already have the latest version ($current_version) installed at $install_type location"
|
||||
if [[ "$force_reinstall" == "true" ]]; then
|
||||
print_status "Force reinstall requested, proceeding..."
|
||||
return 0
|
||||
else
|
||||
return 1 # No update needed
|
||||
fi
|
||||
else
|
||||
print_status "Newer version available: $latest_version > $current_version"
|
||||
return 0 # Update needed
|
||||
fi
|
||||
else
|
||||
print_success "Your version ($current_version) is newer than latest release ($latest_version)"
|
||||
return 1 # No update needed
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download file
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local filename="$2"
|
||||
|
||||
print_status "Downloading $filename..."
|
||||
|
||||
if command_exists curl; then
|
||||
curl -L -o "$TEMP_DIR/$filename" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$TEMP_DIR/$filename" "$url"
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$TEMP_DIR/$filename" ]]; then
|
||||
print_error "Failed to download $filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Downloaded $filename"
|
||||
}
|
||||
|
||||
# Function to install from package manager
|
||||
install_from_package_manager() {
|
||||
print_status "Attempting to install from package manager..."
|
||||
|
||||
case $PKG_MANAGER in
|
||||
apt)
|
||||
# Check if git-credential-manager is available in repos
|
||||
if apt-cache show git-credential-manager >/dev/null 2>&1; then
|
||||
print_status "Installing git-credential-manager from apt repository..."
|
||||
sudo apt update
|
||||
sudo apt install -y git-credential-manager
|
||||
return 0
|
||||
else
|
||||
print_warning "git-credential-manager not available in apt repositories"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
yum|dnf)
|
||||
# Check EPEL repositories for RHEL/CentOS/Fedora
|
||||
if command_exists git-credential-manager; then
|
||||
print_success "git-credential-manager is already installed"
|
||||
return 0
|
||||
else
|
||||
print_warning "git-credential-manager not available in $PKG_MANAGER repositories"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
pacman)
|
||||
# Arch Linux has git-credential-manager in community repo
|
||||
if pacman -Si git-credential-manager >/dev/null 2>&1; then
|
||||
print_status "Installing git-credential-manager from pacman repository..."
|
||||
sudo pacman -S --noconfirm git-credential-manager
|
||||
return 0
|
||||
else
|
||||
print_warning "git-credential-manager not available in pacman repositories"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
print_warning "Package manager $PKG_MANAGER not supported for automatic installation"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to install from DEB package
|
||||
install_from_deb() {
|
||||
local arch="$1"
|
||||
local version="$2"
|
||||
|
||||
local deb_name="gcm-linux_${arch}.${version#v}.deb"
|
||||
local download_url="https://github.com/$GITHUB_REPO/releases/download/$version/$deb_name"
|
||||
|
||||
download_file "$download_url" "$deb_name"
|
||||
|
||||
print_status "Installing DEB package..."
|
||||
sudo dpkg -i "$TEMP_DIR/$deb_name" || {
|
||||
print_warning "dpkg failed, attempting to fix dependencies..."
|
||||
sudo apt-get install -f -y
|
||||
}
|
||||
|
||||
print_success "DEB package installed successfully"
|
||||
}
|
||||
|
||||
# Function to install from tar.gz
|
||||
install_from_tarball() {
|
||||
local arch="$1"
|
||||
local version="$2"
|
||||
|
||||
local tar_name="gcm-linux_${arch}.${version#v}.tar.gz"
|
||||
local download_url="https://github.com/$GITHUB_REPO/releases/download/$version/$tar_name"
|
||||
|
||||
download_file "$download_url" "$tar_name"
|
||||
|
||||
print_status "Extracting tarball..."
|
||||
cd "$TEMP_DIR"
|
||||
tar -xzf "$tar_name"
|
||||
|
||||
# Check if binary was extracted directly
|
||||
if [[ -f "git-credential-manager" ]]; then
|
||||
print_status "Installing binary to $INSTALL_DIR..."
|
||||
sudo install -m 755 git-credential-manager "$INSTALL_DIR/git-credential-manager"
|
||||
sudo ln -sf "$INSTALL_DIR/git-credential-manager" "$INSTALL_DIR/git-credential-manager-core"
|
||||
|
||||
# Install shared libraries if present
|
||||
for lib in lib*.so; do
|
||||
if [[ -f "$lib" ]]; then
|
||||
sudo install -m 644 "$lib" "$INSTALL_DIR/"
|
||||
print_status "Installed library: $lib"
|
||||
fi
|
||||
done
|
||||
else
|
||||
# Try to find extracted directory (fallback)
|
||||
local extracted_dir=$(find . -maxdepth 1 -type d -name "git-credential-manager*" | head -n 1)
|
||||
if [[ -z "$extracted_dir" ]]; then
|
||||
print_error "Could not find git-credential-manager binary after extraction"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$extracted_dir"
|
||||
print_status "Installing binary to $INSTALL_DIR..."
|
||||
sudo install -m 755 git-credential-manager "$INSTALL_DIR/git-credential-manager"
|
||||
|
||||
# Verify installation
|
||||
if [[ ! -f "$INSTALL_DIR/git-credential-manager" ]]; then
|
||||
print_error "Failed to install Git Credential Manager binary"
|
||||
return 1
|
||||
fi
|
||||
|
||||
sudo ln -sf "$INSTALL_DIR/git-credential-manager" "$INSTALL_DIR/git-credential-manager-core"
|
||||
fi
|
||||
|
||||
print_success "Binary installed successfully"
|
||||
}
|
||||
|
||||
# Function to check and configure Git presets
|
||||
configure_git_presets() {
|
||||
print_status "Checking and configuring Git presets..."
|
||||
|
||||
local presets_configured=0
|
||||
local presets_needed=()
|
||||
|
||||
# Check global credential helper
|
||||
local current_helper=""
|
||||
current_helper=$(git config --global --get credential.helper 2>/dev/null) || current_helper=""
|
||||
if [[ "$current_helper" == "manager" ]] || [[ "$current_helper" == "git-credential-manager" ]]; then
|
||||
print_success "✓ Global credential helper: $current_helper"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ Global credential helper not set to manager"
|
||||
presets_needed+=("git config --global credential.helper manager")
|
||||
fi
|
||||
|
||||
# Check GitHub-specific configuration
|
||||
local github_helper=""
|
||||
github_helper=$(git config --global --get credential.https://github.com.helper 2>/dev/null) || github_helper=""
|
||||
if [[ -n "$github_helper" ]]; then
|
||||
print_success "✓ GitHub credential helper configured ($github_helper)"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ GitHub credential helper not configured"
|
||||
presets_needed+=("git config --global credential.https://github.com.helper manager")
|
||||
fi
|
||||
|
||||
# Check GitLab-specific configuration
|
||||
local gitlab_helper=""
|
||||
gitlab_helper=$(git config --global --get credential.https://gitlab.com.helper 2>/dev/null) || gitlab_helper=""
|
||||
if [[ -n "$gitlab_helper" ]]; then
|
||||
print_success "✓ GitLab credential helper configured"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ GitLab credential helper not configured"
|
||||
presets_needed+=("git config --global credential.https://gitlab.com.helper manager")
|
||||
fi
|
||||
|
||||
# Check Azure DevOps configuration
|
||||
local azure_useHttpPath=""
|
||||
azure_useHttpPath=$(git config --global --get credential.https://dev.azure.com.useHttpPath 2>/dev/null) || azure_useHttpPath=""
|
||||
if [[ "$azure_useHttpPath" == "true" ]]; then
|
||||
print_success "✓ Azure DevOps useHttpPath configured"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ Azure DevOps useHttpPath not configured"
|
||||
presets_needed+=("git config --global credential.https://dev.azure.com.useHttpPath true")
|
||||
fi
|
||||
|
||||
# Check Bitbucket configuration
|
||||
local bitbucket_helper=""
|
||||
bitbucket_helper=$(git config --global --get credential.https://bitbucket.org.helper 2>/dev/null) || bitbucket_helper=""
|
||||
if [[ -n "$bitbucket_helper" ]]; then
|
||||
print_success "✓ Bitbucket credential helper configured"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ Bitbucket credential helper not configured"
|
||||
presets_needed+=("git config --global credential.https://bitbucket.org.helper manager")
|
||||
fi
|
||||
|
||||
# Check Gitea configuration (if any Gitea URL is configured)
|
||||
local gitea_urls=0
|
||||
gitea_urls=$(git config --global --get-regexp "credential.*gitea.*helper" 2>/dev/null | wc -l) || gitea_urls=0
|
||||
if [[ $gitea_urls -gt 0 ]]; then
|
||||
print_success "✓ Gitea credential helpers configured ($gitea_urls found)"
|
||||
presets_configured=$((presets_configured + 1))
|
||||
else
|
||||
print_warning "✗ No Gitea credential helpers configured"
|
||||
presets_needed+=("# For Gitea servers, configure domain-specific helper:")
|
||||
presets_needed+=("git config --global credential.https://go-gitea.mywire.org.helper manager")
|
||||
fi
|
||||
|
||||
# Summary
|
||||
echo
|
||||
print_status "Git Credential Manager Configuration Summary:"
|
||||
print_status "Presets configured: $presets_configured/6"
|
||||
|
||||
if [[ ${#presets_needed[@]} -eq 0 ]]; then
|
||||
print_success "All recommended presets are configured!"
|
||||
echo
|
||||
print_status "Your Git Credential Manager is fully configured and ready to use."
|
||||
echo "When you run Git commands that require authentication, GCM will:"
|
||||
echo "1. Prompt for credentials on first use"
|
||||
echo "2. Securely store them in your system's credential store"
|
||||
echo "3. Automatically provide them for subsequent operations"
|
||||
else
|
||||
print_warning "Some presets need to be configured manually."
|
||||
echo
|
||||
print_status "Run these commands to complete the configuration:"
|
||||
for cmd in "${presets_needed[@]}"; do
|
||||
echo " $cmd"
|
||||
done
|
||||
echo
|
||||
print_status "After configuring, test with:"
|
||||
echo " git config --global --list | grep credential"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to verify installation
|
||||
verify_installation() {
|
||||
print_status "Verifying installation..."
|
||||
|
||||
if command_exists git-credential-manager; then
|
||||
local version=$(git-credential-manager --version 2>/dev/null || echo "unknown")
|
||||
print_success "git-credential-manager installed: $version"
|
||||
|
||||
# Configure basic Git settings
|
||||
print_status "Configuring basic Git settings..."
|
||||
git config --global credential.helper manager
|
||||
print_success "Basic Git configuration completed"
|
||||
|
||||
# Check all presets
|
||||
configure_git_presets
|
||||
|
||||
# Check for user bin version and offer removal
|
||||
if [[ -f "$USER_BIN_DIR/git-credential-manager" ]]; then
|
||||
print_warning "Found git-credential-manager in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
echo
|
||||
read -p "Would you like to remove the user bin version? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
rm -f "$USER_BIN_DIR/git-credential-manager"
|
||||
print_success "Removed user bin version"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "git-credential-manager installation verification failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to cleanup
|
||||
cleanup() {
|
||||
if [[ -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
print_status "Cleaned up temporary files"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Git Credential Manager Installer"
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " -v, --version Install specific version (default: latest)"
|
||||
echo " -f, --force Force reinstall even if already installed"
|
||||
echo " -r, --reinstall Reinstall the current installed version"
|
||||
echo " -l, --local Force installation to user bin directory (~/.bin)"
|
||||
echo " -p, --package Force installation from package manager"
|
||||
echo " -d, --deb Force installation from DEB package"
|
||||
echo " -t, --tarball Force installation from tarball"
|
||||
echo " -c, --checks Check Git credential configuration without installing"
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " $0 # Install latest version using best method"
|
||||
echo " $0 -v v2.6.0 # Install specific version"
|
||||
echo " $0 --reinstall # Reinstall current version"
|
||||
echo " $0 --local # Force installation to user bin"
|
||||
echo " $0 --package # Force installation from package manager"
|
||||
echo " $0 --deb # Force installation from DEB package"
|
||||
echo " $0 --checks # Check configuration without installing"
|
||||
}
|
||||
|
||||
# Function to run configuration checks only
|
||||
run_checks_only() {
|
||||
echo "========================================"
|
||||
echo "Git Credential Manager Configuration Check"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# Check if GCM is installed
|
||||
if ! command_exists git-credential-manager; then
|
||||
print_error "Git Credential Manager is not installed"
|
||||
echo
|
||||
print_status "To install Git Credential Manager, run:"
|
||||
echo " $0"
|
||||
echo
|
||||
print_status "Or to check configuration after installation:"
|
||||
echo " $0 --checks"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run configuration checks
|
||||
configure_git_presets
|
||||
|
||||
echo
|
||||
print_success "Configuration check completed!"
|
||||
}
|
||||
|
||||
# Main installation function
|
||||
main() {
|
||||
local target_version=""
|
||||
local force_reinstall=false
|
||||
local reinstall_current=false
|
||||
local local_install=false
|
||||
local install_method="auto"
|
||||
local checks_only=false
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
target_version="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--force)
|
||||
force_reinstall=true
|
||||
shift
|
||||
;;
|
||||
-r|--reinstall)
|
||||
reinstall_current=true
|
||||
shift
|
||||
;;
|
||||
-l|--local)
|
||||
local_install=true
|
||||
shift
|
||||
;;
|
||||
-p|--package)
|
||||
install_method="package"
|
||||
shift
|
||||
;;
|
||||
-d|--deb)
|
||||
install_method="deb"
|
||||
shift
|
||||
;;
|
||||
-t|--tarball)
|
||||
install_method="tarball"
|
||||
shift
|
||||
;;
|
||||
-c|--checks)
|
||||
checks_only=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If checks only, run checks and exit
|
||||
if [[ "$checks_only" == "true" ]]; then
|
||||
run_checks_only
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "========================================"
|
||||
echo "Git Credential Manager Installer"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# Handle reinstall current version
|
||||
if [[ "$reinstall_current" == "true" ]]; then
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_error "No current version installed to reinstall"
|
||||
exit 1
|
||||
fi
|
||||
target_version="$current_version"
|
||||
force_reinstall=true
|
||||
print_status "Reinstalling current version: $target_version"
|
||||
fi
|
||||
|
||||
# Get latest version if not specified
|
||||
if [[ -z "$target_version" ]]; then
|
||||
get_latest_release
|
||||
target_version="$LATEST_VERSION"
|
||||
else
|
||||
print_status "Using specified version: $target_version"
|
||||
fi
|
||||
|
||||
# Check if update is needed
|
||||
if ! check_update_needed "$target_version"; then
|
||||
print_success "No installation needed. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Detect system
|
||||
detect_os
|
||||
ARCH=$(get_arch)
|
||||
|
||||
# Check for local installation
|
||||
if [[ "$local_install" == "true" ]]; then
|
||||
print_error "Git Credential Manager requires system installation for proper integration"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Installation logic based on method
|
||||
case $install_method in
|
||||
auto)
|
||||
# Try package manager first
|
||||
if install_from_package_manager; then
|
||||
verify_installation
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Fall back to distribution-specific methods
|
||||
case $OS in
|
||||
ubuntu|debian|linuxmint)
|
||||
install_from_deb "$ARCH" "$target_version"
|
||||
;;
|
||||
*)
|
||||
install_from_tarball "$ARCH" "$target_version"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
package)
|
||||
if ! install_from_package_manager; then
|
||||
print_error "Package manager installation failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
deb)
|
||||
install_from_deb "$ARCH" "$target_version"
|
||||
;;
|
||||
tarball)
|
||||
install_from_tarball "$ARCH" "$target_version"
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown install method: $install_method"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Verify installation
|
||||
if verify_installation; then
|
||||
echo
|
||||
print_success "Installation completed successfully!"
|
||||
echo
|
||||
print_status "Test the installation:"
|
||||
echo " git-credential-manager --version"
|
||||
echo " git config --global --list | grep credential"
|
||||
else
|
||||
print_error "Installation failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
611
install-tea-cli.sh
Executable file
611
install-tea-cli.sh
Executable file
@@ -0,0 +1,611 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Tea CLI Installer
|
||||
# Downloads and installs the latest Tea CLI binary
|
||||
# Supports multiple platforms and installation methods
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
GITEA_REPO="gitea.com/gitea/tea"
|
||||
USER_BIN_DIR="$HOME/bin"
|
||||
SYSTEM_INSTALL_DIR="/usr/local/bin"
|
||||
TEMP_DIR="/tmp/tea-install"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to detect OS and package manager
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS="$ID"
|
||||
OS_VERSION="$VERSION_ID"
|
||||
else
|
||||
print_error "Cannot detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect package manager
|
||||
if command_exists apt; then
|
||||
PKG_MANAGER="apt"
|
||||
elif command_exists yum; then
|
||||
PKG_MANAGER="yum"
|
||||
elif command_exists dnf; then
|
||||
PKG_MANAGER="dnf"
|
||||
elif command_exists pacman; then
|
||||
PKG_MANAGER="pacman"
|
||||
elif command_exists zypper; then
|
||||
PKG_MANAGER="zypper"
|
||||
else
|
||||
PKG_MANAGER="unknown"
|
||||
fi
|
||||
|
||||
print_status "Detected OS: $OS $OS_VERSION"
|
||||
print_status "Package manager: $PKG_MANAGER"
|
||||
}
|
||||
|
||||
# Function to get system architecture
|
||||
get_arch() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
x86_64)
|
||||
echo "amd64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
echo "arm64"
|
||||
;;
|
||||
armv7l)
|
||||
echo "arm"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to get current installed version and location
|
||||
get_current_version() {
|
||||
if command_exists tea; then
|
||||
CURRENT_VERSION=$(tea --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
if [[ -z "$CURRENT_VERSION" ]]; then
|
||||
CURRENT_VERSION="unknown"
|
||||
fi
|
||||
|
||||
# Determine installation location
|
||||
TEA_PATH=$(which tea)
|
||||
if [[ "$TEA_PATH" == "$USER_BIN_DIR"* ]]; then
|
||||
INSTALL_TYPE="user"
|
||||
elif [[ "$TEA_PATH" == "/usr/local/bin"* ]] || [[ "$TEA_PATH" == "/usr/bin"* ]]; then
|
||||
INSTALL_TYPE="system"
|
||||
else
|
||||
INSTALL_TYPE="other"
|
||||
fi
|
||||
else
|
||||
CURRENT_VERSION="not_installed"
|
||||
INSTALL_TYPE="none"
|
||||
fi
|
||||
echo "$CURRENT_VERSION:$INSTALL_TYPE"
|
||||
}
|
||||
|
||||
# Function to check if user bin directory exists and is in PATH
|
||||
check_user_bin_setup() {
|
||||
if [[ ! -d "$USER_BIN_DIR" ]]; then
|
||||
print_status "User bin directory doesn't exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if user bin is in PATH
|
||||
if [[ ":$PATH:" != *":$USER_BIN_DIR:"* ]]; then
|
||||
print_warning "User bin directory ($USER_BIN_DIR) is not in PATH"
|
||||
print_status "Add to PATH: export PATH=\"$USER_BIN_DIR:\$PATH\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to check for version-specific symlink
|
||||
check_version_symlink() {
|
||||
local tea_path=$(which tea 2>/dev/null)
|
||||
if [[ -z "$tea_path" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if it's a symlink
|
||||
if [[ -L "$tea_path" ]]; then
|
||||
SYMLINK_TARGET=$(readlink "$tea_path")
|
||||
# Extract version from symlink target
|
||||
if [[ "$SYMLINK_TARGET" =~ tea-(v?[0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
||||
CURRENT_SYMLINK_VERSION="${BASH_REMATCH[1]}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to determine installation strategy
|
||||
determine_install_strategy() {
|
||||
local local_install="$1"
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
# Strategy: Check installation type preference
|
||||
if [[ "$local_install" == "true" ]]; then
|
||||
print_status "Local installation requested"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
else
|
||||
print_error "User bin directory not available for local installation"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
print_status "Running as root, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
elif sudo -n true 2>/dev/null; then
|
||||
print_status "Passwordless sudo available, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
elif command_exists sudo; then
|
||||
print_status "Testing sudo access (you may be prompted for password)..."
|
||||
if sudo -v 2>/dev/null; then
|
||||
print_success "Sudo access confirmed, installing system-wide"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
else
|
||||
print_error "Sudo access failed. Use --local to install to user bin directory"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_error "Sudo not available. Use --local to install to user bin directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Warn if user bin has tea (only for system installs)
|
||||
if [[ "$INSTALL_STRATEGY" == "system_install" ]] && [[ -f "$USER_BIN_DIR/tea" ]]; then
|
||||
print_warning "Tea CLI found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_status "Installation strategy: $INSTALL_STRATEGY"
|
||||
print_status "Target directory: $TARGET_DIR"
|
||||
}
|
||||
|
||||
# Function to compare versions
|
||||
compare_versions() {
|
||||
local version1="$1"
|
||||
local version2="$2"
|
||||
|
||||
# Remove 'v' prefix if present
|
||||
version1=${version1#v}
|
||||
version2=${version2#v}
|
||||
|
||||
# Split versions into arrays
|
||||
IFS='.' read -ra V1 <<< "$version1"
|
||||
IFS='.' read -ra V2 <<< "$version2"
|
||||
|
||||
# Compare major, minor, patch
|
||||
for i in {0..2}; do
|
||||
local v1=${V1[$i]:-0}
|
||||
local v2=${V2[$i]:-0}
|
||||
|
||||
if (( v1 > v2 )); then
|
||||
return 0 # version1 > version2
|
||||
elif (( v1 < v2 )); then
|
||||
return 1 # version1 < version2
|
||||
fi
|
||||
done
|
||||
|
||||
return 0 # versions are equal
|
||||
}
|
||||
|
||||
# Function to get latest release info
|
||||
get_latest_release() {
|
||||
print_status "Fetching latest Tea CLI release information..."
|
||||
|
||||
if command_exists curl; then
|
||||
RELEASE_INFO=$(curl -s "https://gitea.com/api/v1/repos/gitea/tea/releases/latest")
|
||||
elif command_exists wget; then
|
||||
RELEASE_INFO=$(wget -qO- "https://gitea.com/api/v1/repos/gitea/tea/releases/latest")
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$RELEASE_INFO" ]]; then
|
||||
print_error "Failed to fetch release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract version and download URLs
|
||||
LATEST_VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": *"[^"]*"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [[ -z "$LATEST_VERSION" ]]; then
|
||||
print_error "Failed to parse release information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Latest version: $LATEST_VERSION"
|
||||
}
|
||||
|
||||
# Function to check if update is needed
|
||||
check_update_needed() {
|
||||
local latest_version="$1"
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
print_status "Current version: $current_version ($install_type)"
|
||||
print_status "Latest version: $latest_version"
|
||||
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_status "Tea CLI is not installed"
|
||||
return 0 # Need to install
|
||||
fi
|
||||
|
||||
if [[ "$current_version" == "unknown" ]]; then
|
||||
print_warning "Cannot determine current version, proceeding with update"
|
||||
return 0 # Assume update needed
|
||||
fi
|
||||
|
||||
# Clean version strings for comparison
|
||||
local clean_current="${current_version#v}"
|
||||
local clean_latest="${latest_version#v}"
|
||||
|
||||
if compare_versions "$clean_latest" "$clean_current"; then
|
||||
if [[ "$clean_latest" == "$clean_current" ]]; then
|
||||
print_success "You already have the latest version ($current_version) installed at $install_type location"
|
||||
if [[ "$force_reinstall" == "true" ]]; then
|
||||
print_status "Force reinstall requested, proceeding..."
|
||||
return 0
|
||||
else
|
||||
return 1 # No update needed
|
||||
fi
|
||||
else
|
||||
print_status "Newer version available: $latest_version > $current_version"
|
||||
return 0 # Update needed
|
||||
fi
|
||||
else
|
||||
print_success "Your version ($current_version) is newer than latest release ($latest_version)"
|
||||
return 1 # No update needed
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download file
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local filename="$2"
|
||||
|
||||
print_status "Downloading $filename..."
|
||||
|
||||
if command_exists curl; then
|
||||
curl -L -o "$TEMP_DIR/$filename" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$TEMP_DIR/$filename" "$url"
|
||||
else
|
||||
print_error "curl or wget is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$TEMP_DIR/$filename" ]]; then
|
||||
print_error "Failed to download $filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_success "Downloaded $filename"
|
||||
}
|
||||
|
||||
# Function to install Tea CLI from package manager
|
||||
install_tea_from_package_manager() {
|
||||
# Package manager installation is not reliable for Tea CLI, use binary instead
|
||||
print_warning "Package manager installation not supported for Tea CLI to ensure correct version, using binary instead"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to install Tea CLI from binary
|
||||
install_tea_from_binary() {
|
||||
local arch="$1"
|
||||
local version="$2"
|
||||
|
||||
local binary_name="tea-${version#v}-linux-${arch}"
|
||||
local download_url="https://gitea.com/gitea/tea/releases/download/$version/$binary_name"
|
||||
|
||||
download_file "$download_url" "$binary_name"
|
||||
|
||||
# Determine installation command based on target directory
|
||||
local install_cmd="install -m 755"
|
||||
local symlink_cmd="ln -sf"
|
||||
|
||||
if [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
install_cmd="sudo $install_cmd"
|
||||
symlink_cmd="sudo $symlink_cmd"
|
||||
fi
|
||||
|
||||
print_status "Installing Tea CLI binary to $TARGET_DIR..."
|
||||
|
||||
# Install the binary with version suffix
|
||||
$install_cmd "$TEMP_DIR/$binary_name" "$TARGET_DIR/tea-$version"
|
||||
|
||||
# Verify installation
|
||||
if [[ ! -f "$TARGET_DIR/tea-$version" ]]; then
|
||||
print_error "Failed to install Tea CLI binary"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Remove any existing tea symlink or file to avoid conflicts
|
||||
rm -f "$TARGET_DIR/tea"
|
||||
|
||||
# Create/update symlink to point to this version
|
||||
$symlink_cmd "$TARGET_DIR/tea-$version" "$TARGET_DIR/tea"
|
||||
|
||||
print_success "Tea CLI binary installed successfully"
|
||||
print_status "Version symlink: tea -> tea-$version"
|
||||
}
|
||||
|
||||
# Function to verify Tea CLI installation
|
||||
verify_tea_installation() {
|
||||
print_status "Verifying Tea CLI installation..."
|
||||
|
||||
if command_exists tea; then
|
||||
local version=$(tea --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
print_success "Tea CLI installed: $version"
|
||||
|
||||
# Check for user bin versions and offer removal
|
||||
if [[ -d "$USER_BIN_DIR" ]] && [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
local user_versions=()
|
||||
for file in "$USER_BIN_DIR"/tea*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
user_versions+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#user_versions[@]} -gt 0 ]]; then
|
||||
print_warning "Found tea binaries in user bin directory:"
|
||||
for file in "${user_versions[@]}"; do
|
||||
echo " $file"
|
||||
done
|
||||
echo
|
||||
read -p "Would you like to remove these user bin versions? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for file in "${user_versions[@]}"; do
|
||||
rm -f "$file"
|
||||
print_status "Removed $file"
|
||||
done
|
||||
print_success "Removed all user bin versions"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Tea CLI installation verification failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to cleanup
|
||||
cleanup() {
|
||||
if [[ -d "$TEMP_DIR" ]]; then
|
||||
rm -rf "$TEMP_DIR"
|
||||
print_status "Cleaned up temporary files"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show usage
|
||||
show_usage() {
|
||||
echo "Tea CLI Installer"
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " -v, --version Install specific version (default: latest)"
|
||||
echo " -f, --force Force reinstall even if up-to-date"
|
||||
echo " -r, --reinstall Reinstall the current installed version"
|
||||
echo " -l, --local Force installation to user bin directory (~/.bin)"
|
||||
echo " -p, --package Force installation from package manager"
|
||||
echo " -b, --binary Force installation from binary"
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " $0 # Install latest version using best method"
|
||||
echo " $0 -v v0.10.0 # Install specific version"
|
||||
echo " $0 --reinstall # Reinstall current version"
|
||||
echo " $0 --local # Force installation to user bin"
|
||||
echo " $0 --package # Force installation from package manager"
|
||||
echo " $0 --binary # Force installation from binary"
|
||||
echo
|
||||
}
|
||||
|
||||
# Main installation function
|
||||
main() {
|
||||
local target_version=""
|
||||
local force_reinstall=false
|
||||
local reinstall_current=false
|
||||
local local_install=false
|
||||
local install_method="auto"
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
target_version="$2"
|
||||
shift 2
|
||||
;;
|
||||
-f|--force)
|
||||
force_reinstall=true
|
||||
shift
|
||||
;;
|
||||
-r|--reinstall)
|
||||
reinstall_current=true
|
||||
shift
|
||||
;;
|
||||
-l|--local)
|
||||
local_install=true
|
||||
shift
|
||||
;;
|
||||
-p|--package)
|
||||
install_method="package"
|
||||
shift
|
||||
;;
|
||||
-b|--binary)
|
||||
install_method="binary"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "========================================"
|
||||
echo "Tea CLI Installer"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# Check if running as root for system installation
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_warning "Not running as root. Some operations may require sudo."
|
||||
fi
|
||||
|
||||
# Detect system
|
||||
detect_os
|
||||
ARCH=$(get_arch)
|
||||
|
||||
# Handle reinstall current version
|
||||
if [[ "$reinstall_current" == "true" ]]; then
|
||||
local current_info=$(get_current_version)
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
if [[ "$current_version" == "not_installed" ]]; then
|
||||
print_error "No current version installed to reinstall"
|
||||
exit 1
|
||||
fi
|
||||
target_version="$current_version"
|
||||
force_reinstall=true
|
||||
print_status "Reinstalling current version: $target_version"
|
||||
fi
|
||||
|
||||
# Get latest version if not specified
|
||||
if [[ -z "$target_version" ]]; then
|
||||
get_latest_release
|
||||
target_version="$LATEST_VERSION"
|
||||
else
|
||||
print_status "Using specified version: $target_version"
|
||||
fi
|
||||
|
||||
# Determine installation strategy
|
||||
determine_install_strategy "$local_install"
|
||||
|
||||
# Check if update is needed
|
||||
if ! check_update_needed "$target_version"; then
|
||||
print_success "No installation needed. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create temporary directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
# Trap cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Installation logic based on method and strategy
|
||||
case $install_method in
|
||||
auto)
|
||||
# For user installations, prefer binary over package manager
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
print_status "Using binary installation for user directory"
|
||||
install_tea_from_binary "$ARCH" "$target_version"
|
||||
verify_tea_installation
|
||||
else
|
||||
# Try package manager first for system installations
|
||||
if install_tea_from_package_manager; then
|
||||
verify_tea_installation
|
||||
else
|
||||
install_tea_from_binary "$ARCH" "$target_version"
|
||||
verify_tea_installation
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
package)
|
||||
if ! install_tea_from_package_manager; then
|
||||
print_error "Package manager installation failed"
|
||||
exit 1
|
||||
fi
|
||||
verify_tea_installation
|
||||
;;
|
||||
binary)
|
||||
install_tea_from_binary "$ARCH" "$target_version"
|
||||
verify_tea_installation
|
||||
;;
|
||||
esac
|
||||
|
||||
# Installation completed successfully
|
||||
echo
|
||||
print_success "Installation completed successfully!"
|
||||
echo
|
||||
echo "Installation details:"
|
||||
echo "- Strategy: $INSTALL_STRATEGY"
|
||||
echo "- Location: $TARGET_DIR"
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "- Binary: tea (symlink to tea-$target_version)"
|
||||
echo "- Version: $target_version"
|
||||
fi
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo "1. Test installation: tea --version"
|
||||
echo "2. Configure login: tea login add"
|
||||
echo "3. Use Tea CLI: tea --help"
|
||||
echo
|
||||
if [[ "$INSTALL_STRATEGY" == user* ]]; then
|
||||
echo "User-specific installation notes:"
|
||||
echo "- Binary installed in: $USER_BIN_DIR"
|
||||
echo "- Ensure $USER_BIN_DIR is in your PATH"
|
||||
echo "- You can have multiple versions side-by-side"
|
||||
fi
|
||||
echo
|
||||
echo "For more information, visit: https://gitea.com/gitea/tea"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
@@ -15,7 +15,6 @@ NC='\033[0m' # No Color
|
||||
|
||||
# Configuration file path
|
||||
CONFIG_FILE="$(dirname "$0")/config.json"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
@@ -38,6 +37,91 @@ command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to install Git Credential Manager if needed
|
||||
install_credential_manager() {
|
||||
local script_dir="$(dirname "$0")"
|
||||
local installer="$script_dir/install-git-credential-manager.sh"
|
||||
|
||||
if [[ -f "$installer" ]]; then
|
||||
print_status "Running Git Credential Manager installer..."
|
||||
"$installer"
|
||||
return $?
|
||||
else
|
||||
print_warning "Git Credential Manager installer not found at $installer"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install Tea CLI if needed
|
||||
install_tea_cli() {
|
||||
local script_dir="$(dirname "$0")"
|
||||
local installer="$script_dir/install-tea-cli.sh"
|
||||
|
||||
if [[ -f "$installer" ]]; then
|
||||
print_status "Running Tea CLI installer..."
|
||||
"$installer"
|
||||
return $?
|
||||
else
|
||||
print_warning "Tea CLI installer not found at $installer"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to detect and configure credential manager
|
||||
setup_credential_manager() {
|
||||
print_status "Checking for Git credential managers..."
|
||||
|
||||
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 "Continuing without credential manager - you will be prompted for credentials"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure credential helper for the specific Gitea instance
|
||||
if [[ -n "$GITEA_URL" ]]; then
|
||||
local domain=$(echo "$GITEA_URL" | sed 's|https://||' | sed 's|http://||')
|
||||
git config --global credential."https://$domain".helper "$credential_helper"
|
||||
print_success "Configured credential manager for $domain"
|
||||
else
|
||||
git config --global credential.helper "$credential_helper"
|
||||
print_success "Configured global credential manager"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to validate input
|
||||
validate_input() {
|
||||
if [[ -z "$1" ]]; then
|
||||
@@ -113,73 +197,71 @@ setup_ssh_key() {
|
||||
|
||||
# Function to setup tea CLI
|
||||
setup_tea() {
|
||||
print_status "Setting up tea CLI..."
|
||||
|
||||
print_status "Setting up Tea CLI..."
|
||||
|
||||
if ! command_exists tea; then
|
||||
print_status "Installing tea CLI..."
|
||||
|
||||
# Detect OS and install tea
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Linux
|
||||
if command_exists apt; then
|
||||
# Try to install from package manager first
|
||||
sudo apt update && sudo apt install -y tea || {
|
||||
print_warning "tea not available in package manager, installing from binary..."
|
||||
curl -sL https://dl.gitea.com/tea/latest/tea-linux-amd64 -o /tmp/tea
|
||||
chmod +x /tmp/tea
|
||||
sudo mv /tmp/tea /usr/local/bin/tea
|
||||
}
|
||||
elif command_exists yum; then
|
||||
sudo yum install -y tea || {
|
||||
print_warning "tea not available in package manager, installing from binary..."
|
||||
curl -sL https://dl.gitea.com/tea/latest/tea-linux-amd64 -o /tmp/tea
|
||||
chmod +x /tmp/tea
|
||||
sudo mv /tmp/tea /usr/local/bin/tea
|
||||
}
|
||||
elif command_exists pacman; then
|
||||
sudo pacman -S --noconfirm tea || {
|
||||
print_warning "tea not available in package manager, installing from binary..."
|
||||
curl -sL https://dl.gitea.com/tea/latest/tea-linux-amd64 -o /tmp/tea
|
||||
chmod +x /tmp/tea
|
||||
sudo mv /tmp/tea /usr/local/bin/tea
|
||||
}
|
||||
print_warning "Tea CLI is not installed"
|
||||
|
||||
# Offer to install Tea CLI
|
||||
echo
|
||||
read -p "Would you like to install Tea CLI for Gitea repository management? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
if install_tea_cli; then
|
||||
print_success "Tea CLI installed successfully"
|
||||
else
|
||||
# Generic Linux installation
|
||||
curl -sL https://dl.gitea.com/tea/latest/tea-linux-amd64 -o /tmp/tea
|
||||
chmod +x /tmp/tea
|
||||
sudo mv /tmp/tea /usr/local/bin/tea
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
if command_exists brew; then
|
||||
brew install tea
|
||||
else
|
||||
print_error "Homebrew not found. Please install Homebrew first."
|
||||
exit 1
|
||||
print_error "Failed to install Tea CLI"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print_error "Unsupported OS for automatic tea installation"
|
||||
exit 1
|
||||
print_warning "Continuing without Tea CLI - you can install it later with ./install-tea-cli.sh"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print_success "tea CLI installed successfully"
|
||||
else
|
||||
print_success "tea CLI is already installed"
|
||||
print_success "Tea CLI is already installed"
|
||||
fi
|
||||
|
||||
|
||||
# Configure tea login with presets
|
||||
print_status "Configuring tea login..."
|
||||
|
||||
print_status "Configuring Tea CLI login..."
|
||||
|
||||
# Use defaults from config if available
|
||||
local tea_url="${GITEA_URL:-$GITEA_URL}"
|
||||
local tea_method="${LOGIN_METHOD:-token}"
|
||||
local tea_has_token="${HAS_ACCESS_TOKEN:-true}"
|
||||
|
||||
|
||||
echo "Using preset configuration:"
|
||||
echo "- URL: $tea_url"
|
||||
echo "- Method: $tea_method"
|
||||
echo "- Has token: $tea_has_token"
|
||||
echo
|
||||
|
||||
# Check for existing logins
|
||||
print_status "Checking existing Tea CLI logins..."
|
||||
if tea logins 2>/dev/null | grep -q "No logins"; then
|
||||
echo "No existing logins found. Creating new login..."
|
||||
tea login add
|
||||
else
|
||||
echo "Existing logins found:"
|
||||
tea logins
|
||||
echo
|
||||
read -p "Do you want to use an existing login? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
read -p "Enter the name of the existing login to use: " existing_login
|
||||
if tea logins | grep -q "$existing_login"; then
|
||||
print_success "Using existing login: $existing_login"
|
||||
# Set the existing login as default for this session
|
||||
export TEA_LOGIN="$existing_login"
|
||||
else
|
||||
print_warning "Login '$existing_login' not found. Creating new login..."
|
||||
tea login add
|
||||
fi
|
||||
else
|
||||
echo "Creating new login..."
|
||||
tea login add
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for existing logins
|
||||
print_status "Checking existing tea logins..."
|
||||
@@ -331,13 +413,13 @@ main() {
|
||||
echo "Git Repository Setup Script for Gitea"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
|
||||
# Check if git is installed
|
||||
if ! command_exists git; then
|
||||
print_error "Git is not installed. Please install Git first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Load configuration if available
|
||||
CONFIG_LOADED=false
|
||||
if load_config; then
|
||||
@@ -383,8 +465,8 @@ main() {
|
||||
|
||||
echo
|
||||
echo "Choose authentication method:"
|
||||
echo "1) SSH (recommended - passwordless after setup)"
|
||||
echo "2) HTTPS (may prompt for password/token)"
|
||||
echo "1) SSH (recommended - passwordless after key setup)"
|
||||
echo "2) HTTPS with credential manager (secure, stores tokens)"
|
||||
echo "3) Tea CLI (creates repo via API)"
|
||||
|
||||
# Use default auth method from config if available
|
||||
@@ -410,8 +492,23 @@ main() {
|
||||
2)
|
||||
AUTH_METHOD="https"
|
||||
print_status "HTTPS authentication selected"
|
||||
|
||||
# Setup credential manager for passwordless authentication
|
||||
if setup_credential_manager; then
|
||||
print_success "Credential manager configured for passwordless HTTPS access"
|
||||
echo "You will be prompted for credentials on first use, then they will be stored securely."
|
||||
else
|
||||
print_warning "No credential manager available. You will be prompted for credentials each time."
|
||||
echo "Consider installing git-credential-manager for secure credential storage."
|
||||
fi
|
||||
|
||||
REMOTE_URL="$GITEA_URL/$GITEA_USERNAME/$REPO_NAME.git"
|
||||
print_warning "Make sure you have an access token or will be prompted for credentials"
|
||||
echo
|
||||
echo "HTTPS Authentication Setup:"
|
||||
echo "1. Generate a Personal Access Token in Gitea: User Settings → Applications"
|
||||
echo "2. Use your username and the access token when prompted"
|
||||
echo "3. Credentials will be stored securely by your credential manager"
|
||||
echo
|
||||
;;
|
||||
3)
|
||||
AUTH_METHOD="tea"
|
||||
@@ -454,6 +551,11 @@ main() {
|
||||
echo "SSH setup reminder:"
|
||||
echo "- Make sure your SSH public key is added to your Gitea account"
|
||||
echo "- SSH key location: $HOME/.ssh/id_ed25519.pub"
|
||||
elif [[ "$AUTH_METHOD" == "https" ]]; then
|
||||
echo "HTTPS setup reminder:"
|
||||
echo "- Use your Personal Access Token as password when prompted"
|
||||
echo "- Credentials are stored securely by your credential manager"
|
||||
echo "- Generate tokens at: $GITEA_URL/user/settings/applications"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user