Spaces:
Paused
Paused
Download entrypoint.sh from 2Btainment/node-red: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/spaces/2Btainment/node-red/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/2Btainment/node-red/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/2Btainment/node-red/resolve/main/entrypoint.sh
2.36 kB
| set -euo pipefail | |
| log() { echo "[entrypoint $(date -Iseconds)] $*"; } | |
| export TZ="${TZ:-Europe/Berlin}" | |
| export PORT=1880 | |
| export FLOWS="${FLOWS:-flows.json}" | |
| if [ -d /data ] && [ -w /data ]; then | |
| USER_DIR=/data | |
| PERSIST_HINT="writable /data — still ephemeral on HF unless volume" | |
| else | |
| mkdir -p /tmp/node-red-data | |
| USER_DIR=/tmp/node-red-data | |
| PERSIST_HINT="ephemeral /tmp/node-red-data" | |
| fi | |
| mkdir -p "$USER_DIR" | |
| log "Persistence: ${PERSIST_HINT}" | |
| cp -f /einswarm/settings.js "$USER_DIR/settings.js" | |
| ADMIN_USER="${NODE_RED_ADMIN_USER:-admin}" | |
| ADMIN_PASS="${NODE_RED_ADMIN_PASSWORD:-}" | |
| export NODE_RED_ADMIN_USER="$ADMIN_USER" | |
| if [ -n "${NODE_RED_ADMIN_PASSWORD_HASH:-}" ]; then | |
| log "Using pre-set NODE_RED_ADMIN_PASSWORD_HASH for user=${ADMIN_USER}" | |
| elif [ -n "$ADMIN_PASS" ]; then | |
| export NODE_RED_ADMIN_PASSWORD="$ADMIN_PASS" | |
| HASH="$( | |
| cd /usr/src/node-red | |
| node -e ' | |
| const pw = process.env.NODE_RED_ADMIN_PASSWORD; | |
| let bcrypt; | |
| try { bcrypt = require("bcryptjs"); } | |
| catch (e) { | |
| try { bcrypt = require("/usr/src/node-red/node_modules/bcryptjs"); } | |
| catch (e2) { | |
| try { bcrypt = require("/usr/src/node-red/node_modules/node-red/node_modules/bcryptjs"); } | |
| catch (e3) { console.error("bcryptjs missing"); process.exit(1); } | |
| } | |
| } | |
| process.stdout.write(bcrypt.hashSync(pw, 8)); | |
| ' | |
| )" | |
| export NODE_RED_ADMIN_PASSWORD_HASH="$HASH" | |
| unset NODE_RED_ADMIN_PASSWORD | |
| log "Generated admin password hash for user=${ADMIN_USER}" | |
| else | |
| log "WARNING: NODE_RED_ADMIN_PASSWORD unset — editor OPEN inside private HF gate" | |
| fi | |
| if [ -z "${NODE_RED_CREDENTIAL_SECRET:-}" ]; then | |
| log "WARNING: NODE_RED_CREDENTIAL_SECRET unset" | |
| else | |
| log "NODE_RED_CREDENTIAL_SECRET is set (not logged)" | |
| fi | |
| # settings.js reads env at require-time | |
| cp -f /einswarm/settings.js "$USER_DIR/settings.js" | |
| mkdir -p /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi | |
| nginx -t | |
| nginx | |
| log "nginx listening on 0.0.0.0:7860 → 127.0.0.1:1880" | |
| log "Starting Node-RED (userDir=${USER_DIR})" | |
| cd /usr/src/node-red | |
| # Match official image: node …/red.js --userDir /data | |
| # Pass -s so our Einswarm settings (with env hash) are used. | |
| exec node ${NODE_OPTIONS:-} node_modules/node-red/red.js --userDir "$USER_DIR" -s "$USER_DIR/settings.js" | |