Spaces:
Sleeping
Sleeping
Create start.sh
Browse files
start.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
DATA_DIR=/data
|
| 5 |
+
JSON_FILE=/defaults/library.json
|
| 6 |
+
|
| 7 |
+
# Création du dossier persistant et attribution des droits à l'utilisateur archivebox (UID 911)
|
| 8 |
+
mkdir -p "$DATA_DIR"
|
| 9 |
+
chown -R 911:911 "$DATA_DIR"
|
| 10 |
+
|
| 11 |
+
# Initialisation d’ArchiveBox si la base n’existe pas encore
|
| 12 |
+
if [ ! -f "$DATA_DIR/index.sqlite3" ]; then
|
| 13 |
+
echo "=== Initialisation d'ArchiveBox ==="
|
| 14 |
+
gosu 911 archivebox init --setup
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
# Ajout automatique des URLs définies dans library.json
|
| 18 |
+
if [ -f "$JSON_FILE" ]; then
|
| 19 |
+
echo "=== Ajout des URLs depuis library.json ==="
|
| 20 |
+
python3 -c "
|
| 21 |
+
import json, subprocess
|
| 22 |
+
|
| 23 |
+
with open('$JSON_FILE') as f:
|
| 24 |
+
data = json.load(f)
|
| 25 |
+
for url in data.get('urls', []):
|
| 26 |
+
print(f'Ajout de {url}...')
|
| 27 |
+
subprocess.run(['gosu', '911', 'archivebox', 'add', url], check=False)
|
| 28 |
+
"
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
echo "=== Démarrage du serveur ArchiveBox ==="
|
| 32 |
+
exec gosu 911 archivebox server --port 7860 --quick-init 0.0.0.0
|