Clean up shell script comments

This commit is contained in:
bigbong420 committed 2026-03-29 14:11:43 -04:00
1 parent 227b632ad8
commit c148db231d
2 files changed
-183

No files matched your search

-118
View File
@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
# ============================================================================
# Tor Hosting - Automated Installer for Debian 13 (Trixie) # Tor Hosting - Automated Installer for Debian 13 (Trixie)
# https://github.com/bigbong420/hosting # https://github.com/bigbong420/hosting
# #
@@ -9,7 +8,6 @@ set -e
# curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash # curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash
# Or with options: # Or with options:
# curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash -s -- --non-interactive # curl -sSL https://raw.githubusercontent.com/bigbong420/hosting/upgrades/install.sh | bash -s -- --non-interactive
# ============================================================================
REPO_URL="https://github.com/bigbong420/hosting.git" REPO_URL="https://github.com/bigbong420/hosting.git"
REPO_BRANCH="upgrades" REPO_BRANCH="upgrades"
@@ -31,11 +29,6 @@ DB_PMA_PASS="${HOSTING_PMA_PASS:-}"
ADMIN_PASS="${HOSTING_ADMIN_PASS:-}" ADMIN_PASS="${HOSTING_ADMIN_PASS:-}"
BLOWFISH_SECRET="" BLOWFISH_SECRET=""
ONION_ENC_KEY="" ONION_ENC_KEY=""
# ============================================================================
# Functions
# ============================================================================
log_info() { echo -e "${CYAN}[INFO]${NC} $1"; } log_info() { echo -e "${CYAN}[INFO]${NC} $1"; }
log_ok() { echo -e "${GREEN}[OK]${NC} $1"; } log_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
@@ -65,11 +58,6 @@ Examples:
EOF EOF
exit 0 exit 0
} }
# ============================================================================
# Parse arguments
# ============================================================================
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--non-interactive) NONINTERACTIVE=true; shift ;; --non-interactive) NONINTERACTIVE=true; shift ;;
@@ -83,11 +71,6 @@ while [[ $# -gt 0 ]]; do
*) log_error "Unknown option: $1"; usage ;; *) log_error "Unknown option: $1"; usage ;;
esac esac
done done
# ============================================================================
# Pre-flight checks
# ============================================================================
log_step "Pre-flight checks" log_step "Pre-flight checks"
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
@@ -135,9 +118,7 @@ fi
log_ok "Repository found at $SCRIPT_DIR" log_ok "Repository found at $SCRIPT_DIR"
# ============================================================================
# Interactive prompts (skipped with --non-interactive) # Interactive prompts (skipped with --non-interactive)
# ============================================================================
if [ "$NONINTERACTIVE" = false ]; then if [ "$NONINTERACTIVE" = false ]; then
log_step "Configuration" log_step "Configuration"
@@ -191,8 +172,6 @@ if [ "$NONINTERACTIVE" = false ]; then
fi fi
fi fi
fi fi
# Generate any passwords that weren't provided
[ -z "$DB_HOSTING_PASS" ] && DB_HOSTING_PASS=$(gen_pass) [ -z "$DB_HOSTING_PASS" ] && DB_HOSTING_PASS=$(gen_pass)
[ -z "$DB_PMA_PASS" ] && DB_PMA_PASS=$(gen_pass) [ -z "$DB_PMA_PASS" ] && DB_PMA_PASS=$(gen_pass)
[ -z "$ADMIN_PASS" ] && ADMIN_PASS=$(gen_pass) [ -z "$ADMIN_PASS" ] && ADMIN_PASS=$(gen_pass)
@@ -213,8 +192,6 @@ if [ "$NONINTERACTIVE" = false ]; then
exit 0 exit 0
fi fi
fi fi
# Save credentials to file
CREDS_FILE="/root/hosting-credentials.txt" CREDS_FILE="/root/hosting-credentials.txt"
cat > "$CREDS_FILE" <<EOF cat > "$CREDS_FILE" <<EOF
=== Daniel's Hosting Credentials === === Daniel's Hosting Credentials ===
@@ -233,11 +210,6 @@ Onion Key Encryption Key: $ONION_ENC_KEY
EOF EOF
chmod 600 "$CREDS_FILE" chmod 600 "$CREDS_FILE"
log_ok "Credentials saved to $CREDS_FILE" log_ok "Credentials saved to $CREDS_FILE"
# ============================================================================
# Step 1: Purge conflicting packages and fix DNS
# ============================================================================
log_step "Step 1: Purge conflicting packages" log_step "Step 1: Purge conflicting packages"
DEBIAN_FRONTEND=noninteractive apt purge -y apache2* dnsmasq* eatmydata exim4* \ DEBIAN_FRONTEND=noninteractive apt purge -y apache2* dnsmasq* eatmydata exim4* \
@@ -249,11 +221,6 @@ systemctl stop systemd-resolved.service 2>/dev/null || true
echo "nameserver 1.1.1.1" > /etc/resolv.conf echo "nameserver 1.1.1.1" > /etc/resolv.conf
log_ok "DNS set to 1.1.1.1" log_ok "DNS set to 1.1.1.1"
# ============================================================================
# Step 2: Add repositories
# ============================================================================
log_step "Step 2: Add repositories" log_step "Step 2: Add repositories"
apt update -qq apt update -qq
@@ -275,11 +242,6 @@ grep -q "sury.org" /etc/apt/sources.list || \
apt update -qq apt update -qq
DEBIAN_FRONTEND=noninteractive apt upgrade -y DEBIAN_FRONTEND=noninteractive apt upgrade -y
log_ok "Repositories configured" log_ok "Repositories configured"
# ============================================================================
# Step 3: Build binaries (PHP, ImageMagick, etc)
# ============================================================================
if [ "$SKIP_BINARIES" = true ]; then if [ "$SKIP_BINARIES" = true ]; then
log_step "Step 3: Skipping binary compilation (--skip-binaries)" log_step "Step 3: Skipping binary compilation (--skip-binaries)"
else else
@@ -295,11 +257,6 @@ else
fi fi
log_ok "All binaries compiled and installed" log_ok "All binaries compiled and installed"
fi fi
# ============================================================================
# Step 4: Vanity onion generation (if requested)
# ============================================================================
if [ -n "$VANITY_PREFIX" ]; then if [ -n "$VANITY_PREFIX" ]; then
log_step "Step 4: Generating vanity .onion address (prefix: $VANITY_PREFIX)" log_step "Step 4: Generating vanity .onion address (prefix: $VANITY_PREFIX)"
@@ -334,22 +291,12 @@ if [ -n "$VANITY_PREFIX" ]; then
else else
log_step "Step 4: Skipping vanity generation (random onion)" log_step "Step 4: Skipping vanity generation (random onion)"
fi fi
# ============================================================================
# Step 5: Copy site and config files
# ============================================================================
log_step "Step 5: Copy site and config files" log_step "Step 5: Copy site and config files"
cp -a "$SCRIPT_DIR/var/www/"* /var/www/ cp -a "$SCRIPT_DIR/var/www/"* /var/www/
cp -a "$SCRIPT_DIR/etc/"* /etc/ cp -a "$SCRIPT_DIR/etc/"* /etc/
log_ok "Files copied" log_ok "Files copied"
# ============================================================================
# Step 6: Create systemd service files for all PHP versions
# ============================================================================
log_step "Step 6: Create PHP-FPM systemd service files" log_step "Step 6: Create PHP-FPM systemd service files"
# 8.2 service files should exist from install_binaries.sh packages # 8.2 service files should exist from install_binaries.sh packages
@@ -363,11 +310,6 @@ done
systemctl daemon-reload systemctl daemon-reload
log_ok "PHP-FPM service files created for 8.2, 8.3, 8.4, 8.5" log_ok "PHP-FPM service files created for 8.2, 8.3, 8.4, 8.5"
# ============================================================================
# Step 7: Start Tor and get .onion address
# ============================================================================
log_step "Step 7: Configure Tor" log_step "Step 7: Configure Tor"
systemctl restart bind9.service systemctl restart bind9.service
@@ -387,17 +329,10 @@ if [ -z "$ONION_ADDR" ]; then
fi fi
log_ok "Onion address: ${GREEN}${ONION_ADDR}${NC}" log_ok "Onion address: ${GREEN}${ONION_ADDR}${NC}"
# ============================================================================
# Step 8: Configure common.php
# ============================================================================
log_step "Step 8: Configure hosting" log_step "Step 8: Configure hosting"
ADMIN_HASH=$(php8.2 -r "echo password_hash('$ADMIN_PASS', PASSWORD_DEFAULT);" 2>/dev/null || \ ADMIN_HASH=$(php8.2 -r "echo password_hash('$ADMIN_PASS', PASSWORD_DEFAULT);" 2>/dev/null || \
php8.5 -r "echo password_hash('$ADMIN_PASS', PASSWORD_DEFAULT);") php8.5 -r "echo password_hash('$ADMIN_PASS', PASSWORD_DEFAULT);")
# Replace passwords and settings
sed -i "s|const DBPASS='MY_PASSWORD'|const DBPASS='$DB_HOSTING_PASS'|" /var/www/common.php sed -i "s|const DBPASS='MY_PASSWORD'|const DBPASS='$DB_HOSTING_PASS'|" /var/www/common.php
sed -i "s|const ADMIN_PASSWORD='MY_PASSWORD'|const ADMIN_PASSWORD='$ADMIN_HASH'|" /var/www/common.php sed -i "s|const ADMIN_PASSWORD='MY_PASSWORD'|const ADMIN_PASSWORD='$ADMIN_HASH'|" /var/www/common.php
sed -i "s|const ONION_KEY_ENCRYPTION_KEY=''|const ONION_KEY_ENCRYPTION_KEY='$ONION_ENC_KEY'|" /var/www/common.php sed -i "s|const ONION_KEY_ENCRYPTION_KEY=''|const ONION_KEY_ENCRYPTION_KEY='$ONION_ENC_KEY'|" /var/www/common.php
@@ -415,11 +350,6 @@ sed -i "s/$DEFAULT_ONION/$ONION_ADDR/g" \
/var/www/html/squirrelmail/config/config.php /var/www/html/squirrelmail/config/config.php
log_ok "Configuration applied" log_ok "Configuration applied"
# ============================================================================
# Step 9: Configure Dovecot for Debian 13
# ============================================================================
log_step "Step 9: Configure Dovecot" log_step "Step 9: Configure Dovecot"
# Dovecot 2.4 in trixie has different config syntax # Dovecot 2.4 in trixie has different config syntax
@@ -459,22 +389,12 @@ fi
systemctl restart dovecot systemctl restart dovecot
log_ok "Dovecot configured" log_ok "Dovecot configured"
# ============================================================================
# Step 10: Postfix maps
# ============================================================================
log_step "Step 10: Configure Postfix" log_step "Step 10: Configure Postfix"
postalias /etc/aliases postalias /etc/aliases
postmap /etc/postfix/canonical /etc/postfix/sender_login_maps /etc/postfix/transport postmap /etc/postfix/canonical /etc/postfix/sender_login_maps /etc/postfix/transport
log_ok "Postfix maps created" log_ok "Postfix maps created"
# ============================================================================
# Step 11: Configure fstab (tmpfs, hidepid, quota)
# ============================================================================
log_step "Step 11: Configure fstab and quota" log_step "Step 11: Configure fstab and quota"
grep -q "tmpfs /tmp" /etc/fstab || \ grep -q "tmpfs /tmp" /etc/fstab || \
@@ -498,11 +418,6 @@ quotacheck -cMu "$QUOTA_TARGET" 2>/dev/null || true
quotaon "$QUOTA_TARGET" 2>/dev/null || true quotaon "$QUOTA_TARGET" 2>/dev/null || true
log_ok "Filesystem configured" log_ok "Filesystem configured"
# ============================================================================
# Step 12: Composer install (sodium_compat)
# ============================================================================
log_step "Step 12: Install Composer dependencies" log_step "Step 12: Install Composer dependencies"
echo "nameserver 1.1.1.1" > /etc/resolv.conf echo "nameserver 1.1.1.1" > /etc/resolv.conf
@@ -521,11 +436,6 @@ if [ ! -f /var/www/vendor/autoload.php ]; then
fi fi
log_ok "Composer dependencies installed" log_ok "Composer dependencies installed"
# ============================================================================
# Step 13: MySQL setup
# ============================================================================
log_step "Step 13: Configure MySQL" log_step "Step 13: Configure MySQL"
mysql -e "CREATE USER IF NOT EXISTS 'phpmyadmin'@'%' IDENTIFIED BY '$DB_PMA_PASS'; mysql -e "CREATE USER IF NOT EXISTS 'phpmyadmin'@'%' IDENTIFIED BY '$DB_PMA_PASS';
@@ -538,26 +448,15 @@ mysql phpmyadmin < /var/www/html/phpmyadmin/sql/create_tables.sql 2>/dev/null ||
mysql -e "CREATE USER IF NOT EXISTS 'hosting'@'%' IDENTIFIED BY '$DB_HOSTING_PASS'; mysql -e "CREATE USER IF NOT EXISTS 'hosting'@'%' IDENTIFIED BY '$DB_HOSTING_PASS';
GRANT ALL PRIVILEGES ON *.* TO 'hosting'@'%' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'hosting'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;" FLUSH PRIVILEGES;"
# Configure phpMyAdmin
sed -i "s|\$cfg\['blowfish_secret'\] = '.*'|\$cfg['blowfish_secret'] = '$BLOWFISH_SECRET'|" \ sed -i "s|\$cfg\['blowfish_secret'\] = '.*'|\$cfg['blowfish_secret'] = '$BLOWFISH_SECRET'|" \
/var/www/html/phpmyadmin/config.inc.php /var/www/html/phpmyadmin/config.inc.php
sed -i "s|YOUR_PASSWORD|$DB_PMA_PASS|g" /var/www/html/phpmyadmin/config.inc.php 2>/dev/null || true sed -i "s|YOUR_PASSWORD|$DB_PMA_PASS|g" /var/www/html/phpmyadmin/config.inc.php 2>/dev/null || true
log_ok "MySQL users and databases created" log_ok "MySQL users and databases created"
# ============================================================================
# Step 14: Run setup.php
# ============================================================================
log_step "Step 14: Run setup.php" log_step "Step 14: Run setup.php"
php8.2 /var/www/setup.php 2>&1 || true php8.2 /var/www/setup.php 2>&1 || true
# Ensure nginx runtime directories exist
mkdir -p /var/log/nginx /var/run/nginx mkdir -p /var/log/nginx /var/run/nginx
# Enable FPM services for all PHP versions
for ver in 8.2 8.3 8.4 8.5; do for ver in 8.2 8.3 8.4 8.5; do
systemctl enable "php$ver-fpm@default" 2>/dev/null || true systemctl enable "php$ver-fpm@default" 2>/dev/null || true
systemctl start "php$ver-fpm@default" 2>/dev/null || true systemctl start "php$ver-fpm@default" 2>/dev/null || true
@@ -565,11 +464,6 @@ done
systemctl restart nginx 2>/dev/null || true systemctl restart nginx 2>/dev/null || true
log_ok "Setup complete" log_ok "Setup complete"
# ============================================================================
# Step 15: Vanity onion import (if generated)
# ============================================================================
if [ -n "$VANITY_PREFIX" ] && [ -n "$VANITY_SECRET" ]; then if [ -n "$VANITY_PREFIX" ] && [ -n "$VANITY_SECRET" ]; then
log_step "Step 15: Import vanity onion address" log_step "Step 15: Import vanity onion address"
@@ -611,26 +505,14 @@ if [ -n "$VANITY_PREFIX" ] && [ -n "$VANITY_SECRET" ]; then
else else
log_step "Step 15: Skipping vanity import" log_step "Step 15: Skipping vanity import"
fi fi
# ============================================================================
# Step 16: Enable timers and disable sftp subsystem
# ============================================================================
log_step "Step 16: Final configuration" log_step "Step 16: Final configuration"
systemctl enable hosting-del.timer hosting.timer systemctl enable hosting-del.timer hosting.timer
sed -i 's/^Subsystem/#Subsystem/' /etc/ssh/sshd_config sed -i 's/^Subsystem/#Subsystem/' /etc/ssh/sshd_config
# Restart all services
systemctl restart nginx postfix dovecot systemctl restart nginx postfix dovecot
systemctl restart tor@default.service systemctl restart tor@default.service
log_ok "Timers enabled, services configured" log_ok "Timers enabled, services configured"
# ============================================================================
# Summary
# ============================================================================
log_step "Installation Complete" log_step "Installation Complete"
echo -e "${BOLD}Onion Address:${NC} ${GREEN}http://${ONION_ADDR}${NC}" echo -e "${BOLD}Onion Address:${NC} ${GREEN}http://${ONION_ADDR}${NC}"
-65
View File
@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
# ============================================================================
# Tor Hosting - Update Script # Tor Hosting - Update Script
# https://github.com/bigbong420/hosting # https://github.com/bigbong420/hosting
# #
@@ -13,7 +12,6 @@ set -e
# ./update.sh --rebuild # Also rebuild PHP/ImageMagick # ./update.sh --rebuild # Also rebuild PHP/ImageMagick
# ./update.sh --php-only # Only rebuild PHP (skip ImageMagick) # ./update.sh --php-only # Only rebuild PHP (skip ImageMagick)
# ./update.sh --code-only # Only update PHP code, no config changes # ./update.sh --code-only # Only update PHP code, no config changes
# ============================================================================
REPO_URL="https://github.com/bigbong420/hosting.git" REPO_URL="https://github.com/bigbong420/hosting.git"
REPO_BRANCH="upgrades" REPO_BRANCH="upgrades"
@@ -64,11 +62,6 @@ while [[ $# -gt 0 ]]; do
*) log_error "Unknown option: $1"; usage ;; *) log_error "Unknown option: $1"; usage ;;
esac esac
done done
# ============================================================================
# Pre-flight
# ============================================================================
log_step "Pre-flight checks" log_step "Pre-flight checks"
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
@@ -76,7 +69,6 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1 exit 1
fi fi
# Find the repo
if [ -d "/root/hosting" ]; then if [ -d "/root/hosting" ]; then
REPO_DIR="/root/hosting" REPO_DIR="/root/hosting"
elif [ -d "$(dirname "$0")/.git" ]; then elif [ -d "$(dirname "$0")/.git" ]; then
@@ -87,17 +79,10 @@ else
fi fi
log_ok "Repository at $REPO_DIR" log_ok "Repository at $REPO_DIR"
# ============================================================================
# Backup current config
# ============================================================================
log_step "Backing up current configuration" log_step "Backing up current configuration"
BACKUP_DIR="/root/hosting-backup-$(date +%Y%m%d-%H%M%S)" BACKUP_DIR="/root/hosting-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
# Save current secrets from common.php
if [ -f /var/www/common.php ]; then if [ -f /var/www/common.php ]; then
cp /var/www/common.php "$BACKUP_DIR/common.php.bak" cp /var/www/common.php "$BACKUP_DIR/common.php.bak"
DBHOST=$(php8.2 -r "require('/var/www/common.php'); echo DBHOST;" 2>/dev/null || echo "127.0.0.1") DBHOST=$(php8.2 -r "require('/var/www/common.php'); echo DBHOST;" 2>/dev/null || echo "127.0.0.1")
@@ -119,16 +104,9 @@ if [ -z "$DBPASS" ] || [ -z "$ADDRESS" ]; then
fi fi
log_ok "Backup saved to $BACKUP_DIR" log_ok "Backup saved to $BACKUP_DIR"
# ============================================================================
# Pull latest code
# ============================================================================
log_step "Pulling latest code" log_step "Pulling latest code"
cd "$REPO_DIR" cd "$REPO_DIR"
# Save hash of install_binaries.sh before pull to detect changes
OLD_BINARIES_HASH="" OLD_BINARIES_HASH=""
if [ -f "$REPO_DIR/install_binaries.sh" ]; then if [ -f "$REPO_DIR/install_binaries.sh" ]; then
OLD_BINARIES_HASH=$(md5sum "$REPO_DIR/install_binaries.sh" | cut -d' ' -f1) OLD_BINARIES_HASH=$(md5sum "$REPO_DIR/install_binaries.sh" | cut -d' ' -f1)
@@ -140,11 +118,6 @@ git reset --hard "origin/$REPO_BRANCH"
NEW_BINARIES_HASH=$(md5sum "$REPO_DIR/install_binaries.sh" | cut -d' ' -f1) NEW_BINARIES_HASH=$(md5sum "$REPO_DIR/install_binaries.sh" | cut -d' ' -f1)
log_ok "Code updated to latest" log_ok "Code updated to latest"
# ============================================================================
# Check for binary changes
# ============================================================================
BINARIES_CHANGED=false BINARIES_CHANGED=false
if [ "$OLD_BINARIES_HASH" != "$NEW_BINARIES_HASH" ] && [ -n "$OLD_BINARIES_HASH" ]; then if [ "$OLD_BINARIES_HASH" != "$NEW_BINARIES_HASH" ] && [ -n "$OLD_BINARIES_HASH" ]; then
BINARIES_CHANGED=true BINARIES_CHANGED=true
@@ -184,10 +157,6 @@ if [ "$OLD_BINARIES_HASH" != "$NEW_BINARIES_HASH" ] && [ -n "$OLD_BINARIES_HASH"
fi fi
fi fi
# ============================================================================
# Rebuild binaries (if requested or needed)
# ============================================================================
if [ "$REBUILD" = true ]; then if [ "$REBUILD" = true ]; then
log_step "Rebuilding all binaries (PHP + ImageMagick)" log_step "Rebuilding all binaries (PHP + ImageMagick)"
bash "$REPO_DIR/install_binaries.sh" 2>&1 | tee /root/rebuild.log bash "$REPO_DIR/install_binaries.sh" 2>&1 | tee /root/rebuild.log
@@ -205,13 +174,7 @@ elif [ "$BINARIES_CHANGED" = true ] && [ "$CODE_ONLY" != true ]; then
log_warn "Continuing with code-only update for now." log_warn "Continuing with code-only update for now."
fi fi
# ============================================================================
# Update code files
# ============================================================================
log_step "Updating code files" log_step "Updating code files"
# Copy updated PHP files
cp -a "$REPO_DIR/var/www/common.php" /var/www/common.php cp -a "$REPO_DIR/var/www/common.php" /var/www/common.php
cp -a "$REPO_DIR/var/www/html/home.php" /var/www/html/home.php cp -a "$REPO_DIR/var/www/html/home.php" /var/www/html/home.php
cp -a "$REPO_DIR/var/www/html/login.php" /var/www/html/login.php cp -a "$REPO_DIR/var/www/html/login.php" /var/www/html/login.php
@@ -233,25 +196,15 @@ cp -a "$REPO_DIR/var/www/find_old.php" /var/www/find_old.php 2>/dev/null || true
log_ok "Code files updated" log_ok "Code files updated"
# ============================================================================
# Restore configuration
# ============================================================================
log_step "Restoring configuration" log_step "Restoring configuration"
DEFAULT_ONION="dhosting4xxoydyaivckq7tsmtgi4wfs3flpeyitekkmqwu4v4r46syd.onion" DEFAULT_ONION="dhosting4xxoydyaivckq7tsmtgi4wfs3flpeyitekkmqwu4v4r46syd.onion"
# Restore DB settings
sed -i "s|const DBHOST='127.0.0.1'|const DBHOST='$DBHOST'|" /var/www/common.php sed -i "s|const DBHOST='127.0.0.1'|const DBHOST='$DBHOST'|" /var/www/common.php
sed -i "s|const DBPASS='MY_PASSWORD'|const DBPASS='$DBPASS'|" /var/www/common.php sed -i "s|const DBPASS='MY_PASSWORD'|const DBPASS='$DBPASS'|" /var/www/common.php
sed -i "s|const ADMIN_PASSWORD='MY_PASSWORD'|const ADMIN_PASSWORD='$ADMIN_PASSWORD'|" /var/www/common.php sed -i "s|const ADMIN_PASSWORD='MY_PASSWORD'|const ADMIN_PASSWORD='$ADMIN_PASSWORD'|" /var/www/common.php
sed -i "s|const ONION_KEY_ENCRYPTION_KEY=''|const ONION_KEY_ENCRYPTION_KEY='$ONION_KEY_ENCRYPTION_KEY'|" /var/www/common.php sed -i "s|const ONION_KEY_ENCRYPTION_KEY=''|const ONION_KEY_ENCRYPTION_KEY='$ONION_KEY_ENCRYPTION_KEY'|" /var/www/common.php
# Restore onion address
sed -i "s|$DEFAULT_ONION|$ADDRESS|g" /var/www/common.php sed -i "s|$DEFAULT_ONION|$ADDRESS|g" /var/www/common.php
sed -i "s|$DEFAULT_ONION|$ADDRESS|g" /var/www/skel/www/index.hosting.html 2>/dev/null || true sed -i "s|$DEFAULT_ONION|$ADDRESS|g" /var/www/skel/www/index.hosting.html 2>/dev/null || true
# Fix permissions
chown root:www-data /var/www/common.php chown root:www-data /var/www/common.php
chmod 640 /var/www/common.php chmod 640 /var/www/common.php
@@ -263,25 +216,13 @@ if [ "$CODE_ONLY" = true ]; then
exit 0 exit 0
fi fi
# ============================================================================
# Update configs and restart services
# ============================================================================
log_step "Updating services" log_step "Updating services"
# Run setup.php to update database schema and configs
php8.2 /var/www/setup.php 2>&1 || true php8.2 /var/www/setup.php 2>&1 || true
# Ensure runtime dirs exist
mkdir -p /var/log/nginx /var/run/nginx mkdir -p /var/log/nginx /var/run/nginx
# Restart FPM and nginx
for ver in 8.2 8.3 8.4 8.5; do for ver in 8.2 8.3 8.4 8.5; do
systemctl restart "php$ver-fpm@default" 2>/dev/null || true systemctl restart "php$ver-fpm@default" 2>/dev/null || true
done done
systemctl restart nginx 2>/dev/null || true systemctl restart nginx 2>/dev/null || true
# Verify
FAILS=0 FAILS=0
for svc in nginx php8.2-fpm@default php8.3-fpm@default php8.4-fpm@default php8.5-fpm@default; do for svc in nginx php8.2-fpm@default php8.3-fpm@default php8.4-fpm@default php8.5-fpm@default; do
if ! systemctl is-active --quiet "$svc"; then if ! systemctl is-active --quiet "$svc"; then
@@ -296,17 +237,11 @@ else
log_warn "$FAILS service(s) need attention" log_warn "$FAILS service(s) need attention"
fi fi
# ============================================================================
# Summary
# ============================================================================
log_step "Update Complete" log_step "Update Complete"
echo -e "${BOLD}Onion:${NC} $ADDRESS" echo -e "${BOLD}Onion:${NC} $ADDRESS"
echo -e "${BOLD}Backup:${NC} $BACKUP_DIR" echo -e "${BOLD}Backup:${NC} $BACKUP_DIR"
echo "" echo ""
# Quick smoke test
TITLE=$(curl -s --max-time 30 --socks5-hostname 127.0.0.1:9050 "http://$ADDRESS/" 2>/dev/null | grep -o "<title>[^<]*</title>") TITLE=$(curl -s --max-time 30 --socks5-hostname 127.0.0.1:9050 "http://$ADDRESS/" 2>/dev/null | grep -o "<title>[^<]*</title>")
if [ -n "$TITLE" ]; then if [ -n "$TITLE" ]; then
log_ok "Site responding: $TITLE" log_ok "Site responding: $TITLE"