mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-24 14:51:03 +01:00
lnd: autopilot and autounlock for testnet
This commit is contained in:
parent
c0d286df72
commit
8d86a8dbcf
3 changed files with 55 additions and 47 deletions
|
@ -5,11 +5,14 @@ echo "get raspiblitz config"
|
|||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# use default values from the raspiblitz.conf
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars)
|
||||
|
||||
echo "services default values"
|
||||
if [ ${#autoPilot} -eq 0 ]; then autoPilot="off"; fi
|
||||
if [ ${#${netprefix}autoPilot} -eq 0 ]; then ${netprefix}autoPilot="off"; fi
|
||||
if [ ${#autoUnlock} -eq 0 ]; then autoUnlock="off"; fi
|
||||
if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi
|
||||
if [ ${#chain} -eq 0 ]; then chain="main"; fi
|
||||
# if [ ${#chain} -eq 0 ]; then chain="main"; fi
|
||||
if [ ${#autoNatDiscovery} -eq 0 ]; then autoNatDiscovery="off"; fi
|
||||
if [ ${#networkUPnP} -eq 0 ]; then networkUPnP="off"; fi
|
||||
if [ ${#touchscreen} -eq 0 ]; then touchscreen=0; fi
|
||||
|
@ -29,9 +32,9 @@ echo "map zerotier to on/off"
|
|||
zerotierSwitch="off"
|
||||
if [ "${zerotier}" != "off" ]; then zerotierSwitch="on"; fi
|
||||
|
||||
echo "map chain to on/off"
|
||||
chainValue="off"
|
||||
if [ "${chain}" = "test" ]; then chainValue="on"; fi
|
||||
# echo "map chain to on/off"
|
||||
# chainValue="off"
|
||||
# if [ "${chain}" = "test" ]; then chainValue="on"; fi
|
||||
|
||||
echo "map domain to on/off"
|
||||
domainValue="off"
|
||||
|
@ -53,12 +56,12 @@ if [ ${touchscreen} -gt 0 ]; then
|
|||
touchscreenMenu='on'
|
||||
fi
|
||||
|
||||
echo "check autopilot by lnd.conf"
|
||||
lndAutoPilotOn=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'autopilot.active=1')
|
||||
echo "check ${netprefix}autopilot in ${netprefix}lnd.conf"
|
||||
lndAutoPilotOn=$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep -c 'autopilot.active=1')
|
||||
if [ ${lndAutoPilotOn} -eq 1 ]; then
|
||||
autoPilot="on"
|
||||
${netprefix}autoPilot="on"
|
||||
else
|
||||
autoPilot="off"
|
||||
${netprefix}autoPilot="off"
|
||||
fi
|
||||
|
||||
echo "map keysend to on/off"
|
||||
|
@ -83,11 +86,12 @@ if [ "${displayClass}" == "lcd" ]; then
|
|||
OPTIONS+=(s 'Touchscreen' ${touchscreenMenu})
|
||||
OPTIONS+=(r 'LCD Rotate' ${lcdrotateMenu})
|
||||
fi
|
||||
OPTIONS+=(a 'Channel Autopilot' ${${netprefix}autoPilot})
|
||||
if [ ${chain} = "main" ];then
|
||||
OPTIONS+=(a 'Channel Autopilot' ${autoPilot})
|
||||
OPTIONS+=(k 'Accept Keysend' ${keysend})
|
||||
fi
|
||||
# OPTIONS+=(n 'Testnet' ${chainValue})
|
||||
# OPTIONS+=(n 'Testnet' ${chainValue}) # deprecated option
|
||||
# see the parallel network in SERVICES
|
||||
OPTIONS+=(c 'Circuitbreaker (LND firewall)' ${circuitbreaker})
|
||||
OPTIONS+=(u 'LND Auto-Unlock' ${autoUnlock})
|
||||
OPTIONS+=(d 'StaticChannelBackup on DropBox' ${DropboxBackup})
|
||||
|
@ -213,7 +217,7 @@ anychange=0
|
|||
# AUTOPILOT process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "a")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${autoPilot}" != "${choice}" ]; then
|
||||
if [ "${${netprefix}autoPilot}" != "${choice}" ]; then
|
||||
echo "Autopilot Setting changed .."
|
||||
anychange=1
|
||||
sudo /home/admin/config.scripts/lnd.autopilot.sh ${choice}
|
||||
|
|
|
@ -2,62 +2,64 @@
|
|||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "small config script to switch the LND auto pilot on or off"
|
||||
echo "lnd.autopilot.sh [on|off]"
|
||||
echo "lnd.autopilot.sh [on|off] <mainnet|testnet|signet>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check lnd.conf exits
|
||||
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c 'lnd.conf')
|
||||
lndConfExists=$(sudo ls /mnt/hdd/lnd/${netprefix}lnd.conf | grep -c 'lnd.conf')
|
||||
if [ ${lndConfExists} -eq 0 ]; then
|
||||
echo "FAIL - /mnt/hdd/lnd/lnd.conf not found"
|
||||
echo "FAIL - /mnt/hdd/lnd/${netprefix}lnd.conf not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd $2)
|
||||
|
||||
# stop services
|
||||
echo "making sure services are not running"
|
||||
sudo systemctl stop lnd 2>/dev/null
|
||||
|
||||
# check if "autopilot.active" exists
|
||||
valueExists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'autopilot.active=')
|
||||
# check if "${netprefix}autopilot.active" exists
|
||||
valueExists=$(sudo cat /mnt/hdd/lnd/${netprefix}lnd.conf | grep -c '${netprefix}autopilot.active=')
|
||||
if [ ${valueExists} -eq 0 ]; then
|
||||
echo "Adding autopilot config defaults to /mnt/hdd/lnd/lnd.conf"
|
||||
sudo sed -i '$ a [autopilot]' /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i '$ a autopilot.active=0' /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i '$ a autopilot.allocation=0.6' /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i '$ a autopilot.maxchannels=5' /mnt/hdd/lnd/lnd.conf
|
||||
echo "Adding ${netprefix}autopilot config defaults to /mnt/hdd/lnd/${netprefix}lnd.conf"
|
||||
sudo sed -i '$ a [autopilot]' /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
sudo sed -i '$ a autopilot.active=0' /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
sudo sed -i '$ a autopilot.allocation=0.6' /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
sudo sed -i '$ a autopilot.maxchannels=5' /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
fi
|
||||
|
||||
# add default value to raspi config if needed
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
if [ ${#autoPilot} -eq 0 ]; then
|
||||
echo "autoPilot=off" >> /mnt/hdd/raspiblitz.conf
|
||||
if [ ${#${netprefix}autoPilot} -eq 0 ]; then
|
||||
echo "${netprefix}autoPilot=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
# switch on
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
echo "switching the LND autopilot ON"
|
||||
echo "editing /mnt/hdd/lnd/lnd.conf"
|
||||
sudo sed -i "s/^autopilot.active=.*/autopilot.active=1/g" /mnt/hdd/lnd/lnd.conf
|
||||
echo "switching the LND ${netprefix}autopilot ON"
|
||||
echo "editing /mnt/hdd/lnd/${netprefix}lnd.conf"
|
||||
sudo sed -i "s/^${netprefix}autopilot.active=.*/${netprefix}autopilot.active=1/g" /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
echo "editing /mnt/hdd/raspiblitz.conf"
|
||||
sudo sed -i "s/^autoPilot=.*/autoPilot=on/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - autopilot is now ON"
|
||||
sudo sed -i "s/^${netprefix}autoPilot=.*/${netprefix}autoPilot=on/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - ${netprefix}autopilot is now ON"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# switch off
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
echo "switching the LND autopilot OFF"
|
||||
echo "editing /mnt/hdd/lnd/lnd.conf"
|
||||
sudo sed -i "s/^autopilot.active=.*/autopilot.active=0/g" /mnt/hdd/lnd/lnd.conf
|
||||
echo "switching the LND ${netprefix}autopilot OFF"
|
||||
echo "editing /mnt/hdd/lnd/${netprefix}lnd.conf"
|
||||
sudo sed -i "s/^${netprefix}autopilot.active=.*/${netprefix}autopilot.active=0/g" /mnt/hdd/lnd/${netprefix}lnd.conf
|
||||
echo "editing /mnt/hdd/raspiblitz.conf"
|
||||
sudo sed -i "s/^autoPilot=.*/autoPilot=off/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - autopilot is now OFF"
|
||||
sudo sed -i "s/^${netprefix}autoPilot=.*/${netprefix}autoPilot=off/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - ${netprefix}autopilot is now OFF"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "FAIL - Unknown Paramter $1"
|
||||
echo "FAIL - Unknown Parameter $1"
|
||||
echo "may needs reboot to run normal again"
|
||||
exit 1
|
|
@ -14,13 +14,15 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then turn="on"; fi
|
|||
# 2. parameter [?passwordC]
|
||||
passwordC=$2
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars lnd)
|
||||
|
||||
# run interactive if 'turn on' && no further parameters
|
||||
if [ "${turn}" = "on" ] && [ ${#passwordC} -eq 0 ]; then
|
||||
|
||||
dialog --backtitle "LND Auto-Unlock" --inputbox "ENTER your PASSWORD C:
|
||||
dialog --backtitle "${netprefix}LND Auto-Unlock" --inputbox "ENTER your PASSWORD C:
|
||||
|
||||
For more details see chapter in GitHub README
|
||||
'Auto-unlock LND on startup'
|
||||
'Auto-unlock ${netprefix}LND on startup'
|
||||
https://github.com/rootzoll/raspiblitz
|
||||
|
||||
Password C will be stored on the device.
|
||||
|
@ -44,7 +46,7 @@ Password C will be stored on the device.
|
|||
# test if correct
|
||||
echo "# testing password .. please wait"
|
||||
echo "SYSTEMD RESTART LOG: lightning (LND)" > /home/admin/systemd.lightning.log
|
||||
sudo systemctl restart lnd
|
||||
sudo systemctl restart ${netprefix}lnd
|
||||
sleep 4
|
||||
error=""
|
||||
source <(sudo /home/admin/config.scripts/lnd.unlock.sh "$passwordC")
|
||||
|
@ -61,7 +63,7 @@ fi
|
|||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# lnd conf file
|
||||
lndConfig="/mnt/hdd/lnd/lnd.conf"
|
||||
lndConfig="/mnt/hdd/lnd/${netprefix}lnd.conf"
|
||||
|
||||
# check if config file exists
|
||||
configExists=$(ls ${configFile} | grep -c '.conf')
|
||||
|
@ -70,10 +72,10 @@ if [ ${configExists} -eq 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# make sure entry line for 'autoUnlock' exists
|
||||
entryExists=$(cat ${configFile} | grep -c 'autoUnlock=')
|
||||
# make sure entry line for '${netprefix}autoUnlock' exists
|
||||
entryExists=$(cat ${configFile} | grep -c '${netprefix}autoUnlock=')
|
||||
if [ ${entryExists} -eq 0 ]; then
|
||||
echo "autoUnlock=" >> ${configFile}
|
||||
echo "${netprefix}autoUnlock=" >> ${configFile}
|
||||
fi
|
||||
|
||||
# switch on
|
||||
|
@ -82,11 +84,11 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
|||
echo "# switching the Auto-Unlock ON"
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^autoUnlock=.*/autoUnlock=on/g" /mnt/hdd/raspiblitz.conf
|
||||
sudo sed -i "s/^${netprefix}autoUnlock=.*/${netprefix}autoUnlock=on/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# password C needs to be stored on RaspiBlitz
|
||||
echo "# storing password for root in /root/lnd.autounlock.pwd"
|
||||
sudo sh -c "echo \"${passwordC}\" > /root/lnd.autounlock.pwd"
|
||||
echo "# storing password for root in /root/${netprefix}lnd.autounlock.pwd "
|
||||
sudo sh -c "echo \"${passwordC}\" > /root/${netprefix}lnd.autounlock.pwd "
|
||||
|
||||
echo "# Auto-Unlock is now ON"
|
||||
echo "# NOTE: you may need to reconnect mobile/external wallets (macaroon/tls)"
|
||||
|
@ -98,11 +100,11 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
|||
echo "# switching the Auto-Unlock OFF"
|
||||
|
||||
# setting value in raspi blitz config
|
||||
sudo sed -i "s/^autoUnlock=.*/autoUnlock=off/g" /mnt/hdd/raspiblitz.conf
|
||||
sudo sed -i "s/^${netprefix}autoUnlock=.*/${netprefix}autoUnlock=off/g" /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# delete password C securly
|
||||
echo "# shredding password on for RaspiBlitz Auto-Unlock"
|
||||
sudo shred -u /root/lnd.autounlock.pwd 2>/dev/null
|
||||
sudo shred -u /root/${netprefix}lnd.autounlock.pwd 2>/dev/null
|
||||
|
||||
echo "# Auto-Unlock is now OFF"
|
||||
exit 0
|
||||
|
|
Loading…
Add table
Reference in a new issue