Simplify localIP detection and improve compatibility (#2432)

This commit is contained in:
rek79 2021-07-22 13:09:36 -04:00 committed by GitHub
parent a2c07c4184
commit bd3c5668f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 19 deletions

View File

@ -166,10 +166,9 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
echo "# Running on ${chain}net"
echo
localIPrange=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\
grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' |\
grep 'eth0\|wlan0\|enp0\|inet' | tail -n1 | awk '{print $2}' |\
awk -F. '{print $1"."$2"."$3".0/24"}')
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' |\
grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localIP=$(hostname -I | awk '{print $1}')
allowIPrange=$(grep -c "rpcallowip=$localIPrange" < /mnt/hdd/${network}/${network}.conf)
bindIP=$(grep -c "${chain}.rpcbind=$localIP" < /mnt/hdd/${network}/${network}.conf)
rpcTorService=$(grep -c "HiddenServicePort ${BITCOINRPCPORT} 127.0.0.1:${BITCOINRPCPORT}" < /etc/tor/torrc)

View File

@ -94,7 +94,7 @@ do
echo "*** RECHECK DHCP-SERVER ***"
# get the local network IP
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
echo "localip(${localip})"
# detect a missing DHCP config

View File

@ -26,7 +26,7 @@ sudo mkdir /mnt/hdd/temp 2>/dev/null
sudo chmod 777 -R /mnt/hdd/temp 2>/dev/null
# localIP
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep -E -i '(*[eth|ens|enp|eno|wlan|wlp][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
echo "localIP='${localip}'"
# temp - no measurement in a VM

View File

@ -27,7 +27,7 @@ if [ "$1" = "status" ]; then
isInstalled=$(sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service')
echo "installed=${isInstalled}"
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localIP=$(hostname -I | awk '{print $1}')
echo "localIP='${localIP}'"
echo "httpsPort='23001'"
echo "publicIP='${publicIP}'"

View File

@ -22,7 +22,7 @@ if [ "$1" = "status" ]; then
echo "configured=1"
# get network info
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/cryptoadvance-specter/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /home/specter/.specter/cert.pem -fingerprint -noout | cut -d"=" -f2)
echo "localip='${localip}'"

View File

@ -29,7 +29,7 @@ fi
if [ "$1" = "menu" ]; then
# get network info
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/lit/hostname 2>/dev/null)
fingerprint=$(sudo openssl x509 -in /home/lit/.lit/tls.cert -fingerprint -noout | cut -d"=" -f2)
@ -382,4 +382,4 @@ fi
echo "FAIL - Unknown Parameter $1"
echo "may need reboot to run normal again"
exit 1

View File

@ -85,7 +85,7 @@ if [ "$1" = "status" ]; then
if [ "${LNBits}" = "on" ]; then
echo "installed=1"
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localIP=$(hostname -I | awk '{print $1}')
echo "localIP='${localIP}'"
echo "httpPort='5000'"
echo "httpsPort='5001'"

View File

@ -135,7 +135,7 @@ fi
# get the local IP as default host
if [ ${#host} -eq 0 ]; then
host=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
host=$(hostname -I | awk '{print $1}')
fi
# change host to dynDNS if set

View File

@ -32,7 +32,7 @@ This can take multiple hours.
fi
# get network info
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/mempool/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)

View File

@ -74,7 +74,7 @@ fi
if [ "$1" = "menu" ]; then
# get network info
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/RTL/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)

View File

@ -199,7 +199,7 @@ if [ "$1" = "status" ]; then
echo "installed=0"
fi
localIP=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localIP=$(hostname -I | awk '{print $1}')
echo "localIP='${localIP}'"
echo "httpsPort='3301'"
echo "httpPort='3300'"

View File

@ -23,7 +23,7 @@ fi
if [ "$1" = "menu" ]; then
# get network info
localip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip=$(hostname -I | awk '{print $1}')
toraddress=$(sudo cat /mnt/hdd/tor/thunderhub/hostname 2>/dev/null)
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)

View File

@ -58,11 +58,11 @@ fi
#############################################
# get local IP (from different sources)
localip_ALL=$(ip addr 2>/dev/null | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep -E -i '(*[eth|ens|enp|eno|wlan|inet|wlp][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip_ALL=$(hostname -I | awk '{print $1}')
if [ $(isValidIP ${localip_ALL}) -eq 0 ]; then
localip_ALL=""
fi
localip_LAN=$(ip addr 2>/dev/null | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep -E -i '(*[eth][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
localip_LAN=$(ip addr 2>/dev/null | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep -E -i '(*[eth][0-9]$)*' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
if [ $(isValidIP ${localip_LAN}) -eq 0 ]; then
localip_LAN=""
fi

View File

@ -123,7 +123,7 @@ elif [ "${exportType}" = "btcpay" ]; then
###########################
elif [ "${exportType}" = "scp" ]; then
local_ip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
local_ip=$(hostname -I | awk '{print $1}')
clear
echo "###### DOWNLOAD BY SCP ######"
echo "Copy, paste and execute these commands in your client terminal to download the files."
@ -141,7 +141,7 @@ elif [ "${exportType}" = "scp" ]; then
###########################
elif [ "${exportType}" = "http" ]; then
local_ip=$(ip addr | grep 'state UP' -A2 | grep -E -v 'docker0|veth' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
local_ip=$(hostname -I | awk '{print $1}')
randomPortNumber=$(shuf -i 20000-39999 -n 1)
sudo ufw allow from 192.168.0.0/16 to any port ${randomPortNumber} comment 'temp http server'
clear