File size: 872 Bytes
92b3c94
 
 
 
 
 
 
 
 
d677cf3
92b3c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d677cf3
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -e

DATA_DIR=/data
JSON_FILE=/defaults/library.json

mkdir -p "$DATA_DIR"
chown -R 911:911 "$DATA_DIR"

# Initialisation de la base si elle n’existe pas encore
if [ ! -f "$DATA_DIR/index.sqlite3" ]; then
    echo "=== Initialisation d'ArchiveBox ==="
    gosu 911 archivebox init --setup
fi

# Ajout automatique des URLs définies dans library.json
if [ -f "$JSON_FILE" ]; then
    echo "=== Ajout des URLs depuis library.json ==="
    python3 -c "
import json, subprocess
with open('$JSON_FILE') as f:
    data = json.load(f)
for url in data.get('urls', []):
    print(f'Ajout de {url}...')
    subprocess.run(['gosu', '911', 'archivebox', 'add', url], check=False)
"
fi

echo "=== Démarrage du serveur ArchiveBox sur le port 7860 ==="
# Le port se passe sous la forme 0.0.0.0:7860, sans --port
exec gosu 911 archivebox server --quick-init 0.0.0.0:7860