-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmainctl
More file actions
executable file
·66 lines (60 loc) · 1.99 KB
/
Copy pathmainctl
File metadata and controls
executable file
·66 lines (60 loc) · 1.99 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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f $0)")"/..
. etc/env
if [ "$1" = "" ] || [ "$1" = "--help" ]; then
cat <<EOF
No command specified. Valid commands include:
* serve: Run electrum server
* setup: First time check
See https://github.com/binaryage/electrum-server-docker for details.
EOF
exit 1
fi
# ----------------------------------
if [ "$1" = "build" ]; then
set -x
docker build -rm -t binaryage/electrum-bitcoind bitcoind
docker build -rm -t binaryage/electrum-server electrum
elif [ "$1" == "setup" ]; then
set -x
mkdir -p "$HOST_BITCOIND_DATA_DIR"
mkdir -p "$HOST_ELECTRUM_DATA_DIR"
mkdir -p "$HOST_ELECTRUM_LEVELDB_DIR"
./do gencert
elif [ "$1" == "rm" ]; then
set -x
docker rm $BITCOIND_NODE_CONTAINER_NAME
docker rm $ELECTRUM_SERVER_CONTAINER_NAME
elif [ "$1" == "run" ]; then
set -x
bin/bitcoindctl serve
sleep 20 # TODO: wait for bitcoind to launch fully
bin/electrumctl serve
elif [ "$1" == "start" ]; then
set -x
docker start $BITCOIND_NODE_CONTAINER_NAME
sleep 20 # TODO: wait for bitcoind to launch fully
docker start $ELECTRUM_SERVER_CONTAINER_NAME
elif [ "$1" == "stop" ]; then
set -x
docker stop $ELECTRUM_SERVER_CONTAINER_NAME
docker stop $BITCOIND_NODE_CONTAINER_NAME
elif [ "$1" == "gencert" ]; then
set -x
# see https://github.com/spesmilo/electrum-server/blob/master/HOWTO.md#step-9-create-a-self-signed-ssl-cert
mkdir -p "$HOST_ELECTRUM_CERT_DIR"
cd "$HOST_ELECTRUM_CERT_DIR"
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out electrum-server.key
rm server.pass.key
openssl req -new -key electrum-server.key -out electrum-server.csr
openssl x509 -req -days 730 -in electrum-server.csr -signkey electrum-server.key -out electrum-server.crt
echo "--------------------"
ls -la *
elif [ "$1" == "rpc" ]; then
set -x
bin/bitcoindctl $@
else
echo "unknown command, run ./do --help"
fi