sleep well

This commit is contained in:
fred 2023-01-03 18:42:41 +01:00
parent ddc5bd7b95
commit db84c6d8cc
8 changed files with 163 additions and 131 deletions

View File

@ -193,20 +193,26 @@ while true; do
exec ${MY_PATH}/API/QRCODE.sh "$PORT" "$THAT" "$AND" "$THIS" "$APPNAME" "$WHAT" "$OBJ" "$VAL" &
;;
### USED TO TRY NEW API
"sandbox")
exec ${MY_PATH}/API/SANDBOX.sh "$PORT" "$THAT" "$AND" "$THIS" "$APPNAME" "$WHAT" "$OBJ" "$VAL" &
;;
"")
echo "ERROR UNKNOWN $CMD"
echo "$HTTPCORS
ERROR UNKNOWN $CMD : ${MOATS} : $(date)" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
end=`date +%s`
echo " ($CMD) $myHOST:$PORT / Execution time was "`expr $end - $start` seconds.
;;
### ADD API SCRIPT INTO /API
*)
[[ ! -s ${MY_PATH}/API/${CMD^^}.sh ]] \
&& ( echo "$HTTPCORS
ERROR UNKNOWN $CMD : ${MOATS} : $(date)" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & ) \
|| exec ${MY_PATH}/API/${CMD^^}.sh "$PORT" "$THAT" "$AND" "$THIS" "$APPNAME" "$WHAT" "$OBJ" "$VAL" &
;;
esac
end=`date +%s`
echo " ($CMD) $myHOST:$PORT / Launching time was "`expr $end - $start` seconds.
done
exit 0

View File

@ -56,9 +56,11 @@ echo "20H12 (♥‿‿♥) Execution time was $dur" seconds.
## MAIL LOG : support@qo-op.com
$MY_PATH/tools/mailjet.sh "support@qo-op.com" "/tmp/20h12.log"
espeak "20 12 duration was $dur seconds" > /dev/null 2>&1
espeak "20 12 Storm & Thunder duration was $dur seconds" > /dev/null 2>&1
espeak "Restarting API" > /dev/null 2>&1
sleep 12
espeak "Restarting Astroport Station API" > /dev/null 2>&1
## CLOSING API PORT
[[ -s ~/.zen/.pid ]] && kill -9 $(cat ~/.zen/.pid)
## OPEN API ENGINE

View File

@ -16,6 +16,7 @@ Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET
Server: Astroport.ONE
Content-Type: text/html; charset=UTF-8
"
start=`date +%s`

View File

@ -16,6 +16,7 @@ Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET
Server: Astroport.ONE
Content-Type: text/html; charset=UTF-8
"
start=`date +%s`

View File

@ -16,6 +16,7 @@ Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET
Server: Astroport.ONE
Content-Type: text/html; charset=UTF-8
"
start=`date +%s`
@ -138,7 +139,7 @@ PEPPER=$THIS
########################################
if [[ "$APPNAME" == "g1pub" && "$OBJ" != "email" ]]; then
[[ ${WHAT} == "astro" ]] && REPLACE="$LIBRA/ipns/$ASTRONAUTENS" \
[[ ${WHAT} == "astro" ]] && REPLACE="https://$myTUBE/ipns/${ASTRONAUTENS}" \
|| REPLACE="$myGCHANGE/#/app/user/${G1PUB}"
echo ${REPLACE}
@ -321,7 +322,9 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
fi
if [[ ! -d ~/.zen/game/players/${EMAIL} ]]; then
echo "# ASTRONAUT NEW VISA Create VISA.new.sh in background (~/.zen/tmp/email.${EMAIL}.${MOATS}.txt)"
(
startvisa=`date +%s`
[[ "$SALT" == "0" && "$PEPPER" == "0" ]] && SALT="" && PEPPER="" # "0" "0" means random salt pepper
@ -335,16 +338,23 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
cat ~/.zen/tmp/${IPFSNODEID}/_timings | tail -n 1
) &
echo "$HTTPCORS - <meta http-equiv='refresh' content='3; url=\""${myIPFS}"/ipns/"$ASTRONAUTENS"\"'/>
<h1>BOOTING - ASTRONAUT $PSEUDO </h1> IPFS FORMATING - [$SALT + $PEPPER] (${EMAIL})
<br>- TW - ${myIPFS}/ipns/$ASTRONAUTENS <br> - GW - /ipns/$IPFSNODEID" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
echo "$HTTPCORS
<meta http-equiv='refresh' content='30; url=\""${myIPFS}"/ipns/"${ASTRONAUTENS}"\"'/>
<h1>ASTRONAUTE $PSEUDO</h1>
<br>KEY : $SALT:$PEPPER:${EMAIL}
<br>TW : ${myIPFS}/ipns/${ASTRONAUTENS}
<br>STATION : ${myIPFS}/ipns/$IPFSNODEID<br><br>please wait....<br>
export ASTROTW=/ipns/${ASTRONAUTENS} ASTROG1=${G1PUB} ASTROMAIL=${EMAIL} ASTROIPFS=${myIPFS}" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
exit 0
else
# ASTRONAUT EXISTING ${EMAIL}
CHECK=$(cat ~/.zen/game/players/${EMAIL}/secret.june | grep -w "$SALT")
[[ $CHECK ]] && CHECK=$(cat ~/.zen/game/players/${EMAIL}/secret.june | grep -w "$PEPPER")
[[ ! $CHECK ]] && (echo "$HTTPCORS - WARNING - PLAYER ${EMAIL} ALREADY HERE" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0
fi
###################################################################################################

View File

@ -48,11 +48,14 @@ MOATS="$3"
###################################################################
mkdir -p $HOME/.zen/tmp/${IPFSNODEID}/G1PalPay/${PLAYER}/
mkdir -p $HOME/.zen/game/players/${PLAYER}/G1PalPay/
mkdir -p $HOME/.zen/tmp/${MOATS}
~/.zen/Astroport.ONE/tools/timeout.sh -t 12 \
${MY_PATH}/../tools/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey history -n 10 -j > $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json
[[ ! -s $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json ]] && echo "NO PAYMENT HISTORY" && exit 1
[[ ! -s $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json ]] \
&& echo "NO PAYMENT HISTORY" \
&& exit 1
## DEBUG ## cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json | jq -r
@ -84,9 +87,18 @@ for LINE in $(cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.jso
#~ $(${MY_PATH}/../tools/VISA.new.sh "$SALT" "$PEPPER" "${EMAIL}" "$PSEUDO" "${URL}" | tail -n 1) # export ASTROTW=/ipns/$ASTRONAUTENS ASTROG1=$G1PUB ASTROMAIL=$EMAIL ASTROFEED=$FEEDNS
## CREATE new PLAYER IN myASTROTUBE
curl -x ${myASTROTUBE}/?salt=0&pepper=0&g1pub=_URL&email=${EMAIL}
curl -x ${myASTROTUBE}/?salt=0&pepper=0&g1pub=_URL_&email=${EMAIL} -o ~/.zen/tmp/${MOATS}/astro.port
${MY_PATH}/../tools/mailjet.sh "${EMAIL}" "BRO. TON TW $PLAYER $(myIpfsGw)/$ASTROTW" ## WELCOME NEW PLAYER
TELETUBE=$(cat ~/.zen/tmp/${MOATS}/astro.port | grep "(◕‿‿◕)" | cut -d ':' -f 2 | cut -d '/' -f 3)
TELEPORT=$(cat ~/.zen/tmp/${MOATS}/astro.port | grep "(◕‿‿◕)" | cut -d ':' -f 3 | cut -d '"' -f 1)
sleep 12
curl -x http://$TELETUBE:$TELEPORT -o ~/.zen/tmp/${MOATS}/astro.rep
$(cat ~/.zen/tmp/${MOATS}/astro.rep | tail -n 1)
######################################################
${MY_PATH}/../tools/mailjet.sh "${EMAIL}" "BRO. $PLAYER VOUS A OFFERT UN TW : $(myIpfsGw)/$ASTROTW et " ## WELCOME NEW PLAYER
fi
@ -97,7 +109,8 @@ for LINE in $(cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.jso
G1 : $ASTROG1
RSS : $ASTROFEED"
~/.zen/Astroport.ONE/tools/timeout.sh -t 12 \
${MY_PATH}/../tools/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey history -n 10 -j > $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json
else
echo "BAD EMAIL : ${EMAIL}"
@ -191,5 +204,6 @@ done
#~ echo "XXXXXXXXXXXXXXXXXXXXXXX"
#~ fi
rm -Rf $HOME/.zen/tmp/${MOATS}
exit 0

View File

@ -141,7 +141,7 @@ select fav in "${choices[@]}"; do
#~ echo "REMOVE CESIUM+"
#~ $MY_PATH/tools/jaklis/jaklis.py -k $HOME/.zen/game/players/$PLAYER/secret.dunikey -n https://g1.data.e-is.pro erase
echo "rm -Rf ~/.zen/game/players/$PLAYER"
rm -Rf ~/.zen/game/players/$PLAYER
sudo rm -Rf ~/.zen/game/players/$PLAYER
break
;;

View File

@ -29,7 +29,7 @@ LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d
## CHECK if PLAYER resolve any ASTRONAUTENS
[[ ${PLAYER} ]] && ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
[[ ${ASTRONAUTENS} ]] && echo "WARNING IPNS $PLAYER EXISTANT ${myIPFS}/ipns/${ASTRONAUTENS} - EXIT -" && exit 0
[[ ${ASTRONAUTENS} ]] && echo "WARNING IPNS ${PLAYER} EXISTANT ${myIPFS}/ipns/${ASTRONAUTENS} - EXIT -" && exit 0
## Chargement TW !!!
if [[ $SALT != "" && PEPPER != "" ]]; then
@ -58,9 +58,9 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
rm -f ~/.zen/tmp/${MOATS}/TW/index.html
echo "CREATION TW Astronaute" ## Nouveau Compte Astronaute
echo
echo "***** Activation du Canal TW Astronaute $PLAYER *****"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
echo "***** Activation du Canal TW Astronaute ${PLAYER} *****"
mkdir -p ~/.zen/game/players/${PLAYER}/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
else
#############################################
@ -76,14 +76,14 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
[[ $IPNSTAIL == "_ASTROPORT_" ]] \
&& echo "_ASTROPORT_ TW : CONNECT TO DOCK" \
&& mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/ \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
&& mkdir -p ~/.zen/game/players/${PLAYER}/ipfs/moa/ \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html \
&& echo "- WARNING - WARNING - WARNING - WARNING - PLEASE VERIFY TW -"
[[ $IPNSTAIL == $IPFSNODEID ]] \
&& echo "UPDATING $PLAYER LOCAL CACHE ~/.zen/game/players/$PLAYER/ipfs/moa" \
&& mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/ \
&& echo "UPDATING ${PLAYER} LOCAL CACHE ~/.zen/game/players/${PLAYER}/ipfs/moa" \
&& mkdir -p ~/.zen/game/players/${PLAYER}/ipfs/moa \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/${PLAYER}/ipfs/moa/ \
|| ( echo "PLAYER ALREADY CONNECTED TO $ASTROPORT STATION" && exit 1)
else
@ -127,23 +127,21 @@ PSEUDO=${PSEUDO%%[0-9]*}
[[ $(ls ~/.zen/game/players/$PSEUDO 2>/dev/null) ]] && echo "CE PSEUDO EST DEJA UN PLAYER. EXIT" && exit 1
# PSEUDO=${PSEUDO,,} #lowercase
[[ ! $PLAYER ]] && PLAYER=${PSEUDO}${RANDOM:0:2}$(${MY_PATH}/diceware.sh 1 | xargs)${RANDOM:0:2} \
[[ ! ${PLAYER} ]] && PLAYER=${PSEUDO}${RANDOM:0:3}@$(${MY_PATH}/diceware.sh 1 | xargs).${RANDOM:0:3} \
&& echo "ADRESSE EMAIL ?" && read OPLAYER && [[ $OPLAYER ]] && PLAYER=$OPLAYER
[[ -d ~/.zen/game/players/$PLAYER ]] && echo "FATAL ERROR $PLAYER NAME COLLISION. TRY AGAIN." && exit 1
[[ ! $PSEUDO ]] && PSEUDO="Anonymous"
echo; echo "Génération de votre crypto identité PLAYER :"; sleep 1; echo "$PLAYER"; sleep 2
echo; echo "Génération de votre crypto identité PLAYER :"; sleep 1; echo "${PLAYER}"; sleep 2
# 6 DIGIT PASS CODE TO PROTECT QRSEC
PASS=$(echo "${RANDOM}${RANDOM}${RANDOM}${RANDOM}" | tail -c-7)
############################################################
######### TODO Ajouter d'autres clefs IPNS, GPG ?
# MOANS=$(ipfs key gen moa_$PLAYER)
# MOAKEYFILE=$(${MY_PATH}/give_me_keystore_filename.py "moa_$PLAYER")
# MOANS=$(ipfs key gen moa_${PLAYER})
# MOAKEYFILE=$(${MY_PATH}/give_me_keystore_filename.py "moa_${PLAYER}")
# echo "Coffre personnel multimedia journalisé dans votre 'Astroport' (amis de niveau 3)"
# echo "Votre clef moa_$PLAYER <=> $MOANS ($MOAKEYFILE)"; sleep 2
# echo "Votre clef moa_${PLAYER} <=> $MOANS ($MOAKEYFILE)"; sleep 2
############################################################
echo
echo "Votre compte Gchange et portefeuille G1.
@ -165,13 +163,13 @@ G1PUB=$(cat ~/.zen/tmp/${MOATS}/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
## CREATE Player personnal files storage and IPFS publish directory
mkdir -p ~/.zen/game/players/$PLAYER # Prepare PLAYER datastructure
mkdir -p ~/.zen/game/players/${PLAYER} # Prepare PLAYER datastructure
# PLAYER=geg-la_debrouille@super.chez-moi.com
YUSER=$(echo $PLAYER | cut -d '@' -f1) # YUSER=geg-la_debrouille
YUSER=$(echo ${PLAYER} | cut -d '@' -f1) # YUSER=geg-la_debrouille
LYUSER=($(echo "$YUSER" | sed 's/[^a-zA-Z0-9]/\ /g')) # LYUSER=(geg la debrouille)
CLYUSER=$(printf '%s\n' "${LYUSER[@]}" | tac | tr '\n' '.' ) # CLYUSER=debrouille.la.geg.
YOMAIN=$(echo $PLAYER | cut -d '@' -f 2) # YOMAIN=super.chez-moi.com
YOMAIN=$(echo ${PLAYER} | cut -d '@' -f 2) # YOMAIN=super.chez-moi.com
# echo "NEXT STYLE GW : https://ipfs.$CLYUSER$YOMAIN.$(myHostName)"
# echo "MY PLAYER API GW : $(myPlayerApiGw)"
@ -183,86 +181,86 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
####
mv ~/.zen/tmp/${MOATS}/secret.dunikey ~/.zen/game/players/$PLAYER/
mv ~/.zen/tmp/${MOATS}/secret.dunikey ~/.zen/game/players/${PLAYER}/
# Create Player "IPNS Key" (key import)
${MY_PATH}/keygen -t ipfs -o ~/.zen/game/players/$PLAYER/secret.player "$SALT" "$PEPPER"
ipfs key import $PLAYER -f pem-pkcs8-cleartext ~/.zen/game/players/$PLAYER/secret.player
ASTRONAUTENS=$(ipfs key import $G1PUB -f pem-pkcs8-cleartext ~/.zen/game/players/$PLAYER/secret.player)
${MY_PATH}/keygen -t ipfs -o ~/.zen/game/players/${PLAYER}/secret.player "$SALT" "$PEPPER"
ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/game/players/${PLAYER}/secret.player
ASTRONAUTENS=$(ipfs key import $G1PUB -f pem-pkcs8-cleartext ~/.zen/game/players/${PLAYER}/secret.player)
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/G1SSB # Prepare astrXbian sub-datastructure
mkdir -p ~/.zen/game/players/${PLAYER}/ipfs/G1SSB # Prepare astrXbian sub-datastructure
qrencode -s 12 -o ~/.zen/game/players/$PLAYER/QR.png "$G1PUB"
cp ~/.zen/game/players/$PLAYER/QR.png ~/.zen/game/players/$PLAYER/ipfs/QR.png
echo "$G1PUB" > ~/.zen/game/players/$PLAYER/ipfs/G1SSB/_g1.pubkey # G1SSB NOTATION (astrXbian compatible)
qrencode -s 12 -o ~/.zen/game/players/${PLAYER}/QR.png "$G1PUB"
cp ~/.zen/game/players/${PLAYER}/QR.png ~/.zen/game/players/${PLAYER}/ipfs/QR.png
echo "$G1PUB" > ~/.zen/game/players/${PLAYER}/ipfs/G1SSB/_g1.pubkey # G1SSB NOTATION (astrXbian compatible)
qrencode -s 12 -o ~/.zen/game/players/$PLAYER/QR.ASTRONAUTENS.png "$LIBRA/ipns/${ASTRONAUTENS}"
qrencode -s 12 -o ~/.zen/game/players/${PLAYER}/QR.ASTRONAUTENS.png "$LIBRA/ipns/${ASTRONAUTENS}"
## SEC PASS PROTECTED QRCODE
secFromDunikey=$(cat ~/.zen/game/players/$PLAYER/secret.dunikey | grep "sec" | cut -d ' ' -f2)
secFromDunikey=$(cat ~/.zen/game/players/${PLAYER}/secret.dunikey | grep "sec" | cut -d ' ' -f2)
echo "$secFromDunikey" > ~/.zen/tmp/${MOATS}/${PSEUDO}.sec
openssl enc -aes-256-cbc -salt -in ~/.zen/tmp/${MOATS}/${PSEUDO}.sec -out "$HOME/.zen/tmp/${MOATS}/enc.${PSEUDO}.sec" -k $PASS 2>/dev/null
PASsec=$(cat ~/.zen/tmp/${MOATS}/enc.${PSEUDO}.sec | base58) && rm -f ~/.zen/tmp/${MOATS}/${PSEUDO}.sec
qrencode -s 12 -o $HOME/.zen/game/players/$PLAYER/QRsec.png $PASsec
qrencode -s 12 -o $HOME/.zen/game/players/${PLAYER}/QRsec.png $PASsec
echo "Votre Clef publique G1 est : $G1PUB"; sleep 1
### INITALISATION WIKI dans leurs répertoires de publication IPFS
############ TODO améliorer templates, sed, ajouter index.html, etc...
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
# INSERT ASTROPORT ADRESS
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
tiddlywiki --load ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport)
sed -i "s~$ASTROPORT~/ipns/${IPFSNODEID}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~$ASTROPORT~/ipns/${IPFSNODEID}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
# TW CHAIN INIT WITH TWMODEL
sed -i "s~_MOATS_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_CHAIN_~${TWMODEL}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_MOATS_~${MOATS}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_CHAIN_~${TWMODEL}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_SALT_~${SALT}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_PEPPER_~${PEPPER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_PASS_~${PASS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_SALT_~${SALT}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_PEPPER_~${PEPPER}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_PASS_~${PASS}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_URL_~${URL}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_URL_~${URL}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
# INSERT PLAYER DATA
sed -i "s~_PLAYER_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_WISHKEY_~${G1PUB}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_PLAYER_~${PLAYER}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_WISHKEY_~${G1PUB}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_G1PUB_~${G1PUB}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_QRSEC_~${PASsec}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_G1PUB_~${G1PUB}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~_QRSEC_~${PASsec}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~G1Voeu~G1Visa~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~G1Voeu~G1Visa~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
# La Clef IPNS porte comme nom G1PUB
sed -i "s~_MEDIAKEY_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${ASTRONAUTENS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_MEDIAKEY_~${PLAYER}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${ASTRONAUTENS}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~tube.copylaradio.com~$myTUBE~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~ipfs.copylaradio.com~$myTUBE~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~tube.copylaradio.com~$myTUBE~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
sed -i "s~ipfs.copylaradio.com~$myTUBE~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
#
sed -i "s~127.0.0.1~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # 8080 & 5001 BEING THE RECORDING GATEWAY (WAN or ipfs.localhost)
sed -i "s~127.0.0.1~$myIP~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html # 8080 & 5001 BEING THE RECORDING GATEWAY (WAN or ipfs.localhost)
###########
echo "# CRYPTO ENCODING _SECRET_ "
$MY_PATH/natools.py encrypt -p $G1PUB -i $HOME/.zen/game/players/$PLAYER/secret.dunikey -o $HOME/.zen/tmp/${MOATS}/secret.dunikey.$G1PUB.enc
$MY_PATH/natools.py encrypt -p $G1PUB -i $HOME/.zen/game/players/${PLAYER}/secret.dunikey -o $HOME/.zen/tmp/${MOATS}/secret.dunikey.$G1PUB.enc
ENCODING=$(cat ~/.zen/tmp/${MOATS}/secret.dunikey.$G1PUB.enc | base16)
sed -i "s~_SECRET_~$ENCODING~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_SECRET_~$ENCODING~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
###########
echo "# CRYPTO DECODING TESTING..."
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
tiddlywiki --load ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
cat ~/.zen/tmp/${MOATS}/MadeInZion.json | jq -r .[].secret | base16 -d > ~/.zen/tmp/${MOATS}/crypto.$G1PUB.enc.2
$MY_PATH/natools.py decrypt -f pubsec -k $HOME/.zen/game/players/$PLAYER/secret.dunikey -i $HOME/.zen/tmp/${MOATS}/crypto.$G1PUB.enc.2 -o $HOME/.zen/tmp/${MOATS}/crypto.2
$MY_PATH/natools.py decrypt -f pubsec -k $HOME/.zen/game/players/${PLAYER}/secret.dunikey -i $HOME/.zen/tmp/${MOATS}/crypto.$G1PUB.enc.2 -o $HOME/.zen/tmp/${MOATS}/crypto.2
###########
## CRYPTO PROCESS VALIDATED
[[ -s ~/.zen/tmp/${MOATS}/crypto.2 ]] && echo "NATOOLS LOADED" \
|| sed -i "s~$ENCODING~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # Revert to plaintext _SECRET_ myIP
|| sed -i "s~$ENCODING~$myIP~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html # Revert to plaintext _SECRET_ myIP
rm -f ~/.zen/tmp/${MOATS}/crypto.2
###########
@ -270,10 +268,10 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
cat ~/.zen/Astroport.ONE/templates/data/local.api.json | sed "s~_NID_~${WID}~g" > ~/.zen/tmp/${MOATS}/local.api.json
cat ~/.zen/Astroport.ONE/templates/data/local.gw.json | sed "s~_NID_~${NID}~g" > ~/.zen/tmp/${MOATS}/local.gw.json
# Create"$PLAYER_feed" Key
# Create"${PLAYER}_feed" Key
FEEDNS=$(ipfs key gen "${PLAYER}_feed")
## MAKE LightBeam Plugin Tiddler $PLAYER_feed
## MAKE LightBeam Plugin Tiddler ${PLAYER}_feed
# $:/plugins/astroport/lightbeams/saver/ipns/lightbeam-key
echo '[{"title":"$:/plugins/astroport/lightbeams/saver/ipns/lightbeam-name","text":"'${PLAYER}_feed'","tags":""}]' > ~/.zen/tmp/${MOATS}/lightbeam-name.json
echo '[{"title":"$:/plugins/astroport/lightbeams/saver/ipns/lightbeam-key","text":"'${FEEDNS}'","tags":""}]' > ~/.zen/tmp/${MOATS}/lightbeam-key.json
@ -286,7 +284,7 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
## CHANGE SELECTED GW & API
## ADD SYSTEM TW
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
tiddlywiki --load ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html \
--import ~/.zen/tmp/${MOATS}/lightbeam-name.json "application/json" \
--import ~/.zen/tmp/${MOATS}/lightbeam-key.json "application/json" \
--import ~/.zen/tmp/${MOATS}/local.api.json "application/json" \
@ -295,11 +293,11 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
--import ~/.zen/Astroport.ONE/templates/tw/$ _ipfs_saver_gateway.json "application/json" \
--output ~/.zen/tmp/${MOATS} --render "$:/core/save/all" "newindex.html" "text/plain"
[[ -s ~/.zen/tmp/${MOATS}/newindex.html ]] && cp -f ~/.zen/tmp/${MOATS}/newindex.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
[[ -s ~/.zen/tmp/${MOATS}/newindex.html ]] && cp -f ~/.zen/tmp/${MOATS}/newindex.html ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
## ID CARD & QRCODE
convert ~/.zen/game/players/$PLAYER/QR.png -resize 300 ~/.zen/tmp/${MOATS}/QR.png
convert ~/.zen/game/players/$PLAYER/QR.ASTRONAUTENS.png -resize 240 ~/.zen/tmp/${MOATS}/TW.png
convert ~/.zen/game/players/${PLAYER}/QR.png -resize 300 ~/.zen/tmp/${MOATS}/QR.png
convert ~/.zen/game/players/${PLAYER}/QR.ASTRONAUTENS.png -resize 240 ~/.zen/tmp/${MOATS}/TW.png
convert ${MY_PATH}/../images/astroport.jpg -resize 240 ~/.zen/tmp/${MOATS}/ASTROPORT.png
@ -309,49 +307,49 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
# composite -compose Over -gravity NorthWest -geometry +280+280 ~/.zen/game/players/.current/QRsec.png ~/.zen/tmp/${MOATS}/one.png ~/.zen/tmp/${MOATS}/image.png
convert -gravity northwest -pointsize 35 -fill black -draw "text 50,300 \"$PSEUDO\"" ~/.zen/tmp/${MOATS}/one.png ~/.zen/tmp/${MOATS}/image.png
convert -gravity northwest -pointsize 25 -fill black -draw "text 300,40 \"$PLAYER\"" ~/.zen/tmp/${MOATS}/image.png ~/.zen/tmp/${MOATS}/pseudo.png
convert -gravity northwest -pointsize 25 -fill black -draw "text 300,40 \"${PLAYER}\"" ~/.zen/tmp/${MOATS}/image.png ~/.zen/tmp/${MOATS}/pseudo.png
convert -gravity northeast -pointsize 25 -fill black -draw "text 20,180 \"$PASS\"" ~/.zen/tmp/${MOATS}/pseudo.png ~/.zen/tmp/${MOATS}/pass.png
convert -gravity northwest -pointsize 25 -fill black -draw "text 300,100 \"$SALT\"" ~/.zen/tmp/${MOATS}/pass.png ~/.zen/tmp/${MOATS}/salt.png
convert -gravity northwest -pointsize 25 -fill black -draw "text 300,140 \"$PEPPER\"" ~/.zen/tmp/${MOATS}/salt.png ~/.zen/game/players/$PLAYER/ID.png
convert -gravity northwest -pointsize 25 -fill black -draw "text 300,140 \"$PEPPER\"" ~/.zen/tmp/${MOATS}/salt.png ~/.zen/game/players/${PLAYER}/ID.png
# INSERTED IMAGE IPFS
# IASTRO=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ID.png | tail -n 1) ## G1VISA PUBLIC / PRIVATE
# IASTRO=$(ipfs add -Hq ~/.zen/game/players/${PLAYER}/ID.png | tail -n 1) ## G1VISA PUBLIC / PRIVATE
IASTRO=$(ipfs add -Hq ~/.zen/tmp/${MOATS}/pseudo.png | tail -n 1) ## G1VISA PUBLIC ONLY
sed -i "s~bafybeidhghlcx3zdzdah2pzddhoicywmydintj4mosgtygr6f2dlfwmg7a~${IASTRO}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~bafybeidhghlcx3zdzdah2pzddhoicywmydintj4mosgtygr6f2dlfwmg7a~${IASTRO}~g" ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html
echo
echo "## PUBLISHING ${PLAYER}"
echo "/ipns/${ASTRONAUTENS}/"
IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)
echo $IPUSH > ~/.zen/game/players/$PLAYER/ipfs/moa/.chain # Contains last IPFS backup PLAYER KEY
IPUSH=$(ipfs add -Hq ~/.zen/game/players/${PLAYER}/ipfs/moa/index.html | tail -n 1)
echo $IPUSH > ~/.zen/game/players/${PLAYER}/ipfs/moa/.chain # Contains last IPFS backup PLAYER KEY
echo "/ipfs/$IPUSH"
echo $MOATS > ~/.zen/game/players/$PLAYER/ipfs/moa/.moats
echo $MOATS > ~/.zen/game/players/${PLAYER}/ipfs/moa/.moats
(
ipfs name publish --key=${PLAYER} /ipfs/$IPUSH >/dev/null 2>&1
) &
## MEMORISE PLAYER Ŋ1 ZONE
echo "$PLAYER" > ~/.zen/game/players/$PLAYER/.player
echo "$PSEUDO" > ~/.zen/game/players/$PLAYER/.pseudo
echo "$G1PUB" > ~/.zen/game/players/$PLAYER/.g1pub
echo "${PLAYER}" > ~/.zen/game/players/${PLAYER}/.player
echo "$PSEUDO" > ~/.zen/game/players/${PLAYER}/.pseudo
echo "$G1PUB" > ~/.zen/game/players/${PLAYER}/.g1pub
# astrXbian compatible IPFS sub structure =>$XZUID
cp ~/.zen/game/players/$PLAYER/.player ~/.zen/game/players/$PLAYER/ipfs/_xbian.zuid
cp ~/.zen/game/players/$PLAYER/.player ~/.zen/game/players/$PLAYER/ipfs/
cp ~/.zen/game/players/${PLAYER}/.player ~/.zen/game/players/${PLAYER}/ipfs/_xbian.zuid
cp ~/.zen/game/players/${PLAYER}/.player ~/.zen/game/players/${PLAYER}/ipfs/
# PUBLIC Ŋ0 ZONE
echo "${ASTRONAUTENS}" > ~/.zen/game/players/$PLAYER/.playerns
echo "${ASTRONAUTENS}" > ~/.zen/game/players/${PLAYER}/.playerns
echo "SALT=$SALT" > ~/.zen/game/players/$PLAYER/secret.june
echo "PEPPER=$PEPPER" >> ~/.zen/game/players/$PLAYER/secret.june
echo "SALT=$SALT" > ~/.zen/game/players/${PLAYER}/secret.june
echo "PEPPER=$PEPPER" >> ~/.zen/game/players/${PLAYER}/secret.june
echo; echo "Création Clefs et QR codes pour accès au niveau Astroport Ŋ1"; sleep 1
echo "--- PLAYER : $PLAYER";
echo "--- PLAYER : ${PLAYER}";
echo; echo "VISA : ${myIPFS}/ipfs/${IASTRO}"
echo; echo "+ TW : ${myIPFS}/ipns/${ASTRONAUTENS}"
echo; echo "+ RSS : ${myIPFS}/ipns/${FEEDNS}"; sleep 1
@ -360,7 +358,7 @@ echo; echo "+ RSS : ${myIPFS}/ipns/${FEEDNS}"; sleep 1
################# PREPARE DOCKERIZATION
rm ~/.zen/game/players/.current
ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
ln -s ~/.zen/game/players/${PLAYER} ~/.zen/game/players/.current
. "$MY_PATH/my.sh"
#################################################################
@ -375,37 +373,37 @@ ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
# PASS CRYPTING KEY
#~ echo; echo "Sécurisation de vos clefs... "; sleep 1
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/$PLAYER/secret.june" -out "$HOME/.zen/game/players/$PLAYER/enc.secret.june" -k $PASS 2>/dev/null
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/$PLAYER/secret.dunikey" -out "$HOME/.zen/game/players/$PLAYER/enc.secret.dunikey" -k $PASS 2>/dev/null
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/$PLAYER/$KEYFILE -out" "$HOME/.zen/game/players/$PLAYER/enc.$KEYFILE" -k $PASS 2>/dev/null
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/${PLAYER}/secret.june" -out "$HOME/.zen/game/players/${PLAYER}/enc.secret.june" -k $PASS 2>/dev/null
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/${PLAYER}/secret.dunikey" -out "$HOME/.zen/game/players/${PLAYER}/enc.secret.dunikey" -k $PASS 2>/dev/null
#~ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/${PLAYER}/$KEYFILE -out" "$HOME/.zen/game/players/${PLAYER}/enc.$KEYFILE" -k $PASS 2>/dev/null
## TODO MORE SECURE ?! USE opengpg, natools, etc ...
# ${MY_PATH}/natools.py encrypt -p $G1PUB -i ~/.zen/game/players/$PLAYER/secret.dunikey -o "$HOME/.zen/game/players/$PLAYER/enc.secret.dunikey"
# ${MY_PATH}/natools.py encrypt -p $G1PUB -i ~/.zen/game/players/${PLAYER}/secret.dunikey -o "$HOME/.zen/game/players/${PLAYER}/enc.secret.dunikey"
echo
#################################################
# !! TODO !! # DEMO MODE. REMOVE FOR PRODUCTION - RECALCULATE AND RENEW AFTER EACH NEW KEY DELEGATION
echo "$PASS" > ~/.zen/game/players/$PLAYER/.pass
# ~/.zen/game/players/$PLAYER/secret.june SECURITY TODO
echo "$PASS" > ~/.zen/game/players/${PLAYER}/.pass
# ~/.zen/game/players/${PLAYER}/secret.june SECURITY TODO
# Astronaut QRCode + PASS = LOGIN (=> DECRYPTING CRYPTO IPFS INDEX)
# TODO : Allow Astronaut PASS change ;)
#####################################################
## DISCONNECT AND CONNECT CURRENT PLAYER
#~ rm -f ~/.zen/game/players/.current
#~ ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
#~ ln -s ~/.zen/game/players/${PLAYER} ~/.zen/game/players/.current
## MANAGE GCHANGE+ & Ŋ1 EXPLORATION
${MY_PATH}/Connect_PLAYER_To_Gchange.sh "$PLAYER"
${MY_PATH}/Connect_PLAYER_To_Gchange.sh "${PLAYER}"
### IF PRINTER -> PRINT VISA
LP=$(ls /dev/usb/lp* 2>/dev/null)
[[ $LP ]] && ${MY_PATH}/VISA.print.sh "$PLAYER" &
[[ $LP ]] && ${MY_PATH}/VISA.print.sh "${PLAYER}" &
## INIT FRIENDSHIP CAPTAIN/ASTRONAUTS (LATER THROUGH GCHANGE)
## ${MY_PATH}/FRIENDS.init.sh
## NO. GCHANGE+ IS THE MAIN INTERFACE, astrXbian manage
echo "$(${MY_PATH}/face.sh cool)"
echo "Bienvenue 'Astronaute' $PSEUDO ($PLAYER)"
echo "Bienvenue 'Astronaute' $PSEUDO (${PLAYER})"
echo
echo "Notez vos PHRASES et votre PASS"; sleep 1