Browse Source

Merge pull request #1 from lncm/dockerpatch

Add LND container control feature into the neutrino switcher
master
BT 4 years ago
committed by GitHub
parent
commit
bcfa86abee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Dockerfile
  2. 8
      README.md
  3. 15
      switch.sh

2
Dockerfile

@ -1,6 +1,6 @@
FROM alpine:3.10
RUN apk add --no-cache curl jq bash
RUN apk add --no-cache curl jq bash docker
RUN mkdir /lnd/
RUN mkdir /secrets/

8
README.md

@ -8,16 +8,22 @@
docker pull lncm/neutrino-switcher
```
## If using docker-compose
- Container name of LND needs to match the environment variable defined (if not lnd)
## Files/Folders it needs access to
You may map these anywhere in your filesystem. For best results works best with a similar setup to [this one](https://github.com/lncm/thebox-compose-system)
- /secrets/rpcpass.txt (Bitcoin RPC Password)
- /lnd/lnd.conf (LND configuration. For best results write access please)
- /statuses/ (Write access for notifying of changes to other scripts for now)
- /statuses/ (Write access)
- /var/run/docker.sock (is mapped correctly so it can restart the container)
## Environment Variables
Other than that everything should be in the default paths.
- JSONRPCURL (Default: http://10.254.2.2:8332) : Is the JSON-RPC interface for bitcoind
- LND_CONTAINER_NAME (Default: lnd) : is the container name to restart

15
switch.sh

@ -22,6 +22,11 @@ if [ -z $JSONRPCURL ]; then
JSONRPCURL="http://10.254.2.2:8332"
fi
# if LND_CONTAINER_NAME doesn't exist then set it
if [ -z $LND_CONTAINER_NAME ]; then
LND_CONTAINER_NAME="lnd"
fi
while true; do
IS_NEUTRINO=`grep -c 'bitcoin.node=neutrino' /lnd/lnd.conf`
if [ $IS_NEUTRINO -eq 1 ]; then
@ -48,6 +53,16 @@ while true; do
echo "Bitcoind has been switched across to neutrino"
touch /statuses/node-status-bitcoind-ready
sed -i 's/bitcoin.node\=neutrino/bitcoin.node\=bitcoind/g; ' /lnd/lnd.conf
echo "Attempting to Restarting LND"
if command -v docker &> /dev/null; then
# restart docker
docker stop $LND_CONTAINER_NAME
docker start $LND_CONTAINER_NAME
else
echo "Docker command doesn't exist, reverting config"
rm /statuses/node-status-bitcoind-ready
sed -i 's/bitcoin.node\=bitcoind/bitcoin.node\=neutrino/g; ' /lnd/lnd.conf
fi
else
echo "Node isn't full synched yet"
fi

Loading…
Cancel
Save