This commit is contained in:
qo-op 2020-12-12 03:51:08 +01:00
parent 3b6bff8aad
commit 69fc6bd07c
5 changed files with 32 additions and 128 deletions

View File

@ -1,113 +0,0 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.12.04
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
#
# This script is run from ~/.config/autostart/Astroport_X_config.desktop
#
########################################################################
# Create secret key files
# ~/.zen/secret.june
# ~/.zen/secret.dunikey
# ~/.zen/secret.ipfs & /tmp/config.ipfs
# ~/.zen/ipfs.sync
########################################################################
[[ $(which zenity) == "" ]] && echo "Please! sudo apt install zenity. EXIT" && exit 1
[[ -f ~/.zen/ipfs.sync ]] && echo "CONFIG ALREADY DONE" && source ~/.zen/ipfs.sync && exit 0
function cleanTMP
{
rm -f /tmp/secret.june /tmp/secret.dunikey /tmp/config.ipfs /tmp/secret.ipfs /tmp/secret.all
}
# NB: 2> >(grep -v 'GtkDialog' >&2) remove zenity console warning
zenity --question --width 300 --text "Initialiser votre station Astroport?" 2> >(grep -v 'GtkDialog' >&2)
[ $? == 1 ] && exit 1
########################################################################
# LOGIN (=SALT)
salt="$(~/.zen/astrXbian/zen/tools/diceware.sh 3 | xargs)"
# PASS (=PEPPER)
pepper="$(~/.zen/astrXbian/zen/tools/diceware.sh 3 | xargs)"
g1_profil=$(zenity --entry --width 300 --text "Nom de votre machine" --title "Astroport -- Profil" --entry-text="$(hostname)" 2> >(grep -v 'GtkDialog' >&2));
g1_salt=$(zenity --entry --width 300 --text "Identifiant gchange/cesium (sel)" --title "Astroport - Sel" --entry-text="$salt" 2> >(grep -v 'GtkDialog' >&2));
[ ${#g1_salt} -lt 8 ] && zenity --warning --width 300 --text "Identifiant doit faire plus de 8 caractères!!" 2> >(grep -v 'GtkDialog' >&2) && cleanTMP && exit 1
g1_pepper=$(zenity --entry --width 300 --text "Mot de passe gchange/cesium (poivre)" --title "Astroport - Poivre" --entry-text="$pepper" 2> >(grep -v 'GtkDialog' >&2));
echo "CREATING /tmp/secret.june"
echo "$g1_salt" > /tmp/secret.june
echo "$g1_pepper" >> /tmp/secret.june
echo "________________ https://gchange.fr ________________" > /tmp/secret.all
cat /tmp/secret.june >> /tmp/secret.all
########################################################################
echo "CREATING /tmp/secret.dunikey"
python3 ~/.zen/astrXbian/zen/tools/key_create_dunikey.py "$g1_salt" "$g1_pepper"
g1pub=$(cat /tmp/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
g1sec=$(cat /tmp/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
echo "" >> /tmp/secret.all
echo "_________________ https://cesium.app _______________" >> /tmp/secret.all
cat /tmp/secret.dunikey >> /tmp/secret.all
echo "" >> /tmp/secret.all
########################################################################
echo "CREATING /tmp/config.ipfs"
ipfs_ID=$(python3 ~/.zen/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py)
echo $ipfs_ID > /tmp/secret.ipfs && source /tmp/secret.ipfs
jq -r --arg PeerID "$PeerID" '.Identity.PeerID=$PeerID' ~/.ipfs/config > /tmp/config.tmp
jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs
rm /tmp/config.tmp
echo "" >> /tmp/secret.all
echo "_____________________ IPFS ________________________" >> /tmp/secret.all
cat /tmp/secret.ipfs >> /tmp/secret.all
echo "" >> /tmp/secret.all
## Which directory to sync with IPFS
IPFS_sync_directory=$(zenity --file-selection --title="Choisissez le répertoire à partager par IPFS avec vos amis" --directory 2> >(grep -v 'GtkDialog' >&2))
[[ ! -d $IPFS_sync_directory ]] && zenity --warning --width 300 --text "Aucun répertoire... ANNULATION" 2> >(grep -v 'GtkDialog' >&2) && cleanTMP && exit 1
echo "IPFS_SYNC_DIR=$IPFS_sync_directory" >> /tmp/secret.all
########################################################################
echo "Copy new keys?"
zenity --width=971 --height=600 --title "Validation de votre configuration" --text-info --filename="/tmp/secret.all" 2> >(grep -v 'GtkDialog' >&2)
[ $? == 1 ] && cleanTMP && exit 1
[[ -f ~/.zen/secret.dunikey.old ]] && zenity --warning --width 300 --text "ANNULATION! Il existe déjà une sauvegarde d'anciennes clefs... support@qo-op.com" 2> >(grep -v 'GtkDialog' >&2) && cleanTMP && exit 1
mv ~/.zen/secret.june ~/.zen/secret.june.old
mv /tmp/secret.june ~/.zen/secret.june
mv ~/.zen/secret.dunikey ~/.zen/secret.dunikey.old
mv /tmp/secret.dunikey ~/.zen/secret.dunikey
mv ~/.zen/secret.ipfs ~/.zen/secret.ipfs.old
mv /tmp/secret.ipfs ~/.zen/secret.ipfs
mv ~/.ipfs/config ~/.ipfs/config.old
mv /tmp/config.ipfs ~/.ipfs/config
rm /tmp/secret.all
# WRITE ~/.zen/ipfs.sync CONFIG
echo "IPFS_SYNC_DIR=$IPFS_sync_directory" > ~/.zen/ipfs.sync
# CREATE gchange+ profile
# cd ~/.zen/astrXbian/zen/jaklis
# ./jaklis.py --key "~/.zen/secret.dunikey" --node "https://data.gchange.fr" set --name "$g1_profil" --avatar "~/.zen/astrXbian/logo.png"
# ERROR
echo "OK. Restart now"
zenity --warning --width 300 --text "Veuillez redémarrer l'ordinateur pour activer votre configuration..." 2> >(grep -v 'GtkDialog' >&2)
exit 0

View File

@ -152,13 +152,9 @@ sed -i s/_PROFIL_/$XZUID/g ~/.kodi/addons/plugin.video.vstream/resources/sites/a
sed -i s/_LOGIN_/$salt/g ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py
sed -i s/_MDP_/$pepper/g ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py
~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh
~/.zen/astrXbian/zen/cesium_IPFS_swarm.sh
~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh
# Optionnal PUBLISH actual (later done by cron_MINUTE.sh)
IXBIAN=$(ipfs add -qr ~/.zen/ipfs_swarm/xbian | tail -n 1)
JXBIAN=$(ipfs name publish -k xbian $I)
########################################################################
echo 'SEND "ipfstryme" message'
########################################################################
@ -170,7 +166,8 @@ do
done
echo 'SEND ipfstryme to oasis' # Add your bootstrap Pub here
./jaklis.py send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
./jaklis.py -n https://g1.data.le-sou.org send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
./jaklis.py -n https://data.gchange.fr send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
########################################################################
echo 'INSTALL Astroport cron_MINUTE'

View File

@ -92,7 +92,7 @@ fi
#
##################################################################
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/gchange_IPFS_swarm.sh &
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/cesium_IPFS_swarm.sh &
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh &
# Transfert ~/astroport/films to IPFS and make Vstream/ASTROPORT indexes on IPNS

View File

@ -8,8 +8,8 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
# Connect to IPFS peers with bidirectionnal "like" (gchange friends)
#
# Connect to IPFS peers with bidirectionnal "like" (Gchange or Cesium+ friends)
# configured in jaklis/.env
########################################################################
# \\///

View File

@ -38,23 +38,38 @@ do
filena="${filename%.*}"
echo "$filena;http://localhost:8181/ipfs/$AFSHARE/$filename" >> ~/.zen/ipfs/xbian/F${XZUID}
done
ipfs cat /ipns/$NODEIPNS/xbian/F${XZUID}
### TODO
### ADD Animes
### ADD Series
### Animes
echo "ADDING ~/astroport/animes/ to IPFS"
echo "-----------------------------------------------------------------"
AASHARE=$(ipfs add -rq ~/astroport/animes/ | tail -n 1)
[[ $AASHARE == "" ]] && echo "ipfs add ERROR" && exit 1
echo "WRITE ~/.zen/ipfs/xbian/A$XZUID Animes index"
echo "-----------------------------------------------------------------"
mkdir -p ~/.zen/ipfs/xbian
echo "CAT;TITLE;URLS" > ~/.zen/ipfs/xbian/A${XZUID}
for file in ~/astroport/animes/*
do
filename=$(basename -- "$file")
extension="${filename##*.}"
filena="${filename%.*}"
echo "animes;$filena;http://localhost:8181/ipfs/$AASHARE/$filename" >> ~/.zen/ipfs/xbian/A${XZUID}
done
ipfs cat /ipns/$NODEIPNS/xbian/A${XZUID}
########################################################################
echo "PUBLISH ~/.zen/ipfs to IPNS self"
echo "-----------------------------------------------------------------"
MIPFS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$MIPFS)
ipfs cat /ipns/$NODEIPNS/xbian/F${XZUID}
echo "SYNCing SWARM..."
echo "-----------------------------------------------------------------"
~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh
echo "PREPARE my local FASTRXBIAN (films) list from ipfs_swarm"
echo "PREPARE my local FASTRXBIAN (films) AASTRXBIAN (animes) global swarm list from ipfs_swarm"
echo "-----------------------------------------------------------------"
mkdir -p /tmp/xbian/
echo 'TITLE;URL' > /tmp/xbian/FASTRXBIAN
@ -62,6 +77,11 @@ cat ~/.zen/ipfs_swarm/xbian/F*-* | grep -v -E 'TITLE;URL' >> /tmp/xbian/FASTRXBI
cat /tmp/xbian/FASTRXBIAN | uniq > /tmp/xbian/FASTRXBIAN.uniq
mv /tmp/xbian/FASTRXBIAN.uniq /tmp/xbian/FASTRXBIAN
echo 'CAT;TITLE;URL' > /tmp/xbian/AASTRXBIAN
cat ~/.zen/ipfs_swarm/xbian/F*-* | grep -v -E 'TITLE;URL' >> /tmp/xbian/AASTRXBIAN
cat /tmp/xbian/AASTRXBIAN | uniq > /tmp/xbian/AASTRXBIAN.uniq
mv /tmp/xbian/AASTRXBIAN.uniq /tmp/xbian/AASTRXBIAN
echo "PUBLISH IPNS with 'xbian' key"
echo "-----------------------------------------------------------------"
ISTREAM=$(ipfs add -qrw /tmp/xbian/ | tail -n 1)