mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-13 22:29:20 +02:00
changed testnet switch #108
This commit is contained in:
parent
87d72e7abf
commit
4ac194a0a8
@ -6,6 +6,7 @@ source /mnt/hdd/raspiblitz.conf
|
||||
# show select dialog
|
||||
CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 5 \
|
||||
1 "Channel Autopilot" ${autoPilot} \
|
||||
2 "Testnet" ${chain} \
|
||||
2>&1 >/dev/tty)
|
||||
#CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 5 \
|
||||
#1 "Channel Autopilot" ${autoPilot} \
|
||||
@ -23,6 +24,8 @@ if [ ${dialogcancel} -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
needsReboot=0
|
||||
|
||||
# AUTOPILOT process choice
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "1")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
@ -30,15 +33,33 @@ if [ "${autoPilot}" != "${choice}" ]; then
|
||||
echo "Autopilot Setting changed"
|
||||
echo "Stopping Service"
|
||||
sudo systemctl stop lnd
|
||||
echo "Changing raspiblitz.conf"
|
||||
sudo sed -i "s/^autoPilot=.*/autoPilot=${choice}/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "Executing change"
|
||||
sudo /home/admin/config.scripts/lnd.autopilot.sh ${choice}
|
||||
echo "Restarting Service"
|
||||
echo "You may need to unlock after restart ..."
|
||||
sudo systemctl start lnd
|
||||
echo "Giving LND 120 seconds to get ready ..."
|
||||
sleep 120
|
||||
needsReboot=1
|
||||
else
|
||||
echo "Autopilot Setting unchanged."
|
||||
fi
|
||||
|
||||
# TESTNET process choice
|
||||
choice="main"; check=$(echo "${CHOICES}" | grep -c "2")
|
||||
if [ ${check} -eq 1 ]; then choice="test"; fi
|
||||
if [ "${chain}" != "${choice}" ]; then
|
||||
if [ "${network}" = "litecoin" ] && [ "${choice}"="test" ]; then
|
||||
dialog --title 'FAIL' --msgbox 'Litecoin-Testnet not available.' 5 25
|
||||
else
|
||||
echo "Testnet Setting changed"
|
||||
echo "Stopping Service"
|
||||
sudo systemctl stop lnd
|
||||
sudo systemctl stop ${network}d
|
||||
echo "Executing change"
|
||||
sudo /home/admin/config.scripts/network.chain.sh ${choice}net
|
||||
needsReboot=1
|
||||
fi
|
||||
else
|
||||
echo "Testnet Setting unchanged."
|
||||
fi
|
||||
|
||||
if [ ${needsReboot} -eq 1 ]; then
|
||||
dialog --title 'OK' --msgbox 'System will reboot to activate changes.' 5 25
|
||||
sudo shutdown -r now
|
||||
fi
|
@ -27,6 +27,9 @@ fi
|
||||
if [ $1 -eq 1 ] || [ "$1" = "on" ]; then
|
||||
echo "switching the LND autopilot ON"
|
||||
sudo sed -i "s/^autopilot.active=.*/autopilot.active=1/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^autoPilot=.*/autoPilot=on/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - autopilot is now ON"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -34,6 +37,9 @@ fi
|
||||
if [ $1 -eq 0 ] || [ "$1" = "off" ]; then
|
||||
echo "switching the LND autopilot OFF"
|
||||
sudo sed -i "s/^autopilot.active=.*/autopilot.active=0/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^autoPilot=.*/autoPilot=off/g" /mnt/hdd/raspiblitz.conf
|
||||
echo "OK - autopilot is now OFF"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
67
home.admin/config.scripts/network.chain.sh
Executable file
67
home.admin/config.scripts/network.chain.sh
Executable file
@ -0,0 +1,67 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "small config script to change between testnet and mainnet"
|
||||
echo "network.chain.sh [testnet|mainnet]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check input
|
||||
if [ "$1" != "testnet" ] && [ "$1" != "mainnet" ]; then
|
||||
echo "FAIL - unknnown value: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check and load raspiblitz config
|
||||
# to know which network is running
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "FAIL - missing /mnt/hdd/raspiblitz.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# testnet on litecoin cannot be set
|
||||
if [ "${network}" = "litecoin" ] && [ "$1" = "testnet" ]; then
|
||||
echo "FAIL - no lightning support for litecoin testnet"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# editing network config files (hdd & admin user)
|
||||
echo "edit ${network} config .."
|
||||
if [ "$1" = "testnet" ]; then
|
||||
sudo sed -i "s/^testnet=.*/testnet=1/g" /mnt/hdd/${network}/${network}.conf
|
||||
sudo sed -i "s/^testnet=.*/testnet=1/g" /home/admin/.${network}/${network}.conf
|
||||
else
|
||||
sudo sed -i "s/^testnet=.*/testnet=0/g" /mnt/hdd/${network}/${network}.conf
|
||||
sudo sed -i "s/^testnet=.*/testnet=0/g" /home/admin/.${network}/${network}.conf
|
||||
fi
|
||||
|
||||
# editing lnd config files (hdd & admin user)
|
||||
echo "edit lightning config .."
|
||||
if [ "$1" = "testnet" ]; then
|
||||
sudo sed -i "s/^${network}.mainnet.*/${network}.mainnet=0/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.testnet.*/${network}.testnet=1/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.mainnet.*/${network}.mainnet=0/g" /home/admin/.lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.testnet.*/${network}.testnet=1/g" /home/admin/.lnd/lnd.conf
|
||||
else
|
||||
sudo sed -i "s/^${network}.mainnet.*/${network}.mainnet=1/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.testnet.*/${network}.testnet=0/g" /mnt/hdd/lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.mainnet.*/${network}.mainnet=1/g" /home/admin/.lnd/lnd.conf
|
||||
sudo sed -i "s/^${network}.testnet.*/${network}.testnet=0/g" /home/admin/.lnd/lnd.conf
|
||||
fi
|
||||
|
||||
# editing the raspi blitz config file
|
||||
echo "edit raspiblitz config .."
|
||||
if [ "$1" = "testnet" ]; then
|
||||
sudo sed -i "s/^chain=.*/chain=test/g" /mnt/hdd/raspiblitz.conf
|
||||
else
|
||||
sudo sed -i "s/^chain=.*/chain=main/g" /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
# now a reboot is needed to load all services fresh
|
||||
# starting up process will display chain sync
|
||||
# ask user todo reboot
|
||||
echo "OK - all configs changed to: $1"
|
||||
echo "needs reboot to activate new setting"
|
Loading…
x
Reference in New Issue
Block a user