2020-12-04 19:42:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
########################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
2020-12-04 19:48:27 +01:00
|
|
|
# Version: 2020.12.05
|
2020-12-04 19:42:28 +01:00
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
########################################################################
|
2020-12-04 19:48:27 +01:00
|
|
|
# AUTOMATIC version of interactive 1stRUNconfig.sh
|
|
|
|
# This script can run from ~/.config/autostart/Astroport_X_config.desktop
|
|
|
|
#
|
2020-12-04 19:42:28 +01:00
|
|
|
########################################################################
|
|
|
|
# Create secret key files
|
|
|
|
# ~/.zen/secret.june
|
|
|
|
# ~/.zen/secret.dunikey
|
|
|
|
# ~/.zen/secret.ipfs & /tmp/config.ipfs
|
|
|
|
# ~/.zen/ipfs.sync
|
|
|
|
########################################################################
|
|
|
|
[[ -f ~/.zen/ipfs.sync ]] && echo "CONFIG ALREADY DONE" && source ~/.zen/ipfs.sync && exit 0
|
|
|
|
|
|
|
|
########################################################################
|
2020-12-04 19:48:27 +01:00
|
|
|
echo "CREATING Gchange credentials"
|
|
|
|
|
2020-12-04 19:42:28 +01:00
|
|
|
salt="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
|
2020-12-04 19:48:27 +01:00
|
|
|
[[ $salt == "" ]] && echo "ERROR" && exit 1
|
2020-12-04 19:42:28 +01:00
|
|
|
pepper="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
|
|
|
|
|
|
|
|
g1_profil=$(hostname)
|
|
|
|
g1_salt="$salt"
|
|
|
|
g1_pepper="$pepper"
|
|
|
|
|
|
|
|
echo "CREATING /tmp/secret.june"
|
|
|
|
echo "$g1_salt" > /tmp/secret.june
|
|
|
|
echo "$g1_pepper" >> /tmp/secret.june
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
echo "CREATING /tmp/secret.dunikey"
|
|
|
|
python3 ~/.zen/astroport/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 "CREATING /tmp/config.ipfs"
|
|
|
|
ipfs_ID=$(python3 ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py)
|
|
|
|
echo $ipfs_ID > /tmp/secret.ipfs && source /tmp/secret.ipfs
|
2020-12-04 19:48:27 +01:00
|
|
|
[[ $PrivKEY == "" ]] && echo "ERROR" && exit 1
|
2020-12-04 19:42:28 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
## Directory transfered to IPFS
|
|
|
|
IPFS_sync_directory="$HOME/.zen/miam"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# WRITE ~/.zen/ipfs.sync CONFIG
|
|
|
|
echo "IPFS_SYNC_DIR=$IPFS_sync_directory" > ~/.zen/ipfs.sync
|
|
|
|
|
|
|
|
# CREATE gchange+ profile
|
2020-12-04 23:31:28 +01:00
|
|
|
cd ~/.zen/astroport/zen/jaklis
|
|
|
|
./jaklis.py set --name "$(hostname)" --avatar "$HOME/.zen/astroport/logo.png"
|
|
|
|
|
|
|
|
# BECOME FRIEND with oasis
|
|
|
|
./jaklis.py like -p 6Wjem2gFeTRDBz9UvxxS1reVnDhNnjwny6AJJjTC5hDK -s 5
|
2020-12-04 19:42:28 +01:00
|
|
|
|
|
|
|
echo "Restart IPFS"
|
|
|
|
sudo service ipfs restart
|
|
|
|
|
|
|
|
exit 0
|