| #!/bin/bash |
| set -e |
|
|
| echo "===== VSCode Server Startup at $(date) =====" |
| echo "Starting minimal services..." |
| cd /home/user |
|
|
| |
| mkdir -p /home/user/logs |
|
|
| |
| echo "Starting nginx..." |
| nginx -c /etc/nginx/nginx.conf & |
| NGINX_PID=$! |
| echo "Nginx started with PID: $NGINX_PID" |
|
|
| |
| sleep 2 |
|
|
| |
| echo "Starting code-server..." |
| code-server --config /home/user/.config/code-server/config.yaml & |
| CODE_SERVER_PID=$! |
| echo "Code-server started with PID: $CODE_SERVER_PID" |
|
|
| |
| sleep 3 |
|
|
| |
| if [ ! -z "$TUNNEL_TOKEN" ]; then |
| echo "Starting Cloudflare Tunnel with token..." |
| cloudflared tunnel run --token $TUNNEL_TOKEN & |
| TUNNEL_PID=$! |
| echo "Cloudflare Tunnel started with PID: $TUNNEL_PID" |
| else |
| echo "No TUNNEL_TOKEN provided, starting Quick Tunnel..." |
| cloudflared tunnel --url http://localhost:7860 & |
| TUNNEL_PID=$! |
| echo "Cloudflare Quick Tunnel started with PID: $TUNNEL_PID" |
| fi |
|
|
| echo "All services started successfully!" |
| echo "Access URLs:" |
| echo " - Code-server: http://localhost:7860" |
| echo " - Nginx: http://localhost:8080" |
| echo " - VSCode via Nginx: http://localhost:8080/admin-vscode" |
|
|
| |
| wait |