Download start.sh from runitx/test: direct link, hf CLI and curl.
- Browser
- Download file 3.43 kB
-
https://huggingface.co/spaces/runitx/test/resolve/main/start.sh
- Command line
-
hf download hf://spaces/runitx/test/start.sh
-
curl -L -o start.sh https://huggingface.co/spaces/runitx/test/resolve/main/start.sh
3.43 kB
| # Start tmate in a socket | |
| echo "Starting tmate..." | |
| tmate -S /tmp/tmate.sock new-session -d | |
| # Wait for tmate to connect and get the SSH connection string | |
| echo "Waiting for tmate to generate SSH URL..." | |
| for i in {1..30}; do | |
| SSH_CONN=$(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}' 2>/dev/null) | |
| if [ -n "$SSH_CONN" ]; then | |
| echo "=============================================" | |
| echo "SSH connection string: $SSH_CONN" | |
| echo "=============================================" | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| # If SSH_CONN is empty, print error | |
| if [ -z "$SSH_CONN" ]; then | |
| echo "Failed to get tmate SSH connection string." | |
| SSH_CONN="Error: Could not retrieve tmate SSH connection string." | |
| fi | |
| # Create a simple web page to display the SSH connection details | |
| cat <<EOF > index.html | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>SSH Tunnel Connection Details</title> | |
| <style> | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background-color: #0f172a; | |
| color: #f8fafc; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| height: 100vh; | |
| margin: 0; | |
| } | |
| .container { | |
| background-color: #1e293b; | |
| padding: 2.5rem; | |
| border-radius: 12px; | |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); | |
| text-align: center; | |
| max-width: 600px; | |
| width: 90%; | |
| border: 1px solid #334155; | |
| } | |
| h1 { | |
| color: #38bdf8; | |
| margin-top: 0; | |
| font-size: 1.8rem; | |
| } | |
| p { | |
| font-size: 1rem; | |
| color: #94a3b8; | |
| line-height: 1.5; | |
| } | |
| .code-block { | |
| background-color: #090d16; | |
| color: #34d399; | |
| padding: 1rem; | |
| border-radius: 6px; | |
| font-family: monospace; | |
| font-size: 1.1rem; | |
| word-break: break-all; | |
| margin: 1.5rem 0; | |
| border: 1px solid #1e293b; | |
| user-select: all; | |
| cursor: pointer; | |
| } | |
| .instructions { | |
| text-align: left; | |
| margin-top: 2rem; | |
| border-top: 1px solid #334155; | |
| padding-top: 1.5rem; | |
| } | |
| .instructions h3 { | |
| color: #cbd5e1; | |
| margin-bottom: 0.5rem; | |
| } | |
| .instructions ol { | |
| color: #94a3b8; | |
| padding-left: 1.2rem; | |
| margin-top: 0.5rem; | |
| } | |
| .instructions li { | |
| margin-bottom: 0.5rem; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>SSH Access Enabled</h1> | |
| <p>Your Hugging Face Space Docker container is running and has established a secure tunnel via tmate.</p> | |
| <p>Click below to select and copy the SSH command:</p> | |
| <div class="code-block">${SSH_CONN}</div> | |
| <div class="instructions"> | |
| <h3>How to connect:</h3> | |
| <ol> | |
| <li>Copy the command above.</li> | |
| <li>Paste it in your terminal and press Enter.</li> | |
| <li>You will have direct shell access to the Hugging Face Space container.</li> | |
| </ol> | |
| </div> | |
| </div> | |
| </body> | |
| </html> | |
| EOF | |
| # Start a simple Python web server to serve the page on port 7860 | |
| echo "Starting web server on port 7860..." | |
| python3 -m http.server 7860 | |