Extends Astronaut ipfs FRIENDS zone.

This commit is contained in:
fred 2022-05-07 18:53:11 +02:00
parent dcecee31f8
commit 466fc32460
5 changed files with 85 additions and 50 deletions

View File

@ -30,14 +30,14 @@ VISA : MadeInZion
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
[[ ! $YOU ]] && echo "Lancez 'ipfs daemon' SVP" && exit 1
## CONNECT USER
## CREATE AND OR CONNECT USER
PS3='Choisissez votre Astronaute ou ajoutez votre Identité à la liste. '
players=("NOUVEAU VISA" $(ls ~/.zen/game/players))
select fav in "${players[@]}"; do
case $fav in
"NOUVEAU VISA")
${MY_PATH}/tools/VISA.new.sh
fav=$(cat ~/.zen/tmp/PSEUDO) && rm ~/.zen/tmp/PSEUDO
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
;;
@ -63,7 +63,7 @@ read pass
## DECODE CURRENT PLAYER CRYPTO
echo "********* DECODAGE SecuredSocketLayer *********"
rm -f ~/.zen/tmp/${PLAYER}.dunikey 2>/dev/null
openssl enc -aes-256-cbc -d -in "$HOME/.zen/game/players/.current/enc.secret.dunikey" -out "$HOME/.zen/tmp/${PLAYER}.dunikey" -k $pass 2>/dev/null
openssl enc -aes-256-cbc -d -in "$HOME/.zen/game/players/.current/enc.secret.dunikey" -out "$HOME/.zen/tmp/${PLAYER}.dunikey" -k $pass 2>&1>/dev/null
[ ! -f $HOME/.zen/tmp/${PLAYER}.dunikey ] && echo "ERROR. MAUVAIS PASS. EXIT" && exit 1
echo "____________________";
@ -78,8 +78,8 @@ select fav in "${choices[@]}"; do
;;
"EXPORTER VISA")
echo "EXPORT. INSERT USB KEY"
ls ~/.zen/game/players/.current
echo "EXPORT. INSEREZ CLEF USB"
du -h ~/.zen/game/players/.current/
echo "Enter to continue. Ctrl+C to stop"
read
echo "TODO... ${MY_PATH}/tools/SAVE.astronaut.sh"
@ -87,7 +87,7 @@ select fav in "${choices[@]}"; do
;;
"SUPPRIMER VISA")
echo "SUPPRESSION"
echo "ATTENTION SUPPRESSION DEFINITIVE"
echo "Enter to continue. Ctrl+C to stop"
read
ipfs key rm $PLAYER; ipfs key rm qo-op_$PLAYER; ipfs key rm moa_$PLAYER;

View File

@ -18,6 +18,11 @@ for player in $(ls ~/.zen/game/players/); do
qoopns=$(cat ~/.zen/game/players/$PLAYER/.qoopns)
moans=$(cat ~/.zen/game/players/$PLAYER/.moans)
playerns=$(cat ~/.zen/game/players/$PLAYER/.playerns)
# CHECK DIFFERENCES FROM LATEST TIME CHECK
# GET DIFF BETWEEN moa_PLAYERs
# Extract json's => Add to main channel 'moa'
# Warn Captain to monitor.
done

View File

@ -28,11 +28,12 @@ source ~/.zen/ipfs.sync
### AN ASTROPORT NEEDS A CAPTAIN
##############################
if [[ ! -d $IPFS_SYNC_DIR || $IPFS_SYNC_DIR == "" || $IPFS_SYNC_DIR == "$HOME/astroport" ]]; then
if [[ ! -d ~/.zen/game/players/$CAPTAIN || $CAPTAIN == "" || $CAPTAIN == "$HOME/astroport" ]]; then
echo "#-----------------------------------"
echo $IPFS_SYNC_DIR
echo $CAPTAIN
echo "Aucun Capitaine à bord."; sleep 1
echo "$PLAYER vous devenez la clef maitre de la Station et de sa balise astrXbian..."; sleep 1
echo "$PLAYER vous devenez la clef maitre de la Station et de sa balise astrXbian..."; sleep 2
echo "Et de ses canaux, public 'qo-op' et administratif 'moa'"; sleep 2
echo
echo "** Stop or Kill ipfs daemon **"
@ -45,40 +46,54 @@ echo "** Stop or Kill ipfs daemon **"
echo
echo "=== Replacing ~/.ipfs/config ==="; sleep 2
[[ -f ~/.ipfs/config.astrXbian ]] && mv ~/.ipfs/config.astrXbian ~/.ipfs/config.astrXbian.${MOATS} && echo "BACKUP config.astrXbian.${MOATS}"; sleep 2
mv ~/.ipfs/config ~/.ipfs/config.astrXbian && echo "BACKUP current ipfs config"; sleep 2
cp ~/.zen/game/players/$PLAYER/ipfs.config ~/.ipfs/config && echo "Installing $PLAYER 'G1' ipfs config"
[[ ! -f ~/.ipfs/config.astrXbian ]] && mv ~/.ipfs/config ~/.ipfs/config.astrXbian && echo "BACKUP OLD ipfs config" || rm ~/.ipfs/config
ln -s ~/.zen/game/players/$PLAYER/ipfs.config ~/.ipfs/config && echo "Installing $PLAYER 'G1' ipfs config"; sleep 2
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID); echo $IPFSNODEID
echo
echo "==== qo-op & moa Captain/Station keystore ===="; sleep 2
mv ~/.ipfs/keystore ~/.ipfs/keystore.astrXbian.${LAYER}.${MOATS}
mv ~/.ipfs/keystore ~/.ipfs/keystore.astrXbian.${PLAYER}.${MOATS}
ln -s ~/.zen/game/players/$PLAYER/keystore ~/.ipfs/keystore
# Get already created keys
cp ~/.ipfs/keystore.astrXbian.${LAYER}.${MOATS}/* ~/.ipfs/keystore/ 2>/dev/null
# Keep already created keys !!?
cp ~/.ipfs/keystore.astrXbian.${PLAYER}.${MOATS}/* ~/.ipfs/keystore/ 2>/dev/null
# 'qo-op' Key there?
[[ ! -f ~/.ipfs/keystore/key_ofxs233q ]] && qoopns=$(ipfs key gen qo-op)
# 'qo-op' Key there? Or Captain already join a flag
# Astroport public channel 'state of mind' propagation...
[[ ! -f ~/.ipfs/keystore/key_ofxs233q ]] &&\
qoopns=$(ipfs key gen qo-op) && \
IPUSH=$(ipfs add -Hq ${MY_PATH}/../templates/qoopwiki.html | tail -n 1) && \
ipfs name publish --key=qo-op /ipfs/$IPUSH 2>/dev/null
# qo-op channel is created from template
ipfs key list -l | grep -w qo-op
qoopns=$(ipfs key list -l | grep -w qo-op | cut -d ' ' - f 1)
qoopns=$(ipfs key list -l | grep -w qo-op | cut -d ' ' -f 1)
echo "----> Station 'qo-op' channel : /ipns/$qoopns"; sleep 1
echo "----> Station 'qo-op' channel : http://127.0.0.1:8080/ipns/$qoopns"; sleep 1
# 'moa' Key there?
[[ ! -f ~/.ipfs/keystore/key_nvxwc ]] && moans=$(ipfs key gen moa)
# 'moa' Key there? It is the 'Administrative' 3 star.level confidence information layer.
[[ ! -f ~/.ipfs/keystore/key_nvxwc ]] &&\
moans=$(ipfs key gen moa) && \
IPUSH=$(ipfs add -Hq ${MY_PATH}/../templates/moawiki.html | tail -n 1) && \
ipfs name publish --key=moa /ipfs/$IPUSH 2>/dev/null
# moa channel is created from template
ipfs key list -l | grep -w moa
moans=$(ipfs key list -l | grep -w moa | cut -d ' ' - f 1)
moans=$(ipfs key list -l | grep -w moa | cut -d ' ' -f 1)
echo "----> Station 'moa' channel : /ipns/$moans"; sleep 1
echo "----> Station 'moa' channel : http://127.0.0.1:8080/ipns/$moans"; sleep 1
echo
echo "===== Connect captain IPFS datadir to Station (balise junction) ====="; sleep 2
[[ -d ~/.zen/ipfs.astrXbian ]] && mv ~/.zen/ipfs.astrXbian ~/.zen/ipfs.astrXbian.${MOATS} && echo "BACKUP ~/.zen/ipfs.astrXbian.${MOATS}"; sleep 2
mv ~/.zen/ipfs ~/.zen/ipfs.astrXbian && echo "BACKUP current ~/.zen/ipfs"; sleep 2
ln -s ~/.zen/game/players/$PLAYER/ipfs ~/.zen/ipfs && echo "$PLAYER become 'self' and now control 'moa' & 'qo-op' channels"
# Linking ~/.zen/ipfs & ~/.zen/secret.dunikey
echo "CAPITAINE VOUS ETES EN POSSESSION DES CANAUX PRINCIPAUX DE LA STATION 'qo-op', 'moa', etc ..."
ln -s ~/.zen/game/players/$PLAYER/ipfs ~/.zen/ipfs && echo "$PLAYER become 'self' and can manage 'moa' & 'qo-op' channels" && sleep 1
ln -s ~/.zen/game/players/$PLAYER/secret.dunikey ~/.zen/secret.dunikey && echo "Linking your ~/.zen/secret.dunikey with Station" && sleep 1
echo
echo "** Restart IPFS DAEMON **"
sudo service ipfs start
@ -91,20 +106,36 @@ echo "** Restart IPFS DAEMON **"
echo "Nouvelle Identité 'self' Balise IPFS"; sleep 1
ipfs id -f='<id>\n'
echo "##################################################### OK"
echo "IPFS_SYNC_DIR=$PLAYER" > ~/.zen/ipfs.sync ## PLAYER IS ASTROPORT CAPTAIN NOW
echo "CAPTAIN=$PLAYER" > ~/.zen/ipfs.sync ## PLAYER IS ASTROPORT CAPTAIN NOW
## CAPTAIN is define in ~/.zen/ipfs.sync
else
##############################
# Adapting ipfs daemon keystore with player keys
mv ~/.ipfs/keystore ~/.ipfs/keystore.astrXbian.${LAYER}.${MOATS}
echo
echo "=== Replacing ~/.ipfs/config ==="; sleep 2
[[ ! -f ~/.ipfs/config.astrXbian ]] && mv ~/.ipfs/config ~/.ipfs/config.astrXbian && echo "BACKUP OLD ipfs config" || rm ~/.ipfs/config
ln -s ~/.zen/game/players/$PLAYER/ipfs.config ~/.ipfs/config && echo "Installing $PLAYER 'G1' ipfs config"; sleep 2
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID); echo $IPFSNODEID
echo
echo "==== Astronaute keystore activated ===="; sleep 2
[[ ! -d ~/.ipfs/keystore.astrXbian ]] && mv ~/.ipfs/keystore ~/.ipfs/keystore.astrXbian || rm ~/.ipfs/keystore
ln -s ~/.zen/game/players/$PLAYER/keystore ~/.ipfs/keystore
if [[ $IPFS_SYNC_DIR == "$PLAYER" ]]; then
if [[ $CAPTAIN == "$PLAYER" ]]; then
## THE CAPTAIN IS LOGGED IN
echo "Bienvenue CAPITAINE !"; sleep 2
echo "Ouverture des journaux 'moa' et 'qo-op' de votre Station Astroport";
else
# ASTRONAUT PLAYER IS LOGGED IN
echo "Joueur $PLAYER, $CAPTAIN est Capitaine de cet Astroport"; sleep 1
echo "$PSEUDO, Décrivez vos 'Talents', soumettez vos 'Rêves' pour améliorer cet Astroport dans votre journal 'moa'."; sleep 2
echo "Publiez dans votre journal public 'qo-op'"; sleep 2
fi
# OPEN 'moa' channel
moans=$(ipfs key list -l | grep -w moa | cut -d ' ' -f 1)
xdg-open "http://127.0.0.1:8080/ipns/$moans"
@ -113,16 +144,10 @@ else
qoopns=$(ipfs key list -l | grep -w qo-op | cut -d ' ' -f 1)
xdg-open "http://127.0.0.1:8080/ipns/$qoopns"
else
# ASTRONAUT PLAYER IS LOGGED IN
echo "Joueur $PLAYER, $IPFS_SYNC_DIR est Capitaine de cet Astroport"; sleep 1
echo "$PSEUDO, Décrivez vos 'Talents', soumettez vos 'Rêves' pour améliorer cet Astroport dans votre journal 'moa'."; sleep 2
echo "Publiez dans votre journal public 'qo-op'"; sleep 2
fi
fi
# OPEN PLAYER HOME
# OPEN PLAYER HOME (contains 'moa_player' + 'qo-op_player' vertical iframes
player=$(ipfs key list -l | grep -w $PLAYER | cut -d ' ' -f 1)
xdg-open "http://127.0.0.1:8080/ipns/$player"
@ -135,7 +160,7 @@ Saisissez 'S' avant pour copier vos données sur clef USB ?
read EJECT
[[ $EJECT == "" ]] && echo "Merci. Au revoir"; rm -f ~/.zen/game/players/.current && exit 0
echo "## TODO BACKUP SUR CLEF USB"
echo "## TODO ZIP DANS UN FICHIER CHIFFRE AVEC PASS = BACKUP SUR CLEF USB"
# ${MY_PATH}/tools/SAVE.astronaut.sh # tar.gzip PLAYER DATA TO USB KEY TODO
exit 0

View File

@ -118,9 +118,8 @@ else
sed -i "s~_PLAYER_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/index.html
sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/players/$PLAYER/index.html
# Not used (yet) TODO make jQuery Slider
sed -i "s~_PLAYERNS_~${PLAYERNS}~g" ~/.zen/game/players/$PLAYER/index.html
sed -i "s~_MOAKEY_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/index.html
sed -i "s~k2k4r8opmmyeuee0xufn6txkxlf3qva4le2jlbw6da7zynhw46egxwp2~${PLAYERNS}~g" ~/.zen/game/players/$PLAYER/index.html
sed -i "s~_MOANS_~${MOANS}~g" ~/.zen/game/players/$PLAYER/index.html
sed -i "s~_QOOPNS_~${QOOPNS}~g" ~/.zen/game/players/$PLAYER/index.html
#echo "## PUBLISHING ${PLAYER} /ipns/$PLAYERNS"
IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/index.html | tail -n 1)
@ -144,7 +143,7 @@ else
IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/moa/index.html | tail -n 1)
ipfs name publish --key=moa_${PLAYER} /ipfs/$IPUSH 2>/dev/null
# qo-op WIKI ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html
# qo-op WIKI ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html (TODO ENHANCE TW TEMPLATE WITH EXTRA PARMETERS, EXTRA TIDDLERS)
cp ${MY_PATH}/../templates/qoopwiki.html ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html
sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html
@ -162,8 +161,14 @@ else
IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/index.html | tail -n 1)
ipfs name publish --key=qo-op_${PLAYER} /ipfs/$IPUSH 2>/dev/null
## MEMORISE PLAYER
echo "$PSEUDO" > ~/.zen/game/players/$PLAYER/.pseudo
echo "$G1PUB" > ~/.zen/game/players/$PLAYER/.g1pub
echo "$IPFSNODEID" > ~/.zen/game/players/$PLAYER/.ipfsnodeid
echo "$PLAYER" > ~/.zen/game/players/$PLAYER/.player
# astrXbian compatible IPFS sub structure =>$XZUID
cp ~/.zen/game/players/$PLAYER/.player ~/.zen/game/players/$PLAYER/ipfs/.$PeerID/_xbian.zuid
# Record IPNS address for CHANNEL.populate
echo "$PLAYERNS" > ~/.zen/game/players/$PLAYER/.playerns
@ -196,18 +201,18 @@ openssl enc -aes-256-cbc -salt -in "$HOME/.zen/game/players/$PLAYER/$KEYFILE -ou
[[ $1 != "quiet" ]] && echo; echo "Sécurisation de vos clefs par chiffrage SSL... "; sleep 1
#################################################
# !! TODO !! # DEV MODE. REMOVE FOR PRODUCTION
# !! TODO !! # DEMO MODE. REMOVE FOR PRODUCTION
echo "$PASS" > ~/.zen/game/players/$PLAYER/.pass
[[ $1 != "quiet" ]] && echo "_____ REINIT COMMAND____"
[[ $1 != "quiet" ]] && echo "for p in \$(ls ~/.zen/game/players/); do rm -Rf ~/.zen/game/players/\$p"
[[ $1 != "quiet" ]] && echo "for k in \$(ipfs key list | grep \$p); do ipfs key rm \$k; done; done"
[[ $1 != "quiet" ]] && echo "_____ALL PLAYERS REMOVAL____"
#################################################
# ~/.zen/game/players/$PLAYER/secret.june SECURITY TODO
# Astronaut QRCode + PASS = LOGIN (=> DECRYPTING CRYPTO IPFS INDEX)
#####################################################
## SET CURRENT PLAYER
## DISCONNECT AND CONNECT CURRENT PLAYER
rm -f ~/.zen/game/players/.current
ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
## INIT FRIENDSHIP CAPTAIN/ASTRONAUTS
${MY_PATH}/FRIENDS.init.sh
[[ $1 != "quiet" ]] && echo "Bienvenue 'Astronaute' $PSEUDO ($PLAYER)"
[[ $1 != "quiet" ]] && echo "Souvenez-vous bien de votre PASS : $PASS"; sleep 2

View File

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
# SCRIPT INTERACTIF POUR AJOUTER UN FICHIER à ASTROPORT/KODI
@ -53,8 +53,7 @@ haut=$((height-200))
########################################################################
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
[[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title ]] && XGUID="$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title)" || XGUID="$(cat /etc/hostname)"
[[ -f ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid ]] && XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)
XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid 2>/dev/null) || XZUID="noplayer"
########################################################################
## CADRE EXCEPTION COPIE PRIVE
@ -93,6 +92,7 @@ if [[ $RUN == "OUI" ]]; then
STRAP=$(ipfs bootstrap)
BOOT=$(zenity --entry --width 300 --title="Catégorie" --text="$STRAP Changez de Bootstrap" --entry-text="Aucun" astrXbian Public)
[[ $BOOT == "Aucun" ]] && ipfs bootstrap rm --all
## TODO REWRITE, Now init_friends.sh populated swarm bootstrapping
[[ $BOOT == "astrXbian" ]] && for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#"); do ipfs bootstrap add $bootnode; done
[[ $BOOT == "Public" ]] && for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_public.txt | grep -Ev "#"); do ipfs bootstrap add $bootnode; done
REP=$(~/.zen/astrXbian/zen/cron_VRFY.sh) && zenity --warning --width 600 --text "$REP"