astroport/zen/tools/init_IPFS_with_cesium_login...

85 lines
3.6 KiB
Bash

#!/bin/bash
{
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '>>>>>>> METAVERSE KEY CREATION <<<<<<<<
__ __ ____
__/ // /_______ ______ __________ ___ / __ \
/_ _ __/ ___/ | /| / / __ `/ ___/ __ `__ \/ / / /
/_ _ __(__ )| |/ |/ / /_/ / / / / / / / / /_/ /
/_//_/ /____/ |__/|__/\__,_/_/ /_/ /_/ /_/\____/
KEY
CHOOSE YOU LOGIN (min 8 car. best is more than 6 words!!)...
or LEAVE BLANK and HIT ENTER FOR diceware AUTO GENERATION
'
read salt
[[ $salt != "" ]] && echo "CHOOSE PASSWORD?" && read pepper && [[ $pepper == "" ]] && echo "AARRRRGGG why no pepper? exiting" && exit 1
if [[ "$salt" == "" && "$pepper" == "" ]]; then
echo '
._ _ ._ _ ._ _ _ ._ o _
| | | | | (/_ | | | (_) | | | (_
diceware passphrase generator...'
# INSTALL diceware files ## TODO REPLACE WITH ipfs links
[[ ! -f ~/.zen/astroport/zen/tools/diceware.sh ]] \
&& mkdir -p ~/.zen/astroport/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/diceware.sh -o ~/.zen/astroport/zen/tools/diceware.sh \
&& chmod +x ~/.zen/astroport/zen/tools/diceware.sh
[[ ! -f ~/.zen/astroport/zen/tools/diceware-wordlist.txt ]] \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/diceware-wordlist.txt -o ~/.zen/astroport/zen/tools/diceware-wordlist.txt
# LOGIN (=SALT)
salt="$(~/.zen/astroport/zen/tools/diceware.sh 6 | xargs)"
# PASS (=PEPPER)
pepper="$(~/.zen/astroport/zen/tools/diceware.sh 4 | xargs)"
fi
echo "........."
# CREATE /tmp/secret.dunikey
[[ ! -f ~/.zen/astroport/zen/tools/key_create_dunikey.py ]] \
&& mkdir -p ~/.zen/astroport/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/key_create_dunikey.py -o ~/.zen/astroport/zen/tools/key_create_dunikey.py \
&& chmod +x ~/.zen/astroport/zen/tools/key_create_dunikey.py
python3 ~/.zen/astroport/zen/tools/key_create_dunikey.py "$salt" "$pepper"
sleep 1
[[ ! -f /tmp/secret.dunikey ]] && echo "AARRRRGGG problem happens making your secret.dunikey exiting" && exit 1
[[ -f /tmp/secret.dunikey ]] && cp -f /tmp/secret.dunikey ~/.zen/
echo "#YOUR CESIUM SWARM0 IDENTITY
ZENID=\"$salt\"
ZENPWD=\"$pepper\" IS :
"
g1pub=$(cat ~/.zen/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
echo "G1PUB=\"$g1pub\"" >> ~/.zen/secret.astroport.key
g1priv=$(cat ~/.zen/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
ssbpub=$(echo $g1pub | base58 -d | base64)
ssbpriv=$(echo $g1priv | base58 -d | base64 | tr -d "\n" )
# MODIFY ~/.ipfs/config
[[ ! -f ~/.zen/astroport/zen/tools/crypto_pb2.py ]] \
&& mkdir -p ~/.zen/astroport/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/crypto_pb2.py -o ~/.zen/astroport/zen/tools/crypto_pb2.py \
[[ ! -f ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py ]] \
&& mkdir -p ~/.zen/astroport/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py -o ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py \
&& chmod +x ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py
echo "execute python3 ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py"
# jq '.Identity.PeerID="$PeerID"' ~/.ipfs/config
# jq '.Identity.PrivKey="$PrivKey"' ~/.ipfs/config
# rm -f /tmp/secret.dunikey
}