forked from chrisguida/fulcrum-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker_entrypoint.sh
More file actions
executable file
·91 lines (77 loc) · 3.01 KB
/
docker_entrypoint.sh
File metadata and controls
executable file
·91 lines (77 loc) · 3.01 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
set -e
# Get config
BITCOIND_TYPE=$(yq e '.bitcoind.type' /data/start9/config.yaml)
# Set RPC port based on bitcoind type
if [ "$BITCOIND_TYPE" = "bitcoind-testnet" ]; then
export BITCOIND_RPC_PORT=48332
export BITCOIND_HOST="bitcoind-testnet.embassy"
else
export BITCOIND_RPC_PORT=8332
export BITCOIND_HOST="bitcoind.embassy"
fi
if [ ! -e "$SSL_CERTFILE" ] || [ ! -e "$SSL_KEYFILE" ] ; then
openssl req -newkey rsa:2048 -sha256 -nodes -x509 -days 365 -subj "/O=Fulcrum" -keyout "$SSL_KEYFILE" -out "$SSL_CERTFILE"
fi
if [ "$1" = "Fulcrum" ] ; then
set -- "$@" -D "$DATA_DIR" -c "$SSL_CERTFILE" -k "$SSL_KEYFILE"
fi
# ignore database files for backups
echo 'fulc2_db/' > /data/.backupignore
TOR_ADDRESS=$(yq '.electrum-tor-address' /data/start9/config.yaml)
cat << EOF > /data/start9/stats.yaml
---
version: 2
data:
Quick Connect URL:
type: string
value: $TOR_ADDRESS:50001:t
description: For scanning into wallets such as BlueWallet
copyable: true
qr: true
masked: true
Hostname:
type: string
value: $TOR_ADDRESS
description: Hostname to input into wallet software such as Sparrow.
copyable: true
qr: false
masked: true
Port:
type: string
value: "50001"
description: Port to input into wallet software such as Sparrow.
copyable: true
qr: false
masked: false
EOF
configurator
# Check if this is an upgrade from Fulcrum 1.x to 2.0 and add --db-upgrade flag if needed
echo "DEBUG: Checking for database upgrade..."
echo "DEBUG: /data/db exists: $([ -d "/data/db" ] && echo "YES" || echo "NO")"
echo "DEBUG: /data/headers exists: $([ -f "/data/headers" ] && echo "YES" || echo "NO")"
echo "DEBUG: /data/txnum2txhash exists: $([ -f "/data/txnum2txhash" ] && echo "YES" || echo "NO")"
echo "DEBUG: Marker file exists: $([ -f "/data/.fulcrum-2.0-upgraded" ] && echo "YES" || echo "NO")"
ls -la /data/ || echo "DEBUG: /data directory listing failed"
FULCRUM_ARGS=""
# Check for Fulcrum 1.x database files (headers, txnum2txhash, etc.) in /data root
if ([ -f "/data/headers" ] || [ -f "/data/txnum2txhash" ] || [ -d "/data/db" ]) && [ ! -f "/data/.fulcrum-2.0-upgraded" ]; then
echo "DEBUG: Detected existing Fulcrum 1.x database files. Adding --db-upgrade flag for one-time upgrade to 2.0 format."
FULCRUM_ARGS="--db-upgrade"
# Create marker file to prevent running upgrade again
touch /data/.fulcrum-2.0-upgraded
echo "DEBUG: Created marker file /data/.fulcrum-2.0-upgraded"
else
echo "DEBUG: No database upgrade needed"
fi
# Execute Fulcrum with proper argument order
echo "DEBUG: FULCRUM_ARGS='$FULCRUM_ARGS'"
# Send all stdout/stderr through tee once, to both console and log
exec > >(tee -a /data/fulcrum.log) 2>&1
if [ -n "$FULCRUM_ARGS" ]; then
echo "DEBUG: Executing: Fulcrum $FULCRUM_ARGS /data/fulcrum.conf"
exec tini -p SIGTERM -- Fulcrum $FULCRUM_ARGS --ts-format none /data/fulcrum.conf
else
echo "DEBUG: Executing: Fulcrum /data/fulcrum.conf"
exec tini -p SIGTERM -- Fulcrum --ts-format none /data/fulcrum.conf
fi