From 0b603c5b12ac3619b48f32237fb11df517acc1e3 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 18 Dec 2022 20:45:43 +0100 Subject: [PATCH] isLAN from route --- 12345.sh | 2 +- 20h12.process.sh | 2 +- ASTROBOT/G1Voeu.sh | 2 +- ASTROBOT/PLAYER.refresh.sh | 2 +- ASTROBOT/VOEUX.create.sh | 2 +- ASTROBOT/VOEUX.refresh.sh | 2 +- _12345.sh | 2 +- adventure/rooms/gameroom.sh | 2 +- ajouter_media.sh | 2 +- command.sh | 2 +- start.sh | 2 +- tools/Connect_PLAYER_To_Gchange.sh | 2 +- tools/VISA.new.sh | 2 +- tools/VISA.print.sh | 2 +- tools/VOEUX.print.sh | 2 +- tools/ipfs_config.sh | 2 +- tools/ipfs_setup.sh | 2 +- tools/new_file_in_astroport.sh | 2 +- tools/vlc_webcam.sh | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/12345.sh b/12345.sh index 00472dd2..cd3bf9f3 100755 --- a/12345.sh +++ b/12345.sh @@ -16,7 +16,7 @@ ME="${0##*/}" MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") myDOMAINName=$(hostname -d 2>/dev/null || domainname 2>/dev/null) myHOSTName=$(hostname |sed 's/\.'${myDOMAINName}'$//') diff --git a/20h12.process.sh b/20h12.process.sh index 39f1fa37..530f0cdf 100755 --- a/20h12.process.sh +++ b/20h12.process.sh @@ -12,7 +12,7 @@ espeak "Ding" > /dev/null 2>&1 myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" ## CLEANING ~/.zen/tmp diff --git a/ASTROBOT/G1Voeu.sh b/ASTROBOT/G1Voeu.sh index 6e34be63..3a02abe9 100755 --- a/ASTROBOT/G1Voeu.sh +++ b/ASTROBOT/G1Voeu.sh @@ -64,7 +64,7 @@ echo # CRYPTO BUG. TODO use natools to protect and share key with Ŋ1 only ;) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" echo " Passerelle : $myIP" diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh index 7503e7dc..44e6e113 100755 --- a/ASTROBOT/PLAYER.refresh.sh +++ b/ASTROBOT/PLAYER.refresh.sh @@ -58,7 +58,7 @@ for PLAYER in ${PLAYERONE[@]}; do mkdir -p ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/ myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" echo "Getting latest online TW..." diff --git a/ASTROBOT/VOEUX.create.sh b/ASTROBOT/VOEUX.create.sh index 11566b16..afffe572 100755 --- a/ASTROBOT/VOEUX.create.sh +++ b/ASTROBOT/VOEUX.create.sh @@ -23,7 +23,7 @@ ASTRONAUTENS=$(ipfs key list -l | grep -w $PLAYER | cut -d ' ' -f1) [[ ! $ASTRONAUTENS ]] && echo "$PLAYER IPNS INTROUVABLE" && exit 1 myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" ## EXPORT [tag[voeu]] diff --git a/ASTROBOT/VOEUX.refresh.sh b/ASTROBOT/VOEUX.refresh.sh index fb5fec86..ca8bc5cd 100755 --- a/ASTROBOT/VOEUX.refresh.sh +++ b/ASTROBOT/VOEUX.refresh.sh @@ -31,7 +31,7 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" mkdir -p ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu diff --git a/_12345.sh b/_12345.sh index 611b23af..20208b32 100755 --- a/_12345.sh +++ b/_12345.sh @@ -12,7 +12,7 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" PORT=12345 diff --git a/adventure/rooms/gameroom.sh b/adventure/rooms/gameroom.sh index 52319535..1c6a27e6 100755 --- a/adventure/rooms/gameroom.sh +++ b/adventure/rooms/gameroom.sh @@ -17,7 +17,7 @@ echo "y est raccordé... D'autres fils sortent de l'appareil. Une webcam. Une i echo echo "Que voulez vous faire?" myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="127.0.1.1" while true; do diff --git a/ajouter_media.sh b/ajouter_media.sh index be700125..a2b0b14c 100755 --- a/ajouter_media.sh +++ b/ajouter_media.sh @@ -67,7 +67,7 @@ IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) BROWSER=$(xdg-settings get default-web-browser | cut -d '.' -f 1 | cut -d '-' -f 1) ## GET cookies-from-browser myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" if [ $URL ]; then diff --git a/command.sh b/command.sh index faf6cad8..3879c928 100755 --- a/command.sh +++ b/command.sh @@ -7,7 +7,7 @@ MY_PATH="`dirname \"$0\"`" MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" ME="${0##*/}" diff --git a/start.sh b/start.sh index b0b1ea01..36c5bc9f 100755 --- a/start.sh +++ b/start.sh @@ -7,7 +7,7 @@ MY_PATH="`dirname \"$0\"`" MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" ME="${0##*/}" diff --git a/tools/Connect_PLAYER_To_Gchange.sh b/tools/Connect_PLAYER_To_Gchange.sh index b9beed40..ce9c031d 100755 --- a/tools/Connect_PLAYER_To_Gchange.sh +++ b/tools/Connect_PLAYER_To_Gchange.sh @@ -4,7 +4,7 @@ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" IPFSNODEID=$(ipfs id -f='\n') diff --git a/tools/VISA.new.sh b/tools/VISA.new.sh index d853cfd8..50ca8c9a 100755 --- a/tools/VISA.new.sh +++ b/tools/VISA.new.sh @@ -28,7 +28,7 @@ LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) ################################################################################ myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="localhost" [[ $isLAN ]] && myIPFSGW="http://ipfs.localhost:8080" && myASTROPORT="http://astroport.localhost:1234" ## LAN STATION diff --git a/tools/VISA.print.sh b/tools/VISA.print.sh index 34fd73a3..1a3c203c 100755 --- a/tools/VISA.print.sh +++ b/tools/VISA.print.sh @@ -50,7 +50,7 @@ sudo brother_ql_print /tmp/toprint.bin $LP ################################################################ ### PRINT PLAYER TW myIP link myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3) diff --git a/tools/VOEUX.print.sh b/tools/VOEUX.print.sh index 419ede31..9ee9063d 100755 --- a/tools/VOEUX.print.sh +++ b/tools/VOEUX.print.sh @@ -20,7 +20,7 @@ ASTRONAUTENS=$(ipfs key list -l | grep -w "${G1PUB}" | cut -d ' ' -f 1) MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" diff --git a/tools/ipfs_config.sh b/tools/ipfs_config.sh index febb410b..f0f59b2e 100755 --- a/tools/ipfs_config.sh +++ b/tools/ipfs_config.sh @@ -3,7 +3,7 @@ # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ myIP=$(hostname -I | awk '{print $1}') -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") ########################################### ### IMPORTANT !!!!!!! IMPORTANT !!!!!! diff --git a/tools/ipfs_setup.sh b/tools/ipfs_setup.sh index 188feb16..6bf0a40e 100755 --- a/tools/ipfs_setup.sh +++ b/tools/ipfs_setup.sh @@ -23,7 +23,7 @@ err() { # CHECK node IP isLAN? myIP=$(hostname -I | awk '{print $1}') -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); MACHINE_TYPE=`uname -m` diff --git a/tools/new_file_in_astroport.sh b/tools/new_file_in_astroport.sh index 8110925a..7e641ac2 100755 --- a/tools/new_file_in_astroport.sh +++ b/tools/new_file_in_astroport.sh @@ -22,7 +22,7 @@ IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" alias zenity='zenity 2> >(grep -v GtkDialog >&2)' diff --git a/tools/vlc_webcam.sh b/tools/vlc_webcam.sh index e1277566..b240c01c 100755 --- a/tools/vlc_webcam.sh +++ b/tools/vlc_webcam.sh @@ -26,7 +26,7 @@ LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d MOATS=$(date -u +"%Y%m%d%H%M%S%4N") IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) myIP=$(hostname -I | awk '{print $1}' | head -n 1) -isLAN=$(echo $(ip route list match 0/0 | awk '{print $3}') | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") +isLAN=$(route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") [[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost" mkdir -p ~/.zen/game/players/${PLAYER}/vlog