Spaces:
Running
Running
Download services/05-code-server.sh from amangs/cbot: direct link, hf CLI and curl.
- Browser
- Download file 2.52 kB
-
https://huggingface.co/spaces/amangs/cbot/resolve/main/services/05-code-server.sh
- Command line
-
hf download hf://spaces/amangs/cbot/services/05-code-server.sh
-
curl -L -o 05-code-server.sh https://huggingface.co/spaces/amangs/cbot/resolve/main/services/05-code-server.sh
2.52 kB
| # 05-code-server.sh — code-server service on 127.0.0.1:8443 | |
| DIR="/data/script/code-server" | |
| USER_DATA="${CODE_USER_DATA:-/data/apps/vscode}" | |
| mkdir -p "$DIR" "$USER_DATA/User" "$HOME/.config/Code/User" /tmp/logs /tmp/code-server-cache | |
| LOG="/tmp/logs/code-server.log" | |
| if [ -f /data/.env ]; then | |
| set -a | |
| . /data/.env | |
| set +a | |
| fi | |
| export PASSWORD="${CODE_PASSWORD:-${AUTH_TOKEN:-}}" | |
| mkdir -p "$HOME/.config/code-server" | |
| python3 -c " | |
| import yaml | |
| with open('$HOME/.config/code-server/config.yaml', 'w') as f: | |
| yaml.dump({'bind-addr': '127.0.0.1:8443', 'auth': 'password', 'password': '$PASSWORD', 'cert': False}, f) | |
| " 2>/dev/null || printf 'bind-addr: 127.0.0.1:8443\nauth: password\npassword: "%s"\ncert: false\n' "$PASSWORD" > "$HOME/.config/code-server/config.yaml" | |
| # Symlink heavy logs & CachedData to /tmp so S3 /data never fills | |
| ln -sfn /tmp/logs "$USER_DATA/logs" 2>/dev/null || true | |
| ln -sfn /tmp/code-server-cache "$USER_DATA/CachedData" 2>/dev/null || true | |
| # Register REA MCP in VS Code / code-server configuration | |
| cat > "$USER_DATA/User/mcp.json" << 'MCPEOF' | |
| { | |
| "mcpServers": { | |
| "rea": { | |
| "command": "/usr/local/bin/rea", | |
| "args": ["mcp"], | |
| "env": { | |
| "GHIDRA_INSTALL_DIR": "/opt/ghidra/ghidra_12.1.4_PUBLIC", | |
| "JAVA_HOME": "/opt/jdk-21", | |
| "REA_ANALYSIS_PROVIDER": "ghidra", | |
| "REA_JADX_MCP_JAR": "/opt/jadx/jadx-headless-mcp-0.7.1-all.jar", | |
| "REA_BINWALK_COMMAND": "/usr/local/bin/binwalk", | |
| "REA_UNBLOB_COMMAND": "/usr/local/bin/unblob", | |
| "REA_APKTOOL_COMMAND": "/usr/local/bin/apktool", | |
| "REA_FIRMWARE_PRLIMIT_COMMAND": "/usr/bin/prlimit", | |
| "REA_PWNTOOLS_PYTHON": "/usr/bin/python3" | |
| } | |
| } | |
| } | |
| } | |
| MCPEOF | |
| cp "$USER_DATA/User/mcp.json" "$HOME/.config/Code/User/mcp.json" 2>/dev/null || true | |
| # Force code-server to open blank with no workspace restored | |
| cat > "$USER_DATA/User/settings.json" << 'SETEOF' | |
| { | |
| "workbench.startupEditor": "none", | |
| "window.restoreWindows": "none" | |
| } | |
| SETEOF | |
| cp "$USER_DATA/User/settings.json" "$HOME/.config/Code/User/settings.json" 2>/dev/null || true | |
| rm -rf "$USER_DATA/User/workspaceStorage" "$USER_DATA/User/History" "$USER_DATA/Backups" 2>/dev/null || true | |
| if pgrep -f "code-server.*8443" >/dev/null 2>&1; then | |
| echo "code-server already running" | |
| exit 0 | |
| fi | |
| exec code-server \ | |
| --port 8443 \ | |
| --auth password \ | |
| --user-data-dir "$USER_DATA" \ | |
| --bind-addr 127.0.0.1:8443 \ | |
| --disable-telemetry \ | |
| --disable-update-check \ | |
| >> "$LOG" 2>&1 | |