Astroport.ONE/tools/VISA.new.sh

385 lines
20 KiB
Bash
Raw Normal View History

#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
################################################################################
2022-08-23 14:41:15 +02:00
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
! ipfs swarm peers >/dev/null 2>&1 && echo "Lancez 'ipfs daemon' SVP" && exit 1
################################################################################
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
mkdir -p ~/.zen/tmp/${MOATS}
2022-08-20 17:12:15 +02:00
SALT="$1"
PEPPER="$2"
2022-10-10 18:06:37 +02:00
PLAYER="$3"
PSEUDO="$4"
## Fill UP TW with VIDEO URL
URL="$5"
################################################################################
2022-11-16 06:11:07 +01:00
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);
2022-11-01 21:35:45 +01:00
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
################################################################################
2022-11-01 21:35:45 +01:00
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
################################################################################
2022-10-10 18:06:37 +02:00
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
2022-12-18 20:45:43 +01:00
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])/")
2022-12-12 22:17:55 +01:00
[[ ! $myIP || $isLAN ]] && myIP="localhost"
2022-12-13 16:39:32 +01:00
[[ $isLAN ]] && myIPFSGW="http://ipfs.localhost:8080" && myASTROPORT="http://astroport.localhost:1234" ## LAN STATION
[[ ! $isLAN || $USER == "zen" ]] && myIPFSGW="https://ipfs.copylaradio.com" && myASTROPORT="https://astroport.copylaradio.com" ## WAN STATION
################################################################################
2022-11-01 21:35:45 +01:00
## CHECK if PLAYER resolve any ASTRONAUTENS
2022-10-31 19:06:22 +01:00
[[ ${PLAYER} ]] && ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
2022-12-13 16:39:32 +01:00
[[ ${ASTRONAUTENS} ]] && echo "WARNING IPNS $PLAYER EXISTANT ${myIPFSGW}/ipns/${ASTRONAUTENS} - EXIT -" && exit 0
2022-08-20 17:12:15 +02:00
2022-08-22 17:38:25 +02:00
## Chargement TW !!!
if [[ $SALT != "" && PEPPER != "" ]]; then
ASTRO=""
${MY_PATH}/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/player.key "$SALT" "$PEPPER" 2>/dev/null
ASTRONAUTENS=$(ipfs key import ${MOATS} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/player.key 2>/dev/null)
2022-12-08 23:19:09 +01:00
# echo "/ipns/${ASTRONAUTENS}"
2022-08-22 17:38:25 +02:00
ipfs key rm ${MOATS} 2>/dev/null ## CLEANING
mkdir -p ~/.zen/tmp/${MOATS}/TW
2022-12-12 23:57:21 +01:00
echo "SCANNING /ipns/${ASTRONAUTENS}"
## GETTING LAST TW via IPFS or HTTP GW
[[ $YOU ]] \
2022-12-08 23:19:09 +01:00
&& ipfs --timeout 20s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${MOATS}/TW/index.html
[[ ! -s ~/.zen/tmp/${MOATS}/TW/index.html ]] \
2022-12-08 23:19:09 +01:00
&& curl -m 20 -so ~/.zen/tmp/${MOATS}/TW/index.html "$LIBRA/ipns/${ASTRONAUTENS}"
#############################################
## AUCUN RESULTAT
if [ ! -s ~/.zen/tmp/${MOATS}/TW/index.html ]; then
2022-08-22 17:38:25 +02:00
rm -f ~/.zen/tmp/${MOATS}/TW/index.html
echo "CREATION TW Astronaute" ## Nouveau Compte Astronaute
2022-10-10 18:06:37 +02:00
else
#############################################
# TW : DATA TESTING & CACHE
rm -f ~/.zen/tmp/${MOATS}/Astroport.json
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/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)
2022-12-09 15:55:27 +01:00
if [[ $ASTROPORT ]]; then
IPNSTAIL=$(echo $ASTROPORT | rev | cut -f 1 -d '/' | rev)
echo "TW ASTROPORT GATEWAY : ${ASTROPORT}"
2022-12-09 15:55:27 +01:00
[[ $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 "PLAYER on $ASTROPORT Station"
fi
2022-10-10 18:06:37 +02:00
# DO NOT CONTINUE
2022-12-09 15:55:27 +01:00
echo "TW ADDRESS IN USE"
rm -Rf ~/.zen/tmp/${MOATS}
2022-10-10 18:06:37 +02:00
exit 1
fi
2022-08-22 17:38:25 +02:00
fi
################################################################################
2022-12-16 01:02:19 +01:00
TWMODEL="/ipfs/bafybeichgkzj5tkf3zuobrxqxr2evomuedsehfagstcel72gqy4lai3kqa"
2022-12-09 15:55:27 +01:00
# ipfs cat $TWMODEL > templates/twdefault.html
##################################################### # NEW PLAYER ###############
################################################################################
2022-08-20 17:12:15 +02:00
echo "=============================================
ASTROPORT DIPLOMATIC PASSPORT - MadeInZion VISA -
=============================================
A Cryptographic Key to control your INTERNET
Adventure & Exploration P2P Terraforming Game.
=============================================
Bienvenue 'Astronaute'"; sleep 1
echo "Création de votre PLAYER, votre PSEUDO et PASS (6 chiffres)"
2022-08-20 17:12:15 +02:00
[[ $SALT == "" ]] && SALT=$(${MY_PATH}/diceware.sh 4 | xargs)
2022-08-22 17:38:25 +02:00
echo "-> SALT : $SALT"
2022-08-22 17:38:25 +02:00
[[ $PEPPER == "" ]] && PEPPER=$(${MY_PATH}/diceware.sh 2 | xargs)
echo "-> PEPPER : $PEPPER"
PSEUDO=${PLAYER%%[0-9]*}
2022-09-13 20:57:11 +02:00
2022-10-10 18:06:37 +02:00
[[ ! $PSEUDO ]] && echo "Choisissez un pseudo : " && read PSEUDO
PSEUDO=${PSEUDO,,}
PSEUDO=${PSEUDO%%[0-9]*}
2022-12-11 18:51:48 +01:00
[[ $(ls ~/.zen/game/players/$PSEUDO 2>/dev/null) ]] && echo "CE PSEUDO EST DEJA UN PLAYER. EXIT" && exit 1
2022-10-10 18:06:37 +02:00
2022-04-26 14:16:57 +02:00
# PSEUDO=${PSEUDO,,} #lowercase
2022-10-10 18:06:37 +02:00
[[ ! $PLAYER ]] && PLAYER=${PSEUDO}${RANDOM:0:2}$(${MY_PATH}/diceware.sh 1 | xargs)${RANDOM:0:2} \
2022-12-13 16:20:58 +01:00
&& echo "ADRESSE EMAIL ?" && read OPLAYER && [[ $OPLAYER ]] && PLAYER=$OPLAYER
2022-12-13 16:24:13 +01:00
2022-08-15 19:07:39 +02:00
[[ -d ~/.zen/game/players/$PLAYER ]] && echo "FATAL ERROR $PLAYER NAME COLLISION. TRY AGAIN." && exit 1
2022-12-13 16:24:13 +01:00
[[ ! $PSEUDO ]] && PSEUDO="Anonymous"
2022-12-13 16:20:58 +01:00
echo; echo "Génération de votre crypto identité PLAYER :"; sleep 1; echo "$PLAYER"; sleep 2
2022-08-15 19:07:39 +02:00
# 6 DIGIT PASS CODE TO PROTECT QRSEC
PASS=$(echo "${RANDOM}${RANDOM}${RANDOM}${RANDOM}" | tail -c-7)
2022-04-26 14:16:57 +02:00
############################################################
2022-08-15 19:07:39 +02:00
######### TODO Ajouter d'autres clefs IPNS, GPG ?
# 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)"
2022-08-20 17:12:15 +02:00
# echo "Votre clef moa_$PLAYER <=> $MOANS ($MOAKEYFILE)"; sleep 2
2022-08-15 19:07:39 +02:00
############################################################
2022-11-17 16:24:45 +01:00
echo
2022-12-13 16:20:58 +01:00
echo "Votre compte Gchange et portefeuille G1.
Utilisez ces identifiants pour rejoindre la Monnaie Libre
$SALT
$PEPPER
Rendez-vous sur https://gchange.fr"; sleep 3
2022-08-15 19:07:39 +02:00
echo; echo "Création de votre clef multi-accès..."; sleep 2
echo;
2022-04-26 14:16:57 +02:00
2022-12-09 15:55:27 +01:00
${MY_PATH}/keygen -t duniter -o ~/.zen/tmp/${MOATS}/secret.dunikey "$SALT" "$PEPPER"
2022-07-07 13:44:45 +02:00
2022-12-09 15:55:27 +01:00
G1PUB=$(cat ~/.zen/tmp/${MOATS}/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
2022-04-26 14:16:57 +02:00
2022-08-15 19:07:39 +02:00
[[ ! $G1PUB ]] && echo "Désolé. clef Cesium absente." && exit 1
## CREATE Player personnal files storage and IPFS publish directory
mkdir -p ~/.zen/game/players/$PLAYER # Prepare PLAYER datastructure
2022-04-26 14:16:57 +02:00
# PLAYER=geg-la_debrouille@super.chez-moi.com
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
2022-12-15 02:35:59 +01:00
echo "NEXT STYLE GW : https://ipfs.$CLYUSER$YOMAIN.$HOSTNAME"
2022-12-13 13:44:50 +01:00
#~ [[ ! $isLAN ]] && NID="https://ipfs.$CLYUSER$YOMAIN.$HOSTNAME" && WID="$NID/api"
2022-12-13 16:39:32 +01:00
NID="${myIPFSGW}" && WID="$NID/api"
[[ $isLAN ]] && NID="http://ipfs.localhost:8080" && WID="http://ipfs.localhost:5001"
2022-12-12 22:17:55 +01:00
### CREATE $NID ADDRESS FOR API & ROUND ROBIN FOR GW
2022-12-15 03:50:40 +01:00
cat ~/.zen/Astroport.ONE/templates/data/local.api.json | sed -i "s~_NID_~${WID}~g" > ~/.zen/tmp/${MOATS}/local.api.json
cat ~/.zen/Astroport.ONE/templates/data/local.gw.json | sed -i "s~_NID_~${NID}~g" > ~/.zen/tmp/${MOATS}/local.gw.json
2022-12-09 15:55:27 +01:00
mv ~/.zen/tmp/${MOATS}/secret.dunikey ~/.zen/game/players/$PLAYER/
2022-08-15 19:07:39 +02:00
# 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
2022-08-18 03:47:49 +02:00
ASTRONAUTENS=$(ipfs key import $G1PUB -f pem-pkcs8-cleartext ~/.zen/game/players/$PLAYER/secret.player)
2022-08-15 19:07:39 +02:00
2022-09-07 16:32:05 +02:00
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/G1SSB # Prepare astrXbian sub-datastructure
2022-08-22 17:38:25 +02:00
qrencode -s 12 -o ~/.zen/game/players/$PLAYER/QR.png "$G1PUB"
2022-09-07 16:32:05 +02:00
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)
2022-04-26 14:16:57 +02:00
2022-12-09 15:55:27 +01:00
## SEC PASS PROTECTED QRCODE
2022-04-26 14:16:57 +02:00
secFromDunikey=$(cat ~/.zen/game/players/$PLAYER/secret.dunikey | grep "sec" | cut -d ' ' -f2)
2022-12-09 15:55:27 +01:00
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
2022-08-22 17:38:25 +02:00
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...
2022-11-21 18:58:03 +01:00
echo
echo "***** Activation du Canal TW Astronaute $PLAYER *****"
2022-09-07 16:32:05 +02:00
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-09-07 16:32:05 +02:00
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
# INSERT ASTROPORT ADRESS
2022-12-09 15:55:27 +01:00
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
# TW CHAIN INIT WITH TWMODEL
2022-12-08 19:43:30 +01:00
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
2022-12-09 15:55:27 +01:00
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
2022-12-08 19:43:30 +01:00
sed -i "s~_URL_~${URL}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
# INSERT PLAYER DATA
2022-09-07 16:32:05 +02:00
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
2022-08-18 18:32:01 +02:00
2022-09-07 16:32:05 +02:00
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
2022-08-18 03:47:49 +02:00
ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
2022-10-30 19:32:56 +01:00
# La Clef IPNS porte comme nom G1PUB
2022-11-17 17:35:15 +01:00
sed -i "s~_MEDIAKEY_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-09-07 16:32:05 +02:00
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${ASTRONAUTENS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~tube.copylaradio.com~ipfs.copylaradio.com~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~ipfs.copylaradio.com~ipfs.copylaradio.com~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-08-23 14:24:18 +02:00
#
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)
2022-10-10 14:49:47 +02:00
2022-12-09 15:55:27 +01:00
###########
2022-12-11 18:51:48 +01:00
echo "# CRYPTO ENCODING _SECRET_ "
2022-12-09 15:55:27 +01:00
$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
2022-12-09 15:55:27 +01:00
###########
2022-12-11 18:51:48 +01:00
echo "# CRYPTO DECODING TESTING..."
2022-12-09 15:55:27 +01:00
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'
2022-12-12 22:17:55 +01:00
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
2022-12-09 15:55:27 +01:00
###########
## CRYPTO PROCESS VALIDATED
2022-12-12 22:17:55 +01:00
[[ -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
2022-12-12 22:17:55 +01:00
rm -f ~/.zen/tmp/${MOATS}/crypto.2
2022-12-09 15:55:27 +01:00
###########
2022-11-17 17:16:01 +01:00
# Create"$PLAYER_feed" Key
2022-12-12 22:17:55 +01:00
FEEDNS=$(ipfs key gen "${PLAYER}_feed")
## MAKE LightBeam Plugin Tiddler $PLAYER_feed
2022-12-11 18:51:48 +01:00
# $:/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
2022-09-06 03:53:10 +02:00
## ADD SYSTEM TW
2022-11-17 19:40:50 +01:00
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" \
--import ~/.zen/tmp/${MOATS}/local.gw.json "application/json" \
2022-12-09 15:55:27 +01:00
--output ~/.zen/tmp/${MOATS} --render "$:/core/save/all" "newindex.html" "text/plain"
2022-12-11 18:51:48 +01:00
[[ -s ~/.zen/tmp/${MOATS}/newindex.html ]] && cp -f ~/.zen/tmp/${MOATS}/newindex.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-08-15 19:07:39 +02:00
2022-12-09 15:55:27 +01:00
## ID CARD & QRCODE
convert ~/.zen/game/players/$PLAYER/QR.png -resize 300 ~/.zen/tmp/${MOATS}/QR.png
convert ${MY_PATH}/../images/astroport.jpg -resize 300 ~/.zen/tmp/${MOATS}/ASTROPORT.png
2022-08-22 17:38:25 +02:00
2022-12-09 15:55:27 +01:00
composite -compose Over -gravity SouthWest -geometry +280+20 ~/.zen/tmp/${MOATS}/ASTROPORT.png ${MY_PATH}/../images/Brother_600x400.png ~/.zen/tmp/${MOATS}/astroport.png
composite -compose Over -gravity NorthWest -geometry +0+0 ~/.zen/tmp/${MOATS}/QR.png ~/.zen/tmp/${MOATS}/astroport.png ~/.zen/tmp/${MOATS}/one.png
# composite -compose Over -gravity NorthWest -geometry +280+280 ~/.zen/game/players/.current/QRsec.png ~/.zen/tmp/${MOATS}/one.png ~/.zen/tmp/${MOATS}/image.png
2022-08-22 17:38:25 +02:00
2022-12-09 15:55:27 +01:00
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 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
2022-08-22 17:38:25 +02:00
# INSERTED IMAGE IPFS
IASTRO=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ID.png | tail -n 1)
2022-09-07 16:32:05 +02:00
sed -i "s~bafybeidhghlcx3zdzdah2pzddhoicywmydintj4mosgtygr6f2dlfwmg7a~${IASTRO}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
2022-08-18 18:32:01 +02:00
2022-11-21 18:58:03 +01:00
echo
echo "## PUBLISHING ${PLAYER}"
echo "/ipns/${ASTRONAUTENS}/"
2022-09-07 16:32:05 +02:00
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
2022-08-18 18:32:01 +02:00
echo "/ipfs/$IPUSH"
2022-09-07 16:32:05 +02:00
echo $MOATS > ~/.zen/game/players/$PLAYER/ipfs/moa/.moats
2022-11-21 18:58:03 +01:00
(
ipfs name publish --key=${PLAYER} /ipfs/$IPUSH >/dev/null 2>&1
) &
2022-08-15 19:07:39 +02:00
## MEMORISE PLAYER Ŋ1 ZONE
echo "$PLAYER" > ~/.zen/game/players/$PLAYER/.player
echo "$PSEUDO" > ~/.zen/game/players/$PLAYER/.pseudo
2022-05-07 18:53:11 +02:00
echo "$G1PUB" > ~/.zen/game/players/$PLAYER/.g1pub
# astrXbian compatible IPFS sub structure =>$XZUID
2022-09-07 16:32:05 +02:00
cp ~/.zen/game/players/$PLAYER/.player ~/.zen/game/players/$PLAYER/ipfs/_xbian.zuid
cp ~/.zen/game/players/$PLAYER/.player ~/.zen/game/players/$PLAYER/ipfs/
2022-12-09 15:55:27 +01:00
# PUBLIC Ŋ0 ZONE
2022-11-01 21:35:45 +01:00
echo "${ASTRONAUTENS}" > ~/.zen/game/players/$PLAYER/.playerns
2022-05-05 04:12:07 +02:00
echo "$SALT" > ~/.zen/game/players/$PLAYER/secret.june
echo "$PEPPER" >> ~/.zen/game/players/$PLAYER/secret.june
qrencode -s 12 -o "$HOME/.zen/game/players/$PLAYER/QR.ASTRONAUTENS.png" "https://ipfs.copylaradio.com/ipns/${ASTRONAUTENS}"
2022-12-11 18:51:48 +01:00
echo; echo "Création Clefs et QR codes pour accès au niveau Astroport Ŋ1"; sleep 1
2022-12-11 18:51:48 +01:00
echo "--- PLAYER : $PLAYER";
2022-12-13 16:39:32 +01:00
echo; echo "VISA : ${myIPFSGW}/ipfs/${IASTRO}"
echo; echo "+ TW : ${myIPFSGW}/ipns/${ASTRONAUTENS}"
echo; echo "+ RSS : ${myIPFSGW}/ipns/${FEEDNS}"; sleep 1
2022-12-13 16:51:00 +01:00
[[ $XDG_SESSION_TYPE == 'x11' ]] && xdg-open "${myIPFSGW}/ipns/${ASTRONAUTENS}"
2022-12-13 16:55:44 +01:00
[[ ! -L ~/.zen/game/players/.current ]] && 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
## TODO MORE SECURE ?! USE opengpg, natools, etc ...
2022-11-16 05:08:45 +01:00
# ${MY_PATH}/natools.py encrypt -p $G1PUB -i ~/.zen/game/players/$PLAYER/secret.dunikey -o "$HOME/.zen/game/players/$PLAYER/enc.secret.dunikey"
2022-11-21 18:58:03 +01:00
echo
#################################################
2022-10-21 13:43:52 +02:00
# !! TODO !! # DEMO MODE. REMOVE FOR PRODUCTION - RECALCULATE AND RENEW AFTER EACH NEW KEY DELEGATION
2022-04-26 14:16:57 +02:00
echo "$PASS" > ~/.zen/game/players/$PLAYER/.pass
2022-05-07 18:53:11 +02:00
# ~/.zen/game/players/$PLAYER/secret.june SECURITY TODO
# Astronaut QRCode + PASS = LOGIN (=> DECRYPTING CRYPTO IPFS INDEX)
2022-08-15 19:07:39 +02:00
# TODO : Allow Astronaut PASS change ;)
2022-05-07 18:53:11 +02:00
#####################################################
2022-05-07 18:53:11 +02:00
## DISCONNECT AND CONNECT CURRENT PLAYER
2022-12-09 15:55:27 +01:00
#~ rm -f ~/.zen/game/players/.current
#~ ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
2022-10-24 14:59:14 +02:00
## MANAGE GCHANGE+ & Ŋ1 EXPLORATION
${MY_PATH}/Connect_PLAYER_To_Gchange.sh "$PLAYER"
2022-08-18 03:47:49 +02:00
2022-11-21 18:58:03 +01:00
### IF PRINTER -> PRINT VISA
2022-12-09 15:55:27 +01:00
LP=$(ls /dev/usb/lp* 2>/dev/null)
[[ $LP ]] && ${MY_PATH}/VISA.print.sh "$PLAYER" &
2022-11-21 18:58:03 +01:00
2022-08-15 19:07:39 +02:00
## INIT FRIENDSHIP CAPTAIN/ASTRONAUTS (LATER THROUGH GCHANGE)
2022-06-23 16:30:56 +02:00
## ${MY_PATH}/FRIENDS.init.sh
## NO. GCHANGE+ IS THE MAIN INTERFACE, astrXbian manage
2022-11-21 18:58:03 +01:00
echo "$(${MY_PATH}/face.sh cool)"
2022-08-20 17:12:15 +02:00
echo "Bienvenue 'Astronaute' $PSEUDO ($PLAYER)"
2022-12-13 16:51:00 +01:00
echo
echo "Notez vos PHRASES et votre PASS"; sleep 1
2022-04-23 18:33:23 +02:00
echo $PSEUDO > ~/.zen/tmp/PSEUDO ## Return data to start.sh
2022-11-21 18:58:03 +01:00
2022-10-10 18:06:37 +02:00
echo "$PASS"
2022-11-17 19:37:35 +01:00
2022-12-09 15:55:27 +01:00
## CLEANING CACHE
rm -Rf ~/.zen/tmp/${MOATS}
2022-11-17 19:37:35 +01:00
exit 0