forked from nbd-wtf/bitcoin_signet
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathreset-spark.sh
More file actions
executable file
·83 lines (73 loc) · 2.18 KB
/
Copy pathreset-spark.sh
File metadata and controls
executable file
·83 lines (73 loc) · 2.18 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
#!/bin/bash
# Delete the Spark operator and SSP wallet state. LDK data is kept by default.
set -euo pipefail
cd "$(dirname "$0")"
full=0
assume_yes=0
for arg in "$@"; do
case "$arg" in
--full) full=1 ;;
--yes) assume_yes=1 ;;
-h|--help)
echo "Usage: $0 [--full] [--yes]"
echo " --full Also delete the LDK wallet and channel state."
echo " --yes Do not ask for confirmation."
exit 0
;;
*)
echo "Unknown option: $arg" >&2
exit 2
;;
esac
done
volume_root=$(realpath -m "${MUTINYNET_VOLUME_ROOT:-${HOME}/volumes}")
case "$volume_root" in
/|"$HOME")
echo "Refusing unsafe volume root: $volume_root" >&2
exit 1
;;
esac
targets=(spark spark2 spark-shared ssp-data)
if [ "$full" = "1" ]; then
targets+=(ldk-server)
fi
echo "This deletes state from:"
for name in "${targets[@]}"; do
echo " $volume_root/$name"
done
if [ "$assume_yes" != "1" ]; then
read -r -p "Type RESET to continue: " confirmation
if [ "$confirmation" != "RESET" ]; then
echo "Reset cancelled"
exit 1
fi
fi
services=(spark spark2 ssp)
if [ "$full" = "1" ]; then
services+=(ldk-server)
fi
docker compose stop "${services[@]}" || true
for db in \
sparkoperator_0 spark_ephemeral_0 \
sparkoperator_1 spark_ephemeral_1; do
docker compose exec -T postgres psql \
-U lightning-rgs -d postgres \
-c "DROP DATABASE IF EXISTS $db;"
done
for name in "${targets[@]}"; do
target="$volume_root/$name"
mkdir -p "$target"
resolved=$(realpath -m "$target")
if [ "$resolved" != "$target" ] || \
[ "${resolved#"$volume_root"/}" = "$resolved" ]; then
echo "Refusing unexpected reset target: $resolved" >&2
exit 1
fi
find "$resolved" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
done
docker compose up -d --no-deps --force-recreate spark spark2
echo "Spark operators are starting with new identities."
echo "After both are healthy:"
echo " 1. Run ./spark-operator-pubkeys.sh and update .env."
echo " 2. Run docker compose up -d ldk-server ssp."
echo " 3. Run node --env-file=.env fund-ssp.mjs."