#!/bin/bash # Ubuntu Sandbox Initialization Script echo "🐧 Initializing Ubuntu Sandbox..." # Set up environment export DEBIAN_FRONTEND=noninteractive export PYTHONDONTWRITEBYTECODE=1 export PYTHONUNBUFFERED=1 # Create necessary directories mkdir -p /home/sandbox/projects mkdir -p /home/sandbox/tools mkdir -p /home/sandbox/.jupyter # Set up Git configuration (if not exists) if [ ! -f /home/sandbox/.gitconfig ]; then git config --global user.name "Sandbox User" git config --global user.email "sandbox@example.com" git config --global init.defaultBranch main git config --global --add safe.directory '*' fi # Create useful aliases cat > /home/sandbox/.bash_aliases << 'EOF' # Custom aliases for sandbox alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' alias ..='cd ..' alias ...='cd ../..' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' # Development shortcuts alias py='python3' alias pip='pip3' alias serve='python3 -m http.server 8000' alias jlab='jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root' # System monitoring alias ports='netstat -tuln' alias processes='ps aux' alias memory='free -h' alias disk='df -h' EOF # Create Jupyter configuration cat > /home/sandbox/.jupyter/jupyter_lab_config.py << 'EOF' c.ServerApp.ip = '0.0.0.0' c.ServerApp.port = 8888 c.ServerApp.open_browser = False c.ServerApp.allow_root = True c.ServerApp.token = '' c.ServerApp.password = '' c.ServerApp.allow_origin = '*' c.ServerApp.disable_check_xsrf = True EOF # Create a sample project structure if [ ! -d "/home/sandbox/projects/sample-project" ]; then mkdir -p /home/sandbox/projects/sample-project cd /home/sandbox/projects/sample-project # Create a simple Python web app cat > app.py << 'EOF' from fastapi import FastAPI from fastapi.responses import HTMLResponse app = FastAPI(title="Sandbox Web App", version="1.0.0") @app.get("/", response_class=HTMLResponse) def read_root(): return """
Welcome to your Ubuntu development sandbox!
This is a containerized Ubuntu environment with:
Start building your projects in /home/sandbox/projects!
This is your Node.js server in the Ubuntu sandbox!
Server running on port ${port}
`); }); app.get('/api/status', (req, res) => { res.json({ status: 'running', port: port, message: 'Node.js server is healthy!' }); }); app.listen(port, '0.0.0.0', () => { console.log(`🚀 Server running at http://0.0.0.0:${port}`); }); EOF fi # Install Python packages if requirements.txt exists if [ -f "/home/sandbox/projects/sample-project/requirements.txt" ]; then echo "📦 Installing Python dependencies..." cd /home/sandbox/projects/sample-project pip3 install -r requirements.txt --user fi # Set proper permissions chown -R sandbox:sandbox /home/sandbox/ # Display welcome message echo "" echo "✅ Ubuntu Sandbox initialized successfully!" echo "" echo "📁 Available directories:" echo " - /home/sandbox/projects (your code goes here)" echo " - /home/sandbox/tools (custom tools and utilities)" echo "" echo "🚀 Quick start commands:" echo " - cd /home/sandbox/projects/sample-project" echo " - python3 app.py (start FastAPI server on port 8000)" echo " - npm start (start Node.js server on port 3000)" echo " - jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root" echo "" echo "🔧 System info:" echo " - Python: $(python3 --version)" echo " - Node.js: $(node --version 2>/dev/null || echo 'Not available')" echo " - Git: $(git --version)" echo "" echo "Happy coding! 🎉"