#!/bin/bash set -e # Exit on any error # Check if all required parameters are provided if [ "$#" -ne 3 ]; then echo "Usage: $0 " exit 1 fi # Assign parameters to variables USERNAME="$1" DOMAIN="$2" ID="$3" echo "Starting server initialization..." echo "Username: $USERNAME" echo "Domain: $DOMAIN" echo "ID: $ID" # Install required packages echo "Installing required packages..." sudo apt install cron nginx wget unzip openssl -y # Configure web server permissions and files echo "Configuring web server..." sudo chown -R "$USERNAME:$USERNAME" /var/www sudo mkdir -p /var/www/html/.well-known/acme-challenge sudo chown -R www-data:www-data /var/www/html sudo chmod 755 /var/www/html/.well-known/acme-challenge rm -f /var/www/html/index.nginx-debian.html # Create index.html cat >/var/www/html/index.html <<'EOF' John Doe - Professional Portfolio

John Doe

Full Stack Developer

About Me

Passionate full-stack developer with 5+ years of experience building scalable web applications. I specialize in modern JavaScript frameworks and cloud architecture.

Featured Projects

E-commerce Platform

A full-featured e-commerce solution built with React and Node.js, featuring real-time inventory management and secure payment processing.

Task Management App

A collaborative task management application using Vue.js and Firebase, with real-time updates and team collaboration features.

Analytics Dashboard

A responsive analytics dashboard built with D3.js and Express, providing real-time data visualization and reporting capabilities.

Skills

JavaScript React Node.js Python SQL AWS Docker Git

Contact Me

© 2025 John Doe. All rights reserved.

EOF # Initial nginx configuration sudo tee /etc/nginx/nginx.conf >/dev/null <~/cert/renew.sh <&1) RENEW_EXIT_CODE=\$? echo "\$RENEW_OUTPUT" # If renewal was successful (exit code 0) or skipped (exit code 2), proceed with installation if [ \$RENEW_EXIT_CODE -eq 0 ] || [ \$RENEW_EXIT_CODE -eq 2 ]; then # Install/reinstall the certificate /home/$USERNAME/.acme.sh/acme.sh --install-cert -d $DOMAIN --ecc \\ --fullchain-file /home/$USERNAME/cert/x.crt \\ --key-file /home/$USERNAME/cert/x.key echo "X Certificates Renewed/Reinstalled" # Set proper permissions for the private key chmod +r /home/$USERNAME/cert/x.key echo "Read Permission Granted for Private Key" # Restart x service to use the certificate sudo systemctl restart xray echo "X Restarted" # Verify the certificate echo "Certificate details:" openssl x509 -in /home/$USERNAME/cert/x.crt -text -noout | grep -E "(Subject:|Issuer:|Not Before|Not After)" echo "Certificate renewal/installation completed successfully!" else echo "Certificate renewal failed with exit code \$RENEW_EXIT_CODE" exit 1 fi EOF chmod +x ~/cert/renew.sh # Setup cron jobs (crontab -l 2>/dev/null; echo "0 2 * * 0 /home/$USERNAME/cert/renew.sh >> /home/$USERNAME/cert/renewal.log 2>&1") | crontab - # Configure X echo "Configuring X..." sudo tee /usr/local/etc/xray/config.json >/dev/null </dev/null <<'EOF' net.core.default_qdisc=fq net.ipv4.tcp_congestion_control=bbr EOF # Final nginx configuration with ACME challenge support sudo tee /etc/nginx/nginx.conf >/dev/null <