diff --git a/install.sh b/install.sh index 0d585aa..17422e7 100644 --- a/install.sh +++ b/install.sh @@ -10,6 +10,8 @@ ############################################################# set -e # Exit on error +# Determine script directory (for copying local backend/frontend) +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # Colors for output RED='\033[0;31m' @@ -627,12 +629,12 @@ install_mullvad() { # Add Mullvad repository # Determine codename safely - CODENAME="$(lsb_release -cs 2>/dev/null || . /etc/os-release 2>/dev/null && echo "$VERSION_CODENAME")" + CODENAME=$(lsb_release -cs 2>/dev/null || { . /etc/os-release 2>/dev/null; echo "$VERSION_CODENAME"; } ) [ -z "$CODENAME" ] && CODENAME="stable" echo "deb [signed-by=/usr/share/keyrings/mullvad-keyring.gpg arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $CODENAME main" | tee /etc/apt/sources.list.d/mullvad.list - # Update and install - apt-get update &>/dev/null + # Update and install (don't abort on failure) + apt-get update &>/dev/null || warning "apt-get update failed for Mullvad repo; continuing" apt-get install -y mullvad-vpn &>/dev/null || { warning "Could not install Mullvad client, using WireGuard directly" } @@ -748,233 +750,52 @@ install_backend() { pip install --upgrade pip &>/dev/null pip install flask flask-cors requests gunicorn pyyaml &>/dev/null - # Download or create the multi-provider backend - # For production, this would be downloaded from GitHub - # Here we create it inline for the complete solution - + # Install backend from repo if available, else fallback to local backend/ log "Installing multi-provider backend..." - - # The backend app.py would be downloaded from GitHub in production: - # wget -O "$INSTALL_DIR/app.py" "$GITHUB_REPO/app.py" - - # For now, we use a simplified version that supports all providers - cat > "$INSTALL_DIR/app.py" << 'EOFAPP' + + if [ -f "$SCRIPT_DIR/backend/app.py" ]; then + cp "$SCRIPT_DIR/backend/app.py" "$INSTALL_DIR/app.py" + else + # Fallback minimal app + cat > "$INSTALL_DIR/app.py" << 'EOFAPP' #!/usr/bin/env python3 -# Multi-Provider VPN Backend -# This is a placeholder - in production, use the full backend from the artifact -# Download from: https://github.com/yourusername/vpn-gateway/blob/main/backend/app.py - -from flask import Flask, request, jsonify, send_from_directory -from flask_cors import CORS -import subprocess -import json -import os -import logging - +from flask import Flask app = Flask(__name__) -CORS(app) - -# ... (Full backend code would be here) -# For production, download the complete multi-provider backend - @app.route('/') def index(): - return send_from_directory('__INSTALL_DIR__/static', 'index.html') - + return 'VPN Gateway running' if __name__ == '__main__': app.run(host='0.0.0.0', port=5000) EOFAPP - - # Replace placeholders - sed -i "s|__INSTALL_DIR__|$INSTALL_DIR|g" "$INSTALL_DIR/app.py" - + fi + log "Backend installed" } # Install WebUI install_webui() { log "Installing WebUI..." - - # Download WebUI from GitHub or create inline - cat > "$INSTALL_DIR/static/index.html" << 'EOFHTML' - - - - - - VPN Gateway Control - - - -
-

🔐 VPN Gateway Control

- -
- 🛡️ Security Status: PROTECTED
- ✓ Killswitch permanently active
- ✓ No internet without VPN -
- -
-

Status: Checking...

-

IP: -

-

Location: -

-
- - - - - - - - - -
- - - - -EOFHTML - + mkdir -p "$INSTALL_DIR/static" + if [ -f "$SCRIPT_DIR/frontend/index.html" ]; then + cp "$SCRIPT_DIR/frontend/index.html" "$INSTALL_DIR/static/index.html" + else + echo "VPN Gateway WebUI" > "$INSTALL_DIR/static/index.html" + fi log "WebUI installed" } + log "Installing WebUI..." + + # Install WebUI from repo if available, else fallback to local frontend/ + if [ -f "$SCRIPT_DIR/frontend/index.html" ]; then + mkdir -p "$INSTALL_DIR/static" + cp "$SCRIPT_DIR/frontend/index.html" "$INSTALL_DIR/static/index.html" + else + # Minimal fallback page + cat > "$INSTALL_DIR/static/index.html" << 'EOFHTML' + +VPN Gateway WebUI +EOFHTML + fi # Setup systemd services setup_services() {