run from ~/.config/autostart/Astroport_X_config.desktop

This commit is contained in:
qo-op 2020-12-04 04:06:24 +01:00
parent ac61d1784a
commit c43852458b
2 changed files with 59 additions and 17 deletions

View File

@ -8,37 +8,80 @@
# This script is run from ~/.config/autostart/Astroport_X_config.desktop
#
########################################################################
# Create ~/.zen/secret(s) and ~/.zen/config
# Create
# /tmp/secret.june
# /tmp/secret.dunikey
# /tmp/secret.ipfs & /tmp/config.ipfs
#
#
[[ -f ~/.zen/config ]] && echo "CONFIG ALREADY DONE" && cat ~/.zen/config && exit 0
zenity --question --width 300 --text "Voulez-vous initialiser les clefs de votre station Astroport?" 2> >(grep -v 'GtkDialog' >&2)
[ $? == 1 ] && exit 1
########################################################################
# LOGIN (=SALT)
salt="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
# PASS (=PEPPER)
pepper="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
g1_profil=$(zenity --entry --text "Nom de votre profil Gchange" --title "Astroport -- Profil" --entry-text="$(hostname)");
g1_salt=$(zenity --entry --text "Un peu de sel" --title "Astroport - Sel" --entry-text="$salt");
g1_pepper=$(zenity --entry --text "Un peu de poivre" --title "Astroport - Poivre" --entry-text="$pepper");
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 (sel)" --title "Astroport - Sel" --entry-text="$salt" 2> >(grep -v 'GtkDialog' >&2));
g1_pepper=$(zenity --entry --width 300 --text "Mot de passe (poivre)" --title "Astroport - Poivre" --entry-text="$pepper" 2> >(grep -v 'GtkDialog' >&2));
echo "CREATE /tmp/secret.dunikey"
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/astroport/zen/tools/key_create_dunikey.py "$g1_salt" "$g1_pepper"
g1pub=$(cat ~/.zen/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
g1priv=$(cat ~/.zen/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
g1pub=$(cat /tmp/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
g1sec=$(cat /tmp/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
echo
echo "CREATE ~/.ipfs/config.new"
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/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py)
echo $ipfs_ID > ~/.zen/secret.ipfs
source ~/.zen/secret.ipfs
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 > ~/.ipfs/config.new
jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs
rm /tmp/config.tmp
echo $PeerID
echo $PrivKEY
echo "" >> /tmp/secret.all
echo "_____________________ IPFS ________________________" >> /tmp/secret.all
cat /tmp/secret.ipfs >> /tmp/secret.all
echo "" >> /tmp/secret.all
echo
########################################################################
echo "Copy new keys?"
zenity --width=800 --height=600 --title "Valider Configuration" --text-info --filename="/tmp/secret.all" 2> >(grep -v 'GtkDialog' >&2)
[ $? == 1 ] && exit 1
[[ -f ~/.zen/secret.dunikey.old ]] && zenity --warning --width 300 --text "Sauvegarde des anciennes clefs impossible... ANNULATION" 2> >(grep -v 'GtkDialog' >&2) && 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
echo "OK. Restart now"
zenity --warning --width 300 --text "Pour activer votre configuration... Redemarrer votre ordinateur !!!" 2> >(grep -v 'GtkDialog' >&2)

View File

@ -79,7 +79,6 @@ EOF
echo "$salt" > ~/.zen/secret.june
echo "$pepper" >> ~/.zen/secret.june
echo "$g1pub" >> ~/.zen/secret.june
chmod 400 ~/.zen/secret*
echo "~/.zen/secret(s) are OK !"