d / start.sh
pabla1322's picture
Upload 14 files
e5de808 verified
Raw
History Blame Contribute Delete
2.7 kB
#!/bin/bash
# ============================================================
# start.sh – Main container entrypoint
# Initialises storage, user env, VNC, then hands off to supervisord
# ============================================================
set -euo pipefail
# ── Colour helpers ───────────────────────────────────────────
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
BLUE='\033[0;34m'; NC='\033[0m'
log() { echo -e "${GREEN}[START]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN ]${NC} $*"; }
err() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
# ── Banner ───────────────────────────────────────────────────
echo ""
echo -e "${BLUE}╔══════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}β•‘ Ubuntu 24.04 XFCE Desktop – HuggingFace Space β•‘${NC}"
echo -e "${BLUE}β•‘ PRoot-Distro Style β”‚ noVNC Browser Access β•‘${NC}"
echo -e "${BLUE}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${NC}"
echo " Started: $(date)"
echo ""
# ── Ensure /data exists (HF mounts it; fallback for local dev) ──
if [ ! -d /data ]; then
warn "/data not found – creating in-container fallback (data will NOT persist)"
mkdir -p /data
fi
# ── Run setup phases ─────────────────────────────────────────
log "Phase 1/3 – Persistent storage"
bash /setup_storage.sh
log "Phase 2/3 – Ubuntu user environment"
bash /setup_ubuntu.sh
log "Phase 3/3 – VNC configuration"
bash /setup_vnc.sh
# ── Ensure supervisor log dir ────────────────────────────────
mkdir -p /data/logs
mkdir -p /var/log/supervisor
# ── Fix nginx tmp dirs ───────────────────────────────────────
mkdir -p /var/lib/nginx/body /var/lib/nginx/proxy \
/var/lib/nginx/fastcgi /var/lib/nginx/uwsgi \
/var/lib/nginx/scgi
chown -R www-data:www-data /var/lib/nginx
# ── Hand off to supervisord ──────────────────────────────────
log "Launching supervisord (manages all services)…"
echo ""
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf