This commit is contained in:
fred 2024-02-13 19:55:56 +01:00
parent dd76dcbc5b
commit d11e07eb10
3 changed files with 13 additions and 89 deletions

View File

@ -87,7 +87,7 @@ echo "20H12 (♥‿‿♥) Execution time was $dur seconds."
## DRAGON SSH WOT
echo "STOP DRAGONS WOT"
${MY_PATH}/tools/DRAGON_p2p_ssh.sh off
${MY_PATH}/RUNTIME/DRAGON_p2p_ssh.sh off
## RESTART
## MAIL LOG : support@qo-op.com ##
@ -125,6 +125,6 @@ echo "OFF. RESTART IPFS"
sleep 60
sudo systemctl restart ipfs
sleep 30
${MY_PATH}/tools/DRAGON_p2p_ssh.sh
${MY_PATH}/RUNTIME/DRAGON_p2p_ssh.sh
exit 0

View File

@ -17,15 +17,22 @@ ME="${0##*/}"
###################################################################
### CREER VOTRE PROPRE VERSION DU JEU
### List games/E@MAIL/ directories
## PUT A PROPOSAL ON THE METHOD
## ADD PROPOSAL ON THE METHOD
GAMES_DIR="games"
GAMES=$(find "$GAMES_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
GAMES=$(ls $MY_PATH/games/)
GAMES=($(ls -d $MY_PATH/games/))
# Above methods are breaking with games names containing SPACE !
## cd METHOD resist to " " space
cd games && GAMES=(".." *) && cd ..
## but can still be fooled...
# BASH is CREOLE
# this cd *@* METHOD resist to " " space
cd games \
&& GAMES=(".." *@*) && cd .. \
|| GAMES=".."
## but can still be fooled by file...
## personalisez le prompt
PS3="CHOIX DU GAME : __ "
select game in "${GAMES[@]}"; do

View File

@ -1,83 +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
########################################################################
## 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