From 63b3673e6bcd6fd5fff7be56bb449e7fb3f9c1a5 Mon Sep 17 00:00:00 2001 From: qo-op Date: Sat, 16 May 2020 05:29:15 +0200 Subject: [PATCH] nodename Core command used to find make http://$NODENAME:10010 Portal --- zen/tools/{nodename_find.sh => nodename} | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) rename zen/tools/{nodename_find.sh => nodename} (61%) diff --git a/zen/tools/nodename_find.sh b/zen/tools/nodename similarity index 61% rename from zen/tools/nodename_find.sh rename to zen/tools/nodename index fcab04c..2948648 100755 --- a/zen/tools/nodename_find.sh +++ b/zen/tools/nodename @@ -4,7 +4,7 @@ # Version: 0.3 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## -{ # garanty full reading before execution +{ # Full reading before execution ! # echo ' # # __ ___ _ ___ @@ -19,17 +19,20 @@ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" +# GNU DEBIAN Core install extension [[ ! $(which nslookup) ]] && sudo apt-get update && sudo apt-get install dnsutils -y -myip=$(hostname -I | awk '{print $1}') +# What I am doing: +export myIP=$(hostname -I | awk '{print $1}') # Check if IP is from reserved LAN addresses -isLAN=$(echo $myip | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +export isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") # Find 1st route gateway -myRouter=$(sudo route -n | head -n 3 | tail -n 1 | awk '{print $2}') +export myRouter=$(sudo route -n | head -n 3 | tail -n 1 | awk '{print $2}') # Ask to the router its name (BOX DNS or system defined) -[[ $isLAN ]] && nodename=$(sudo nslookup $myip $myRouter | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//') \ -|| nodename=$(sudo nslookup $myip | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//') +[[ $isLAN ]] && export NODENAME=$(sudo nslookup $myIP $myRouter | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//') \ +|| export NODENAME=$(sudo nslookup $myIP | head -n 1 | awk -F ' = ' '{print $2}' | sed 's/\.[^.]*$//') -echo $nodename +# I can tell +echo "$NODENAME" -} +} # Full reading before execution !