Skip to content

Commit

Permalink
remove sed from firstrun.sh as it is not available in docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Henke committed Nov 23, 2022
1 parent 634bb55 commit 2941ad1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
24 changes: 14 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ services:
firstrun:
container_name: firstrun
image: docker:latest
restart: never
restart: "no"
volumes:
- lnd:/data/.lnd
- tor/torrc-lnd:/etc/tor/torrc
- firstrun.sh:/firstrun.sh
command: /firstrun.sh
- ./lnd:/lnd
- ./tor/torrc-lnd:/tor/torrc-lnd
- ./firstrun.sh:/firstrun.sh:ro
command: sh -c "cd / && sh /firstrun.sh"

tor:
container_name: watchtower_tor
image: lncm/tor:0.4.7.9
user: toruser
restart: on-failure
volumes:
- tor/torrc-lnd:/etc/tor/torrc
- tor/data:/var/lib/tor/
- ./tor/torrc-lnd:/etc/tor/torrc:ro
- ./tor/data:/var/lib/tor/
depends_on:
- firstrun
firstrun:
condition: service_completed_successfully
networks:
default:
ipv4_address: 172.0.0.2
Expand All @@ -29,9 +30,12 @@ services:
image: lightninglabs/lnd:v0.15.4-beta
user: 1000:1000
depends_on:
- tor, firstrun
firstrun:
condition: service_completed_successfully
tor:
condition: service_started
volumes:
- ${PWD}/lnd:/data/.lnd
- ./lnd:/data/.lnd
environment:
HOME: /data
restart: on-failure
Expand Down
6 changes: 3 additions & 3 deletions firstrun.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PASSWORDLENGTH=32
PASSWORDFILE="lnd/watchtower.password"
PASSWORDFILE="/lnd/watchtower.password"
# 0. Check if a password file exists
if [ ! -f $PASSWORDFILE ] || [ $(wc -c $PASSWORDFILE | sed "s/ */ /g" | cut -d " " -f 2 || echo 0) -ne $PASSWORDLENGTH ]; then

Expand All @@ -12,6 +12,6 @@ if [ ! -f $PASSWORDFILE ] || [ $(wc -c $PASSWORDFILE | sed "s/ */ /g" | cut -d
# 2. generate tor control password and set up lnd and tor
TORPASSWORD=$(< /dev/urandom tr -dc "[:alnum:]" | head -c$PASSWORDLENGTH)
HASHED_TOR_PASSWORD=$(docker run --rm lncm/tor:0.4.7.9 --hash-password $TORPASSWORD)
sed -i .bak "s/tor.password=.*/tor.password=$TORPASSWORD/" lnd/lnd.conf && rm lnd/lnd.conf.bak
sed -i .bak "s/HashedControlPassword .*/HashedControlPassword $HASHED_TOR_PASSWORD/" tor/torrc-lnd && rm tor/torrc-lnd.bak
echo "tor.password=$TORPASSWORD" >> /lnd/lnd.conf
echo "HashedControlPassword $HASHED_TOR_PASSWORD" >> /tor/torrc-lnd
fi
3 changes: 1 addition & 2 deletions lnd/lnd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nolisten=false

maxpendingchannels=0
feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json
wallet-unlock-password-file=/data/.lnd/data/watchtower.password
wallet-unlock-password-file=/data/.lnd/watchtower.password
no-rest-tls=true

[Bitcoin]
Expand All @@ -24,4 +24,3 @@ tor.socks=9050
tor.v3=true
tor.control=172.0.0.2:29051
tor.socks=172.0.0.2:9050
tor.password=pB2o8b8osXv1uYG6bErq86EJItnluMYd
2 changes: 0 additions & 2 deletions tor/torrc-lnd
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ HiddenServicePort 8080 172.0.0.3:8080
# LND gRPC Hidden Service
HiddenServiceDir /var/lib/tor/lnd-grpc
HiddenServicePort 10009 172.0.0.3:10009

HashedControlPassword 16:85DA0C9A60900E5F60D441B9C1E7559792DDAA192F7F7C8A612D461A65

0 comments on commit 2941ad1

Please sign in to comment.