chore: sync: ClausL-MacBook-Pro.local 2026-05-04 17:55

This commit is contained in:
Claus Lohmar 2026-05-04 17:55:10 +01:00
parent ad26c899b9
commit d6307ed19b

View file

@ -12,7 +12,7 @@ set -e
# #
# Usage: # Usage:
# curl -fsSL https://github.com/yourusername/authelia-api/install.sh | sudo bash # curl -fsSL https://github.com/yourusername/authelia-api/install.sh | sudo bash
# #
# For development/testing: # For development/testing:
# cd /home/authelia/dev # cd /home/authelia/dev
# sudo ./install-authelia-api.sh # sudo ./install-authelia-api.sh
@ -30,7 +30,7 @@ NC='\033[0m' # No Color
# Configuration # Configuration
# Update REPO_URL to your actual GitHub repository before distribution # Update REPO_URL to your actual GitHub repository before distribution
REPO_URL="https://github.com/yourusername/authelia-api" REPO_URL="https://git.lohmar.co.uk/cclohmar/autehlia-api"
DOWNLOAD_URL="${AUTHELIA_API_DOWNLOAD_URL:-${REPO_URL}/releases/latest/download/authelia-api}" DOWNLOAD_URL="${AUTHELIA_API_DOWNLOAD_URL:-${REPO_URL}/releases/latest/download/authelia-api}"
INSTALL_DIR="${AUTHELIA_API_INSTALL_DIR:-/opt/authelia/api}" INSTALL_DIR="${AUTHELIA_API_INSTALL_DIR:-/opt/authelia/api}"
SERVICE_NAME="authelia-api" SERVICE_NAME="authelia-api"
@ -87,11 +87,11 @@ print_step() {
run_command() { run_command() {
local cmd="$1" local cmd="$1"
local desc="$2" local desc="$2"
if [ "$NEED_SUDO" = true ] && [ "$IS_ROOT" = false ]; then if [ "$NEED_SUDO" = true ] && [ "$IS_ROOT" = false ]; then
cmd="sudo $cmd" cmd="sudo $cmd"
fi fi
print_info "$desc" print_info "$desc"
eval "$cmd" eval "$cmd"
} }
@ -99,16 +99,16 @@ run_command() {
ask_confirm() { ask_confirm() {
local prompt="$1" local prompt="$1"
local default="${2:-y}" local default="${2:-y}"
if [ "$default" = "y" ]; then if [ "$default" = "y" ]; then
prompt="$prompt [Y/n]: " prompt="$prompt [Y/n]: "
else else
prompt="$prompt [y/N]: " prompt="$prompt [y/N]: "
fi fi
read -r -p "$prompt" response read -r -p "$prompt" response
response=${response:-$default} response=${response:-$default}
if [[ $response =~ ^[Yy]$ ]]; then if [[ $response =~ ^[Yy]$ ]]; then
return 0 return 0
else else
@ -122,7 +122,7 @@ ask_confirm() {
detect_system() { detect_system() {
print_step "Detecting system..." print_step "Detecting system..."
# Check if running as root # Check if running as root
if [ "$EUID" -eq 0 ]; then if [ "$EUID" -eq 0 ]; then
IS_ROOT=true IS_ROOT=true
@ -139,7 +139,7 @@ detect_system() {
exit 1 exit 1
fi fi
fi fi
# Detect distribution # Detect distribution
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
@ -158,7 +158,7 @@ detect_system() {
print_warning "Could not detect distribution, assuming generic Linux" print_warning "Could not detect distribution, assuming generic Linux"
DISTRO="linux" DISTRO="linux"
fi fi
# Detect architecture # Detect architecture
ARCH=$(uname -m) ARCH=$(uname -m)
case "$ARCH" in case "$ARCH" in
@ -181,14 +181,14 @@ detect_system() {
check_dependencies() { check_dependencies() {
print_step "Checking dependencies..." print_step "Checking dependencies..."
local missing_deps=() local missing_deps=()
# Check for curl (needed for binary download) # Check for curl (needed for binary download)
if ! command -v curl &> /dev/null; then if ! command -v curl &> /dev/null; then
missing_deps+=("curl") missing_deps+=("curl")
fi fi
# Check for authelia binary # Check for authelia binary
if ! command -v authelia &> /dev/null && [ ! -f /opt/authelia/authelia ]; then if ! command -v authelia &> /dev/null && [ ! -f /opt/authelia/authelia ]; then
print_warning "Authelia binary not found in PATH or /opt/authelia/authelia" print_warning "Authelia binary not found in PATH or /opt/authelia/authelia"
@ -197,10 +197,10 @@ check_dependencies() {
exit 1 exit 1
fi fi
fi fi
if [ ${#missing_deps[@]} -ne 0 ]; then if [ ${#missing_deps[@]} -ne 0 ]; then
print_error "Missing dependencies: ${missing_deps[*]}" print_error "Missing dependencies: ${missing_deps[*]}"
if [ "$DISTRO" = "debian" ] || [ "$DISTRO" = "ubuntu" ]; then if [ "$DISTRO" = "debian" ] || [ "$DISTRO" = "ubuntu" ]; then
run_command "apt-get update" "Updating package list" run_command "apt-get update" "Updating package list"
run_command "apt-get install -y ${missing_deps[*]}" "Installing missing dependencies" run_command "apt-get install -y ${missing_deps[*]}" "Installing missing dependencies"
@ -213,7 +213,7 @@ check_dependencies() {
exit 1 exit 1
fi fi
fi fi
print_success "All dependencies satisfied" print_success "All dependencies satisfied"
} }
@ -223,7 +223,7 @@ check_dependencies() {
create_user() { create_user() {
print_step "Checking service user..." print_step "Checking service user..."
# Detect Authelia service user # Detect Authelia service user
local authelia_service_file="/etc/systemd/system/authelia.service" local authelia_service_file="/etc/systemd/system/authelia.service"
if [ -f "$authelia_service_file" ]; then if [ -f "$authelia_service_file" ]; then
@ -235,48 +235,48 @@ create_user() {
return 0 return 0
fi fi
fi fi
# Default to authelia user # Default to authelia user
print_info "Authelia service user not found, using default: $USER" print_info "Authelia service user not found, using default: $USER"
# Check if user exists # Check if user exists
if id "$USER" &>/dev/null; then if id "$USER" &>/dev/null; then
print_success "User '$USER' already exists" print_success "User '$USER' already exists"
else else
print_info "Creating user '$USER'" print_info "Creating user '$USER'"
if [ "$DISTRO" = "alpine" ]; then if [ "$DISTRO" = "alpine" ]; then
run_command "adduser -D -s /bin/false $USER" "Creating system user" run_command "adduser -D -s /bin/false $USER" "Creating system user"
else else
run_command "useradd -r -s /bin/false -M $USER" "Creating system user" run_command "useradd -r -s /bin/false -M $USER" "Creating system user"
fi fi
print_success "User '$USER' created" print_success "User '$USER' created"
fi fi
} }
prepare_installation_directory() { prepare_installation_directory() {
print_step "Preparing installation directory..." print_step "Preparing installation directory..."
# Create installation directory # Create installation directory
if [ ! -d "$INSTALL_DIR" ]; then if [ ! -d "$INSTALL_DIR" ]; then
run_command "mkdir -p $INSTALL_DIR" "Creating installation directory" run_command "mkdir -p $INSTALL_DIR" "Creating installation directory"
else else
print_info "Installation directory already exists: $INSTALL_DIR" print_info "Installation directory already exists: $INSTALL_DIR"
fi fi
# Set permissions # Set permissions
run_command "chown -R $USER:$USER $INSTALL_DIR" "Setting ownership" run_command "chown -R $USER:$USER $INSTALL_DIR" "Setting ownership"
run_command "chmod 755 $INSTALL_DIR" "Setting directory permissions" run_command "chmod 755 $INSTALL_DIR" "Setting directory permissions"
print_success "Installation directory ready: $INSTALL_DIR" print_success "Installation directory ready: $INSTALL_DIR"
} }
download_binary() { download_binary() {
print_step "Downloading Authelia API binary..." print_step "Downloading Authelia API binary..."
local binary_dest="$INSTALL_DIR/authelia-api" local binary_dest="$INSTALL_DIR/authelia-api"
if [ "$DEVELOPMENT_MODE" = true ]; then if [ "$DEVELOPMENT_MODE" = true ]; then
if [ -f "$LOCAL_BINARY_PATH" ]; then if [ -f "$LOCAL_BINARY_PATH" ]; then
print_info "Development mode: Using local binary" print_info "Development mode: Using local binary"
@ -293,11 +293,11 @@ download_binary() {
DEVELOPMENT_MODE=false DEVELOPMENT_MODE=false
fi fi
fi fi
if [ "$DEVELOPMENT_MODE" = false ]; then if [ "$DEVELOPMENT_MODE" = false ]; then
# Construct download URL with architecture # Construct download URL with architecture
local download_url="${DOWNLOAD_URL}_linux_${ARCH}" local download_url="${DOWNLOAD_URL}_linux_${ARCH}"
print_info "Downloading from: $download_url" print_info "Downloading from: $download_url"
if command -v curl &> /dev/null; then if command -v curl &> /dev/null; then
run_command "curl -fsSL -o '$binary_dest' '$download_url'" "Downloading binary" run_command "curl -fsSL -o '$binary_dest' '$download_url'" "Downloading binary"
@ -306,15 +306,15 @@ download_binary() {
exit 1 exit 1
fi fi
fi fi
# Make binary executable # Make binary executable
run_command "chmod +x '$binary_dest'" "Making binary executable" run_command "chmod +x '$binary_dest'" "Making binary executable"
run_command "chown $USER:$USER '$binary_dest'" "Setting binary ownership" run_command "chown $USER:$USER '$binary_dest'" "Setting binary ownership"
# Verify binary # Verify binary
if [ -f "$binary_dest" ] && [ -x "$binary_dest" ]; then if [ -f "$binary_dest" ] && [ -x "$binary_dest" ]; then
print_success "Binary downloaded and ready: $binary_dest" print_success "Binary downloaded and ready: $binary_dest"
# Test binary version # Test binary version
if "$binary_dest" --version &>/dev/null; then if "$binary_dest" --version &>/dev/null; then
local version=$("$binary_dest" --version 2>/dev/null || echo "unknown") local version=$("$binary_dest" --version 2>/dev/null || echo "unknown")
@ -328,18 +328,18 @@ download_binary() {
download_source_files() { download_source_files() {
print_step "Downloading source files and documentation..." print_step "Downloading source files and documentation..."
local source_dir="$INSTALL_DIR/src" local source_dir="$INSTALL_DIR/src"
# Create source directory # Create source directory
if [ ! -d "$source_dir" ]; then if [ ! -d "$source_dir" ]; then
run_command "mkdir -p $source_dir" "Creating source directory" run_command "mkdir -p $source_dir" "Creating source directory"
fi fi
# For development, copy existing source files # For development, copy existing source files
if [ "$DEVELOPMENT_MODE" = true ]; then if [ "$DEVELOPMENT_MODE" = true ]; then
print_info "Development mode: Using existing source files" print_info "Development mode: Using existing source files"
# If source directory already exists in install location, skip copying # If source directory already exists in install location, skip copying
if [ -d "$INSTALL_DIR/src" ] && [ "$INSTALL_DIR/src" != "$source_dir" ]; then if [ -d "$INSTALL_DIR/src" ] && [ "$INSTALL_DIR/src" != "$source_dir" ]; then
print_info "Source directory already exists at installation location" print_info "Source directory already exists at installation location"
@ -347,7 +347,7 @@ download_source_files() {
print_info "Copying source files from development location" print_info "Copying source files from development location"
cp -r "$LOCAL_SOURCE_PATH"/* "$source_dir/" 2>/dev/null || true cp -r "$LOCAL_SOURCE_PATH"/* "$source_dir/" 2>/dev/null || true
fi fi
# Also copy root README if it exists (from dev directory) # Also copy root README if it exists (from dev directory)
if [ -f "/home/authelia/dev/README.md" ] && [ "/home/authelia/dev/README.md" != "$source_dir/ROOT_README.md" ]; then if [ -f "/home/authelia/dev/README.md" ] && [ "/home/authelia/dev/README.md" != "$source_dir/ROOT_README.md" ]; then
cp "/home/authelia/dev/README.md" "$source_dir/ROOT_README.md" cp "/home/authelia/dev/README.md" "$source_dir/ROOT_README.md"
@ -356,7 +356,7 @@ download_source_files() {
# In production, download source archive # In production, download source archive
local source_url="${REPO_URL}/archive/refs/heads/main.tar.gz" local source_url="${REPO_URL}/archive/refs/heads/main.tar.gz"
local temp_file="/tmp/authelia-api-src.tar.gz" local temp_file="/tmp/authelia-api-src.tar.gz"
print_info "Downloading source files from GitHub" print_info "Downloading source files from GitHub"
if command -v curl &> /dev/null; then if command -v curl &> /dev/null; then
run_command "curl -fsSL -o '$temp_file' '$source_url'" "Downloading source archive" run_command "curl -fsSL -o '$temp_file' '$source_url'" "Downloading source archive"
@ -366,19 +366,19 @@ download_source_files() {
print_warning "curl not available, skipping source download" print_warning "curl not available, skipping source download"
fi fi
fi fi
# Set permissions on source directory # Set permissions on source directory
run_command "chown -R $USER:$USER '$source_dir'" "Setting source directory ownership" run_command "chown -R $USER:$USER '$source_dir'" "Setting source directory ownership"
run_command "chmod -R 644 '$source_dir'" "Setting source file permissions" run_command "chmod -R 644 '$source_dir'" "Setting source file permissions"
print_success "Source files downloaded to: $source_dir" print_success "Source files downloaded to: $source_dir"
} }
create_configuration() { create_configuration() {
print_step "Creating configuration..." print_step "Creating configuration..."
local config_file="$INSTALL_DIR/config.yml" local config_file="$INSTALL_DIR/config.yml"
# Check if configuration already exists # Check if configuration already exists
if [ -f "$config_file" ]; then if [ -f "$config_file" ]; then
print_info "Configuration already exists: $config_file" print_info "Configuration already exists: $config_file"
@ -390,7 +390,7 @@ create_configuration() {
return 0 return 0
fi fi
fi fi
# Create basic configuration # Create basic configuration
cat > /tmp/authelia-api-config.yml << EOF cat > /tmp/authelia-api-config.yml << EOF
# Authelia API Configuration # Authelia API Configuration
@ -412,23 +412,23 @@ log_level: "info"
# AUTHELIA_API_LISTEN_ADDR: "127.0.0.1:8080" # AUTHELIA_API_LISTEN_ADDR: "127.0.0.1:8080"
# AUTHELIA_API_LOG_LEVEL: "info" # AUTHELIA_API_LOG_LEVEL: "info"
EOF EOF
run_command "mv /tmp/authelia-api-config.yml '$config_file'" "Creating configuration file" run_command "mv /tmp/authelia-api-config.yml '$config_file'" "Creating configuration file"
run_command "chown $USER:$USER '$config_file'" "Setting configuration ownership" run_command "chown $USER:$USER '$config_file'" "Setting configuration ownership"
run_command "chmod 600 '$config_file'" "Securing configuration" run_command "chmod 600 '$config_file'" "Securing configuration"
print_success "Configuration created: $config_file" print_success "Configuration created: $config_file"
} }
create_systemd_service() { create_systemd_service() {
print_step "Creating systemd service..." print_step "Creating systemd service..."
# Skip service creation for non-standard install directories # Skip service creation for non-standard install directories
if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then
print_info "Skipping systemd service creation (non-standard install directory)" print_info "Skipping systemd service creation (non-standard install directory)"
return 0 return 0
fi fi
# Check if service already exists # Check if service already exists
if [ -f "$SERVICE_FILE" ]; then if [ -f "$SERVICE_FILE" ]; then
print_info "Service file already exists: $SERVICE_FILE" print_info "Service file already exists: $SERVICE_FILE"
@ -441,7 +441,7 @@ create_systemd_service() {
return 0 return 0
fi fi
fi fi
# Create service file # Create service file
local service_content="[Unit] local service_content="[Unit]
Description=Authelia API Description=Authelia API
@ -484,24 +484,24 @@ ReadWritePaths=$INSTALL_DIR /opt/authelia"
[Install] [Install]
WantedBy=multi-user.target" WantedBy=multi-user.target"
# Write service file # Write service file
echo "$service_content" > /tmp/authelia-api.service echo "$service_content" > /tmp/authelia-api.service
run_command "mv /tmp/authelia-api.service '$SERVICE_FILE'" "Creating service file" run_command "mv /tmp/authelia-api.service '$SERVICE_FILE'" "Creating service file"
run_command "chmod 644 '$SERVICE_FILE'" "Setting service file permissions" run_command "chmod 644 '$SERVICE_FILE'" "Setting service file permissions"
# Reload systemd # Reload systemd
run_command "systemctl daemon-reload" "Reloading systemd" run_command "systemctl daemon-reload" "Reloading systemd"
print_success "Systemd service created: $SERVICE_FILE" print_success "Systemd service created: $SERVICE_FILE"
} }
setup_database() { setup_database() {
print_step "Setting up database..." print_step "Setting up database..."
local db_file="$INSTALL_DIR/authelia-api.db" local db_file="$INSTALL_DIR/authelia-api.db"
# Check if database already exists # Check if database already exists
if [ -f "$db_file" ]; then if [ -f "$db_file" ]; then
print_info "Database already exists: $db_file" print_info "Database already exists: $db_file"
@ -514,34 +514,34 @@ setup_database() {
return 0 return 0
fi fi
fi fi
# Create empty database file # Create empty database file
run_command "touch '$db_file'" "Creating database file" run_command "touch '$db_file'" "Creating database file"
run_command "chown $USER:$USER '$db_file'" "Setting database ownership" run_command "chown $USER:$USER '$db_file'" "Setting database ownership"
run_command "chmod 600 '$db_file'" "Securing database" run_command "chmod 600 '$db_file'" "Securing database"
print_success "Database file created: $db_file" print_success "Database file created: $db_file"
} }
run_bootstrap() { run_bootstrap() {
print_step "Running bootstrap..." print_step "Running bootstrap..."
local binary_path="$INSTALL_DIR/authelia-api" local binary_path="$INSTALL_DIR/authelia-api"
if [ ! -f "$binary_path" ]; then if [ ! -f "$binary_path" ]; then
print_error "Binary not found: $binary_path" print_error "Binary not found: $binary_path"
return 1 return 1
fi fi
print_info "Running bootstrap process (first-time setup)" print_info "Running bootstrap process (first-time setup)"
# Run bootstrap with proper user # Run bootstrap with proper user
if [ "$IS_ROOT" = true ]; then if [ "$IS_ROOT" = true ]; then
run_command "sudo -u $USER $binary_path --bootstrap" "Running bootstrap" run_command "sudo -u $USER $binary_path --bootstrap" "Running bootstrap"
else else
run_command "$binary_path --bootstrap" "Running bootstrap" run_command "$binary_path --bootstrap" "Running bootstrap"
fi fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
print_success "Bootstrap completed successfully" print_success "Bootstrap completed successfully"
else else
@ -551,24 +551,24 @@ run_bootstrap() {
enable_and_start_service() { enable_and_start_service() {
print_step "Enabling and starting service..." print_step "Enabling and starting service..."
# Skip service operations for non-standard install directories # Skip service operations for non-standard install directories
if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then
print_info "Skipping service operations (non-standard install directory)" print_info "Skipping service operations (non-standard install directory)"
return 0 return 0
fi fi
# Enable service # Enable service
run_command "systemctl enable $SERVICE_NAME" "Enabling service" run_command "systemctl enable $SERVICE_NAME" "Enabling service"
# Start service # Start service
run_command "systemctl start $SERVICE_NAME" "Starting service" run_command "systemctl start $SERVICE_NAME" "Starting service"
# Check service status # Check service status
sleep 2 sleep 2
if systemctl is-active --quiet "$SERVICE_NAME"; then if systemctl is-active --quiet "$SERVICE_NAME"; then
print_success "Service is running" print_success "Service is running"
# Show status # Show status
run_command "systemctl status $SERVICE_NAME --no-pager" "Service status" run_command "systemctl status $SERVICE_NAME --no-pager" "Service status"
else else
@ -580,20 +580,20 @@ enable_and_start_service() {
setup_firewall() { setup_firewall() {
print_step "Configuring firewall (if applicable)..." print_step "Configuring firewall (if applicable)..."
# Skip firewall configuration for non-standard install directories # Skip firewall configuration for non-standard install directories
if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then if [ "$INSTALL_DIR" != "/opt/authelia/api" ]; then
print_info "Skipping firewall configuration (non-standard install directory)" print_info "Skipping firewall configuration (non-standard install directory)"
return 0 return 0
fi fi
local port="8080" local port="8080"
# Check if firewall-cmd is available (firewalld) # Check if firewall-cmd is available (firewalld)
if command -v firewall-cmd &> /dev/null; then if command -v firewall-cmd &> /dev/null; then
if firewall-cmd --state &>/dev/null; then if firewall-cmd --state &>/dev/null; then
print_info "Configuring firewalld" print_info "Configuring firewalld"
# Add the service/port # Add the service/port
if ! firewall-cmd --query-port="${port}/tcp" &>/dev/null; then if ! firewall-cmd --query-port="${port}/tcp" &>/dev/null; then
run_command "firewall-cmd --permanent --add-port=${port}/tcp" "Adding firewall rule" run_command "firewall-cmd --permanent --add-port=${port}/tcp" "Adding firewall rule"
@ -607,7 +607,7 @@ setup_firewall() {
elif command -v ufw &> /dev/null; then elif command -v ufw &> /dev/null; then
if ufw status | grep -q "Status: active"; then if ufw status | grep -q "Status: active"; then
print_info "Configuring UFW" print_info "Configuring UFW"
if ! ufw status | grep -q "${port}/tcp"; then if ! ufw status | grep -q "${port}/tcp"; then
run_command "ufw allow ${port}/tcp comment 'Authelia API'" "Adding firewall rule" run_command "ufw allow ${port}/tcp comment 'Authelia API'" "Adding firewall rule"
print_success "Firewall rule added for port $port" print_success "Firewall rule added for port $port"
@ -627,9 +627,9 @@ setup_firewall() {
create_backup_script() { create_backup_script() {
print_step "Creating backup script..." print_step "Creating backup script..."
local backup_script="$INSTALL_DIR/backup.sh" local backup_script="$INSTALL_DIR/backup.sh"
cat > "$backup_script" << 'EOF' cat > "$backup_script" << 'EOF'
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
@ -662,7 +662,7 @@ systemctl start authelia-api
echo "Backup created: $BACKUP_FILE" echo "Backup created: $BACKUP_FILE"
echo "Size: $(du -h "$BACKUP_FILE" | cut -f1)" echo "Size: $(du -h "$BACKUP_FILE" | cut -f1)"
EOF EOF
# Copy backup script from source if it exists # Copy backup script from source if it exists
if [ -f "$LOCAL_SOURCE_PATH/backup.sh" ]; then if [ -f "$LOCAL_SOURCE_PATH/backup.sh" ]; then
cp "$LOCAL_SOURCE_PATH/backup.sh" "$backup_script" cp "$LOCAL_SOURCE_PATH/backup.sh" "$backup_script"
@ -682,11 +682,11 @@ EOF
main_installation() { main_installation() {
print_header print_header
echo -e "${BOLD}Authelia API Installation${NC}" echo -e "${BOLD}Authelia API Installation${NC}"
echo -e "This will install the Authelia API to: ${CYAN}$INSTALL_DIR${NC}" echo -e "This will install the Authelia API to: ${CYAN}$INSTALL_DIR${NC}"
echo "" echo ""
# Show what will be installed # Show what will be installed
echo -e "${BOLD}Components to install:${NC}" echo -e "${BOLD}Components to install:${NC}"
echo " • Authelia API binary" echo " • Authelia API binary"
@ -695,17 +695,17 @@ main_installation() {
echo " • Systemd service" echo " • Systemd service"
echo " • Backup script" echo " • Backup script"
echo "" echo ""
if [ "$IS_ROOT" = false ] && [ "$NEED_SUDO" = true ]; then if [ "$IS_ROOT" = false ] && [ "$NEED_SUDO" = true ]; then
echo -e "${YELLOW}Note:${NC} Some operations will require sudo privileges" echo -e "${YELLOW}Note:${NC} Some operations will require sudo privileges"
echo "" echo ""
fi fi
if ! ask_confirm "Proceed with installation?" "y"; then if ! ask_confirm "Proceed with installation?" "y"; then
print_info "Installation cancelled" print_info "Installation cancelled"
exit 0 exit 0
fi fi
# Run installation steps # Run installation steps
detect_system detect_system
check_dependencies check_dependencies
@ -720,9 +720,9 @@ main_installation() {
enable_and_start_service enable_and_start_service
setup_firewall setup_firewall
create_backup_script create_backup_script
print_step "Installation Complete!" print_step "Installation Complete!"
echo -e "${GREEN}${BOLD}✓ Authelia API has been successfully installed${NC}" echo -e "${GREEN}${BOLD}✓ Authelia API has been successfully installed${NC}"
echo "" echo ""
echo -e "${BOLD}Service Information:${NC}" echo -e "${BOLD}Service Information:${NC}"
@ -749,7 +749,7 @@ main_installation() {
echo "" echo ""
echo -e "${BOLD}Documentation:${NC} $REPO_URL" echo -e "${BOLD}Documentation:${NC} $REPO_URL"
echo "" echo ""
# Test API health endpoint # Test API health endpoint
print_info "Testing API health endpoint..." print_info "Testing API health endpoint..."
sleep 3 sleep 3
@ -769,7 +769,7 @@ main_installation() {
uninstall() { uninstall() {
print_header print_header
echo -e "${RED}${BOLD}⚠ Uninstall Authelia API${NC}" echo -e "${RED}${BOLD}⚠ Uninstall Authelia API${NC}"
echo "" echo ""
echo -e "This will:" echo -e "This will:"
@ -780,14 +780,14 @@ uninstall() {
echo "" echo ""
echo -e "${YELLOW}Warning:${NC} This will delete all authelia-api data including the database!" echo -e "${YELLOW}Warning:${NC} This will delete all authelia-api data including the database!"
echo "" echo ""
if ! ask_confirm "Are you sure you want to uninstall?" "n"; then if ! ask_confirm "Are you sure you want to uninstall?" "n"; then
print_info "Uninstall cancelled" print_info "Uninstall cancelled"
exit 0 exit 0
fi fi
print_step "Starting uninstallation..." print_step "Starting uninstallation..."
# Stop and disable service # Stop and disable service
if [ -f "$SERVICE_FILE" ]; then if [ -f "$SERVICE_FILE" ]; then
run_command "systemctl stop $SERVICE_NAME 2>/dev/null || true" "Stopping service" run_command "systemctl stop $SERVICE_NAME 2>/dev/null || true" "Stopping service"
@ -795,17 +795,17 @@ uninstall() {
run_command "rm -f '$SERVICE_FILE'" "Removing service file" run_command "rm -f '$SERVICE_FILE'" "Removing service file"
run_command "systemctl daemon-reload" "Reloading systemd" run_command "systemctl daemon-reload" "Reloading systemd"
fi fi
# Remove installation directory # Remove installation directory
if [ -d "$INSTALL_DIR" ]; then if [ -d "$INSTALL_DIR" ]; then
run_command "rm -rf '$INSTALL_DIR'" "Removing installation directory" run_command "rm -rf '$INSTALL_DIR'" "Removing installation directory"
fi fi
# Remove backup script # Remove backup script
if [ -f "/usr/local/bin/authelia-api-backup" ]; then if [ -f "/usr/local/bin/authelia-api-backup" ]; then
run_command "rm -f /usr/local/bin/authelia-api-backup" "Removing backup script" run_command "rm -f /usr/local/bin/authelia-api-backup" "Removing backup script"
fi fi
print_success "Uninstallation complete!" print_success "Uninstallation complete!"
echo "" echo ""
echo -e "${BOLD}Note:${NC} Authelia configuration and user database were not modified" echo -e "${BOLD}Note:${NC} Authelia configuration and user database were not modified"
@ -855,4 +855,4 @@ case "${1:-}" in
echo "Use --help for usage information" echo "Use --help for usage information"
exit 1 exit 1
;; ;;
esac esac