Spaces:
Sleeping
Sleeping
Upload start.sh with huggingface_hub
Browse files
start.sh
CHANGED
|
@@ -1,8 +1,29 @@
|
|
| 1 |
-
#!/bin/
|
| 2 |
-
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# ==============================================================================
|
| 3 |
+
# start.sh – Bootstrap script for n8n on Hugging Face Spaces
|
| 4 |
+
#
|
| 5 |
+
# Runs as root (PID 1 is tini), fixes the permission wall, then drops
|
| 6 |
+
# privileges to uid 1000 before executing n8n.
|
| 7 |
+
# ==============================================================================
|
| 8 |
+
set -euo pipefail
|
| 9 |
+
|
| 10 |
+
N8N_DATA="/data/.n8n"
|
| 11 |
+
|
| 12 |
+
echo "▸ [start.sh] Ensuring data directory exists …"
|
| 13 |
+
mkdir -p "${N8N_DATA}"
|
| 14 |
+
|
| 15 |
+
# ---------- Fix the Permission Wall -------------------------------------------
|
| 16 |
+
# HF mounts /data owned by a different uid. n8n refuses to start if config
|
| 17 |
+
# files are readable by group/other (requires 0600 / 0700).
|
| 18 |
+
echo "▸ [start.sh] Fixing ownership → 1000:1000 …"
|
| 19 |
+
chown -R 1000:1000 /data
|
| 20 |
+
|
| 21 |
+
echo "▸ [start.sh] Fixing permissions → dirs 0700, files 0600 …"
|
| 22 |
+
find "${N8N_DATA}" -type d -exec chmod 0700 {} +
|
| 23 |
+
find "${N8N_DATA}" -type f -exec chmod 0600 {} +
|
| 24 |
+
|
| 25 |
+
# ---------- Drop Privileges & Launch ------------------------------------------
|
| 26 |
+
echo "▸ [start.sh] Dropping to user 1000, starting n8n on port ${N8N_PORT:-7860} …"
|
| 27 |
+
|
| 28 |
+
# su-exec replaces the current process (no intermediate shell)
|
| 29 |
+
exec su-exec 1000:1000 n8n start
|