mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2024-11-20 10:12:06 +01:00
#400 added BTC UPnP to service menu
This commit is contained in:
parent
315ee8bb56
commit
0559500c71
@ -12,6 +12,7 @@ if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi
|
||||
if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; 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
|
||||
|
||||
echo "map chain to on/off"
|
||||
chainValue="off"
|
||||
@ -42,7 +43,8 @@ CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to a
|
||||
4 'Run behind TOR' ${runBehindTor} \
|
||||
5 'RTL Webinterface' ${rtlWebinterface} \
|
||||
6 'LND Auto-Unlock' ${autoUnlock} \
|
||||
7 'AutoNAT / UPnP' ${autoNatDiscovery} \
|
||||
7 'BTC UPnP (AutoNAT)' ${networkUPnP} \
|
||||
8 'LND UPnP (AutoNAT)' ${autoNatDiscovery} \
|
||||
2>&1 >/dev/tty)
|
||||
dialogcancel=$?
|
||||
echo "done dialog"
|
||||
@ -215,9 +217,28 @@ else
|
||||
echo "LND Autounlock Setting unchanged."
|
||||
fi
|
||||
|
||||
# AutoNAT
|
||||
# UPnP
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "7")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${networkUPnP}" != "${choice}" ]; then
|
||||
echo "BTC UPnP Setting changed .."
|
||||
anychange=1
|
||||
if [ "${choice}" = "on" ]; then
|
||||
echo "Starting BTC UPNP ..."
|
||||
/home/admin/config.scripts/network.upnp.sh on
|
||||
needsReboot=1
|
||||
else
|
||||
echo "Stopping BTC UPNP ..."
|
||||
/home/admin/config.scripts/network.upnp.sh off
|
||||
needsReboot=1
|
||||
fi
|
||||
else
|
||||
echo "BTC UPnP Setting unchanged."
|
||||
fi
|
||||
|
||||
# AutoNAT
|
||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "8")
|
||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||
if [ "${autoNatDiscovery}" != "${choice}" ]; then
|
||||
echo "AUTO NAT Setting changed .."
|
||||
anychange=1
|
||||
|
@ -135,9 +135,18 @@ else
|
||||
echo "Provisioning AUTO PILOT - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# AUTO NAT DISCOVERY
|
||||
# NETWORK UPNP
|
||||
if [ "${networkUPnP}" = "on" ]; then
|
||||
echo "Provisioning NETWORK UPnP - run config script" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup UPnP'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/network.upnp.sh on >> ${logFile} 2>&1
|
||||
else
|
||||
echo "Provisioning NETWORK UPnP - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# LND AUTO NAT DISCOVERY
|
||||
if [ "${autoNatDiscovery}" = "on" ]; then
|
||||
echo "Provisioning AUTO NAT DISCOVERY - run config script" >> ${logFile}
|
||||
echo "Provisioning LND AUTO NAT DISCOVERY - run config script" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Setup AutoNAT'/g" ${infoFile}
|
||||
sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1
|
||||
else
|
||||
|
74
home.admin/config.scripts/network.upnp.sh
Normal file
74
home.admin/config.scripts/network.upnp.sh
Normal file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# based on: https://github.com/Stadicus/guides/issues/249
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "small config script to switch the BTC UPnP on or off"
|
||||
echo "network.upnp.sh [on|off]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# load config values
|
||||
source /home/admin/raspiblitz.info 2>/dev/null
|
||||
source /mnt/hdd/raspiblitz.conf 2>/dev/null
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "FAIL - was not able to load config data / network"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check lnd.conf exits
|
||||
confExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c '${network}.conf')
|
||||
if [ ${confExists} -eq 0 ]; then
|
||||
echo "FAIL - /mnt/hdd/lnd/lnd.conf not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if "nat=" exists in lnd config
|
||||
valueExists=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep -c 'upnp=')
|
||||
if [ ${valueExists} -eq 0 ]; then
|
||||
echo "Adding upnp config defaults to /mnt/hdd/${network}/${network}.conf"
|
||||
sudo sed -i '$ a upnp=0' /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
|
||||
# stop services
|
||||
echo "making sure services are not running"
|
||||
sudo systemctl stop ${network}d 2>/dev/null
|
||||
|
||||
# add default value to raspi config if needed
|
||||
if [ ${#networkUPnP} -eq 0 ]; then
|
||||
echo "networkUPnP=off" >> /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
# switch on
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
echo "switching the NETWORK UPnP ON"
|
||||
# editing config
|
||||
echo "editing /mnt/hdd/${network}/${network}.conf"
|
||||
sudo sed -i "s/^upnp=.*/upnp=1/g" /mnt/hdd/${network}/${network}.conf
|
||||
# edit raspi blitz config
|
||||
echo "editing /mnt/hdd/raspiblitz.conf"
|
||||
sudo sed -i "s/^networkUPnP=.*/networkUPnP=on/g" /mnt/hdd/raspiblitz.conf
|
||||
# enable lnd service
|
||||
echo "OK - UPnP is now ON"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# switch off
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
echo "switching the NETWORK UPnP OFF"
|
||||
# editing config
|
||||
echo "editing /mnt/hdd/${network}/${network}.conf"
|
||||
sudo sed -i "s/^upnp=.*/upnp=0/g" /mnt/hdd/${network}/${network}.conf
|
||||
# edit raspi blitz config
|
||||
echo "editing /mnt/hdd/raspiblitz.conf"
|
||||
sudo sed -i "s/^networkUPnP=.*/networkUPnP=off/g" /mnt/hdd/raspiblitz.conf
|
||||
# enable lnd service
|
||||
echo "OK - UPnP is now OFF"
|
||||
echo "needs reboot to activate new setting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "FAIL - Unknown Paramter $1"
|
||||
echo "may needs reboot to run normal again"
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user