Download entrypoint.sh from tryapp/n8n: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/spaces/tryapp/n8n/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/tryapp/n8n/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/tryapp/n8n/resolve/main/entrypoint.sh
1.73 kB
| set -e | |
| PGDATA="/data/postgres" | |
| BACKUP_DIR="/data/backups" | |
| DUMP_FILE="$BACKUP_DIR/n8n_backup.sql" | |
| PG_BIN="/usr/lib/postgresql/15/bin" | |
| restore_from_hf() { | |
| if [ -z "$HF_TOKEN" ] || [ -z "$HF_BACKUP_REPO" ]; then | |
| return | |
| fi | |
| python3 -c " | |
| from huggingface_hub import hf_hub_download | |
| try: | |
| hf_hub_download(repo_id='$HF_BACKUP_REPO', filename='n8n_backup.sql', repo_type='dataset', token='$HF_TOKEN', local_dir='$BACKUP_DIR') | |
| print('Backup downloaded from HF') | |
| except Exception as e: | |
| print(f'No backup found on HF: {e}') | |
| " | |
| } | |
| mkdir -p /data/postgres /data/backups /data/n8n /run/postgresql | |
| chown -R postgres:postgres /data/postgres /run/postgresql | |
| chmod 700 /data/postgres | |
| if [ ! -f "$PGDATA/PG_VERSION" ]; then | |
| su - postgres -c "$PG_BIN/initdb -D $PGDATA --encoding=UTF8 --locale=C" | |
| cat >> "$PGDATA/postgresql.conf" <<EOF | |
| shared_buffers = 32MB | |
| work_mem = 4MB | |
| dynamic_shared_memory_type = posix | |
| shared_memory_type = mmap | |
| listen_addresses = 'localhost' | |
| port = 5432 | |
| unix_socket_directories = '/run/postgresql' | |
| EOF | |
| su - postgres -c "$PG_BIN/pg_ctl -D $PGDATA -l /tmp/pg_init.log start -w -t 60" || { | |
| echo "=== PostgreSQL failed to start. Log: ===" | |
| cat /tmp/pg_init.log | |
| exit 1 | |
| } | |
| su - postgres -c "psql -c \"CREATE USER n8n WITH PASSWORD 'n8n_secret';\"" | |
| su - postgres -c "psql -c \"CREATE DATABASE n8n OWNER n8n;\"" | |
| su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE n8n TO n8n;\"" | |
| restore_from_hf | |
| if [ -f "$DUMP_FILE" ]; then | |
| su - postgres -c "psql -d n8n < $DUMP_FILE" || true | |
| fi | |
| su - postgres -c "$PG_BIN/pg_ctl -D $PGDATA stop -w" | |
| fi | |
| exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf | |