From ce2c04eac6e814d6422fe13521735c71a0057061 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 10 May 2023 13:56:07 +0200 Subject: [PATCH] Now PLAYER can create any G1CARTE from any Station (without TW) --- _12345.sh | 2 +- command.sh | 23 ++++++++++++++++++++--- tools/VISA.new.sh | 2 +- tools/VISA.print.sh | 43 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/_12345.sh b/_12345.sh index 9c6520d8..fa7cbd5e 100755 --- a/_12345.sh +++ b/_12345.sh @@ -132,7 +132,7 @@ while true; do for znod in $(cat ~/.zen/tmp/_swarm.${ipfsnodeid}); do # CHECK znod validity cznod=$(${MY_PATH}/tools/ipfs_to_g1.py ${znod} 2>/dev/null) - [[ ${cznod} == "" ]] && echo "xxxxxxxxxxxx BAD ${znod} xxxx ON xxxxxx ${ipfsnodeid} - ERROR - CONTINUE" && continue + [[ ${cznod} == "" || ${cznod} == "null" ]] && echo "xxxxxxxxxxxx BAD ${znod} xxxx ON xxxxxx ${ipfsnodeid} - ERROR - CONTINUE" && continue if [[ -d ~/.zen/tmp/swarm/${znod} ]]; then echo "COMPLETING MY SWARM DATA WITH ZNOD=${znod}" diff --git a/command.sh b/command.sh index e3d55044..c3926136 100755 --- a/command.sh +++ b/command.sh @@ -34,18 +34,35 @@ echo 'PRESS ENTER... '; read ## CREATE AND OR CONNECT USER PS3='Astronaute connectez votre PLAYER ___ ' - players=("MAKE G1PASS" "IMPORT G1PASS" $(ls ~/.zen/game/players | grep "@" 2>/dev/null)) + players=( "PRINT G1CARTE" "CREATE PLAYER" "IMPORT PLAYER" $(ls ~/.zen/game/players | grep "@" 2>/dev/null)) ## MULTIPLAYER select fav in "${players[@]}"; do case $fav in - "MAKE G1PASS") + "PRINT G1CARTE") + ## DIRECT VISA.print.sh + echo "'Email ?'" + read EMAIL + echo "'Secret 1 ?'" + read SALT + [[ ${SALT} == "" ]] && SALT=$(${MY_PATH}/tools/diceware.sh 4 | xargs) + echo "'Secret 2?'" + read PEPPER + [[ ${PEPPER} == "" ]] && PEPPER=$(${MY_PATH}/tools/diceware.sh 4 | xargs) + echo "'PIN ?'" + read PASS + [[ ${PASS} == "" ]] && PASS="@" + ${MY_PATH}/tools/VISA.print.sh "${EMAIL}" "$SALT" "$PEPPER" "$PASS" ## + echo "Astronaute $fav bienvenue dans le jeu de terraformation forêt jardin MadeInZion" + exit + ;; + "CREATE PLAYER") ${MY_PATH}/tools/VISA.new.sh fav=$(cat ~/.zen/tmp/PSEUDO 2>/dev/null) && rm ~/.zen/tmp/PSEUDO echo "Astronaute $fav bienvenue dans le jeu de terraformation forêt jardin MadeInZion" exit ;; - "IMPORT G1PASS") + "IMPORT PLAYER") echo "'Secret 1'" read SALT echo "'Secret 2'" diff --git a/tools/VISA.new.sh b/tools/VISA.new.sh index 7df6e460..a36b2fe5 100755 --- a/tools/VISA.new.sh +++ b/tools/VISA.new.sh @@ -48,7 +48,7 @@ if [[ $SALT != "" && PEPPER != "" ]]; then [[ $XDG_SESSION_TYPE == 'x11' ]] \ && [[ -s ~/.zen/tmp/${MOATS}/TW/index.html ]] \ - && echo "TYPE 'yes' TO RESET TW. HIT ENTER TO KEEP IT." \ + && echo "TW FOUND ENTER 'yes' TO RESET TW. HIT ENTER TO KEEP IT." \ && read ENTER \ && [[ $ENTER != "" ]] && rm ~/.zen/tmp/${MOATS}/TW/index.html diff --git a/tools/VISA.print.sh b/tools/VISA.print.sh index 7466fd87..c9b87919 100755 --- a/tools/VISA.print.sh +++ b/tools/VISA.print.sh @@ -13,18 +13,41 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized PLAYER="$1" -[[ ! -f ~/.zen/game/players/${PLAYER}/QR.png ]] &&\ - echo "ERREUR. Aucun PLAYER Astronaute connecté .ERREUR ~/.zen/game/players/${PLAYER}/" && exit 1 +SALT="$2" +PEPPER="$3" -# Check who is .current PLAYER -PLAYER=$(cat ~/.zen/game/players/${PLAYER}/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) -PSEUDO=$(cat ~/.zen/game/players/${PLAYER}/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) -G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) -ASTRONAUTENS=$(cat ~/.zen/game/players/${PLAYER}/.playerns 2>/dev/null) || ( echo "noastronautens" && exit 1 ) +PASS="$4" + +if [[ ${SALT} == "" || ${PEPPER} == "" ]]; then + + [[ ! -f ~/.zen/game/players/${PLAYER}/QR.png ]] &&\ + echo "ERREUR. Aucun PLAYER Astronaute connecté .ERREUR ~/.zen/game/players/${PLAYER}/" && exit 1 + + # Check who is .current PLAYER + PLAYER=$(cat ~/.zen/game/players/${PLAYER}/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) + PSEUDO=$(cat ~/.zen/game/players/${PLAYER}/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) + G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) + ASTRONAUTENS=$(cat ~/.zen/game/players/${PLAYER}/.playerns 2>/dev/null) || ( echo "noastronautens" && exit 1 ) + + PASS=$(cat ~/.zen/game/players/${PLAYER}/.pass) + + source ~/.zen/game/players/${PLAYER}/secret.june + +else + + echo "VIRTUAL PLAYER ${PLAYER} WELCOME - CREATING G1CARD" + VIRTUAL=1 + G1PUB=$(${MY_PATH}/keygen -t duniter "${SALT}" "${PEPPER}") + ASTRONAUTENS=$(${MY_PATH}/keygen -t ipfs "${SALT}" "${PEPPER}") + PSEUDO="${PLAYER}" + + mkdir -p ~/.zen/game/players/${PLAYER}/ + CIMG="${MY_PATH}/../images/g1ticket.png" + amzqr ${G1PUB} -l H -p "$CIMG" -c -n QRG1avatar.png -d ~/.zen/game/players/${PLAYER}/ + +fi -PASS=$(cat ~/.zen/game/players/${PLAYER}/.pass) -source ~/.zen/game/players/${PLAYER}/secret.june [[ $SALT == "" ]] && echo "BAD ACCOUNT. PLEASE BACKUP. MOVE. RESTORE." && exit 1 LP=$(ls /dev/usb/lp* | head -n 1 2>/dev/null) @@ -90,5 +113,7 @@ composite -compose Over -gravity Center -geometry +0+0 ~/.zen/tmp/one.png ${MY_P #~ rm -Rf ~/.zen/G1BILLET/tmp/${PASS} #~ rm ~/.zen/G1BILLET/tmp/${PASS}* #~ rm ~/.zen/tmp/${PASS}* +[[ $VIRTUAL == 1 ]] && rm -Rf ~/.zen/game/players/${PLAYER}/ + exit 0