mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-08-08 09:12:43 +02:00
service dyndomain
This commit is contained in:
@@ -12,13 +12,18 @@ if [ ${#chain} -eq 0 ]; then chain="main"; fi
|
|||||||
chainValue="off"
|
chainValue="off"
|
||||||
if [ "${chain}" = "test" ]; then chainValue="on"; fi
|
if [ "${chain}" = "test" ]; then chainValue="on"; fi
|
||||||
|
|
||||||
|
# map domain to on/off
|
||||||
|
domainValue="off"
|
||||||
|
if [ ${#dynDomain} -gt 0 ]; then domainValue="on"; fi
|
||||||
|
|
||||||
# show select dialog
|
# show select dialog
|
||||||
CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 40 6 \
|
CHOICES=$(dialog --checklist "Activate/Deactivate Services:" 15 45 7 \
|
||||||
1 "Channel Autopilot" ${autoPilot} \
|
1 "Channel Autopilot" ${autoPilot} \
|
||||||
2 "Testnet" ${chainValue} \
|
2 "Testnet" ${chainValue} \
|
||||||
3 "Router AutoNAT" ${autoNatDiscovery} \
|
3 "Router AutoNAT" ${autoNatDiscovery} \
|
||||||
4 "Run behind TOR" ${runBehindTor} \
|
4 "DynnamicDNS (domainname)" ${updateDynDomain} \
|
||||||
5 "RTL Webinterface" ${rtlWebinterface} \
|
5 "Run behind TOR" ${runBehindTor} \
|
||||||
|
4 "RTL Webinterface" ${rtlWebinterface} \
|
||||||
2>&1 >/dev/tty)
|
2>&1 >/dev/tty)
|
||||||
dialogcancel=$?
|
dialogcancel=$?
|
||||||
clear
|
clear
|
||||||
@@ -125,9 +130,25 @@ else
|
|||||||
echo "AutoNAT Setting unchanged."
|
echo "AutoNAT Setting unchanged."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TOR process choice
|
# Dynamic Domain
|
||||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "4")
|
choice="off"; check=$(echo "${CHOICES}" | grep -c "4")
|
||||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||||
|
if [ "${domainValue}" != "${choice}" ]; then
|
||||||
|
echo "Dynamic Domain changed .."
|
||||||
|
if [ "${choice}" = "on" ]; then
|
||||||
|
# turn on - will ask for more info with dialogs
|
||||||
|
sudo /home/admin/config.scripts/internet.dyndomain.sh on
|
||||||
|
else
|
||||||
|
# turn off
|
||||||
|
sudo /home/admin/config.scripts/internet.dyndomain.sh off
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Dynamic Domain unchanged."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TOR process choice
|
||||||
|
choice="off"; check=$(echo "${CHOICES}" | grep -c "5")
|
||||||
|
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||||
if [ "${runBehindTor}" != "${choice}" ]; then
|
if [ "${runBehindTor}" != "${choice}" ]; then
|
||||||
echo "TOR Setting changed .."
|
echo "TOR Setting changed .."
|
||||||
sudo /home/admin/config.scripts/internet.tor.sh ${choice}
|
sudo /home/admin/config.scripts/internet.tor.sh ${choice}
|
||||||
@@ -137,7 +158,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# RTL process choice
|
# RTL process choice
|
||||||
choice="off"; check=$(echo "${CHOICES}" | grep -c "5")
|
choice="off"; check=$(echo "${CHOICES}" | grep -c "6")
|
||||||
if [ ${check} -eq 1 ]; then choice="on"; fi
|
if [ ${check} -eq 1 ]; then choice="on"; fi
|
||||||
if [ "${rtlWebinterface}" != "${choice}" ]; then
|
if [ "${rtlWebinterface}" != "${choice}" ]; then
|
||||||
echo "RTL Webinterface Setting changed .."
|
echo "RTL Webinterface Setting changed .."
|
||||||
|
@@ -117,6 +117,15 @@ else
|
|||||||
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile}
|
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# DYNAMIC DNS
|
||||||
|
if [ "${#dynDomain}" -gt 0 ]; then
|
||||||
|
echo "Provisioning DYNAMIC DNS - run config script" >> ${logFile}
|
||||||
|
sudo sed -i "s/^message=.*/message='Setup DynamicDNS'/g" ${infoFile}
|
||||||
|
sudo /home/admin/config.scripts/internet.dyndomain.sh on ${dynDomain} ${dynUpdateUrl} >> ${logFile} 2>&1
|
||||||
|
else
|
||||||
|
echo "Provisioning DYNAMIC DNS - keep default" >> ${logFile}
|
||||||
|
fi
|
||||||
|
|
||||||
# RTL
|
# RTL
|
||||||
if [ "${rtlWebinterface}" = "on" ]; then
|
if [ "${rtlWebinterface}" = "on" ]; then
|
||||||
echo "Provisioning RTL - run config script" >> ${logFile}
|
echo "Provisioning RTL - run config script" >> ${logFile}
|
||||||
|
128
home.admin/config.scripts/internet.dyndomain.sh
Executable file
128
home.admin/config.scripts/internet.dyndomain.sh
Executable file
@@ -0,0 +1,128 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# command info
|
||||||
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
|
echo "small config script to set a dynamic domain like freeDNS"
|
||||||
|
echo "internet.dyndomain.sh [on|off] [?domainName] [?updateURL]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 1. parameter [on|off]
|
||||||
|
turn="off"
|
||||||
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then turn="on"; fi
|
||||||
|
|
||||||
|
# 2. parameter [?domainName]
|
||||||
|
dynDomain=$2
|
||||||
|
|
||||||
|
# 3. parameter [?domainName]
|
||||||
|
updateDynDomain=$3
|
||||||
|
|
||||||
|
# run interactive if 'turn on' && no further parameters
|
||||||
|
if [ "${turn}"= "on" ] && [ ${#dynDomain} -eq 0 ]; then
|
||||||
|
|
||||||
|
dialog --backtitle "DynamicDNS" --inputbox "ENTER the Dynamic Domain Name:
|
||||||
|
|
||||||
|
For more details see chapter in GitHub README
|
||||||
|
'Public Domain with dynmic IP'
|
||||||
|
https://github.com/rootzoll/raspiblitz
|
||||||
|
|
||||||
|
example: freedns.afraid.org
|
||||||
|
" 13 52 2>./.tmp
|
||||||
|
dynDomain=$( cat ./.tmp )
|
||||||
|
if [ ${#dynDomain} -eq 0 ]; then
|
||||||
|
echo "FAIL input cannot be empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dialog --backtitle "DynamicDNS" --inputbox "OPTIONAL Public IP Update URL:
|
||||||
|
|
||||||
|
The RaspiBlitz will call this URL regularly.
|
||||||
|
4 service freedns.afraid.org use 'DirectURL'
|
||||||
|
" 10 52 2>./.tmp
|
||||||
|
dynUpdateUrl=$( cat ./.tmp )
|
||||||
|
shred ./.tmp
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# config file
|
||||||
|
configFile="/mnt/hdd/raspiblitz.conf"
|
||||||
|
|
||||||
|
# lnd conf file
|
||||||
|
lndConfig="/mnt/hdd/lnd/lnd.conf"
|
||||||
|
|
||||||
|
# check if config file exists
|
||||||
|
configExists=$(ls ${configFile} | grep -c '.conf')
|
||||||
|
if [ ${configExists} -eq 0 ]; then
|
||||||
|
echo "FAIL - missing ${configFile}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make sure entry line for 'dynDomain' exists
|
||||||
|
entryExists=$(cat ${configFile} | grep -c 'dynDomain=')
|
||||||
|
if [ ${entryExist} -eq 0 ]; then
|
||||||
|
echo "dynDomain=" >> ${configFile}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make sure entry line for 'dynDomain' exists
|
||||||
|
entryExists=$(cat ${configFile} | grep -c 'updateDynDomain')
|
||||||
|
if [ ${entryExist} -eq 0 ]; then
|
||||||
|
echo "updateDynDomain=" >> ${configFile}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# stop services
|
||||||
|
echo "making sure services are not running"
|
||||||
|
sudo systemctl stop lnd 2>/dev/null
|
||||||
|
|
||||||
|
# switch on
|
||||||
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||||
|
echo "switching the DynamicDNS ON"
|
||||||
|
|
||||||
|
# setting value in raspi blitz config
|
||||||
|
sudo sed -i "s/^dynDomain=.*/dynDomain='${dynDomain}'/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
sudo sed -i "s/^dynUpdateUrl=.*/dynUpdateUrl='${dynUpdateUrl}'/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
# lnd.conf: uncomment tlsextradomain (just if it is still uncommented)
|
||||||
|
sudo sed -i "s/^#tlsextradomain=.*/tlsextradomain='/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
# lnd.conf: domain value
|
||||||
|
sudo sed -i "s/^tlsextradomain=.*/tlsextradomain=${dynDomain}'/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
echo "DynamicDNS is now ON"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# switch off
|
||||||
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||||
|
echo "switching DynamicDNS OFF"
|
||||||
|
|
||||||
|
# setting value in raspi blitz config
|
||||||
|
sudo sed -i "s/^dynDomain=.*/dynDomain=/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
sudo sed -i "s/^dynUpdateUrl=.*/dynUpdateUrl=/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
# lnd.conf: comment tlsextradomain out
|
||||||
|
sudo sed -i "s/^tlsextradomain=.*/#tlsextradomain='/g" /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
echo "DynamicDNS is now OFF"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "deleting TLSCert"
|
||||||
|
sudo rm /mnt/hdd/lnd/tls.* 2>/dev/null
|
||||||
|
echo "let lnd generate new TLSCert"
|
||||||
|
sudo systemctl restart lnd
|
||||||
|
echo "wait until generated"
|
||||||
|
newCertExists=0
|
||||||
|
count=0
|
||||||
|
while [ ${newCertExists} -eq 0 ]
|
||||||
|
do
|
||||||
|
count=$(($count + 1))
|
||||||
|
if [ ${count} -gt 60 ]; then
|
||||||
|
echo "FAIL - was not able to generate new LND certs""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
newCertExists=$(sudo ls /mnt/hdd/lnd/tls.cert | grep -c '.cert')
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "copy new cert to admin user"
|
||||||
|
sudo cp /mnt/hdd/lnd/tls.cert /home/admin/.lnd
|
||||||
|
|
||||||
|
echo "may needs reboot to run normal again"
|
||||||
|
exit 0
|
Reference in New Issue
Block a user