astrXbian/zen/tools/init_IPFS_with_cesium_login...

116 lines
4.6 KiB
Bash
Executable File

#!/bin/bash
{
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
[[ -f ~/.zen/secret ]] && echo "Please rm -f ~/.zen/secret* before running $ME" && exit 1
echo '>>>>>>> METAVERSE KEY CREATION <<<<<<<<
__ __ ____
__/ // /_______ ______ __________ ___ / __ \
/_ _ __/ ___/ | /| / / __ `/ ___/ __ `__ \/ / / /
/_ _ __(__ )| |/ |/ / /_/ / / / / / / / / /_/ /
/_//_/ /____/ |__/|__/\__,_/_/ /_/ /_/ /_/\____/
CESIUM 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 "Hit ENTER again to continue" && 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/astrXbian/zen/tools/diceware.sh ]] \
&& mkdir -p ~/.zen/astrXbian/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/diceware.sh -o ~/.zen/astrXbian/zen/tools/diceware.sh \
&& chmod +x ~/.zen/astrXbian/zen/tools/diceware.sh
[[ ! -f ~/.zen/astrXbian/zen/tools/diceware-wordlist.txt ]] \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/diceware-wordlist.txt -o ~/.zen/astrXbian/zen/tools/diceware-wordlist.txt
# LOGIN (=SALT)
salt="miz $(~/.zen/astrXbian/zen/tools/diceware.sh 2 | xargs)"
# PASS (=PEPPER)
pepper="$(~/.zen/astrXbian/zen/tools/diceware.sh 2 | xargs)"
fi
echo "........."
# CREATE /tmp/secret.dunikey
[[ ! -f ~/.zen/astrXbian/zen/tools/key_create_dunikey.py ]] \
&& mkdir -p ~/.zen/astrXbian/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/key_create_dunikey.py -o ~/.zen/astrXbian/zen/tools/key_create_dunikey.py \
&& chmod +x ~/.zen/astrXbian/zen/tools/key_create_dunikey.py
python3 ~/.zen/astrXbian/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 "ZENID=\"$salt\"
ZENPWD=\"$pepper\"
"
g1pub=$(cat ~/.zen/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
g1priv=$(cat ~/.zen/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
# make ScutlleButt secret key
ssbpub=$(echo $g1pub | base58 -d | base64)
ssbpriv=$(echo $g1priv | base58 -d | base64 | tr -d "\n" )
cat > ~/.zen/secret <<EOF
{
"curve": "ed25519",
"public": "${ssbpub}.ed25519",
"private": "${ssbpriv}.ed25519",
"id": "@${ssbpub}.ed25519"
}
EOF
echo "$salt" > ~/.zen/secret.june
echo "$pepper" >> ~/.zen/secret.june
chmod 400 ~/.zen/secret*
echo "~/.zen/secret(s) are OK !"
# MODIFY ~/.ipfs/config
[[ ! -f ~/.zen/astrXbian/zen/tools/crypto_pb2.py ]] \
&& mkdir -p ~/.zen/astrXbian/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/crypto_pb2.py -o ~/.zen/astrXbian/zen/tools/crypto_pb2.py \
[[ ! -f ~/.zen/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py ]] \
&& mkdir -p ~/.zen/astrXbian/zen/tools/ \
&& curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py -o ~/.zen/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py \
&& chmod +x ~/.zen/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py
ipfs_ID=$(python3 ~/.zen/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py)
echo $ipfs_ID > ~/.zen/secret.ipfs
source ~/.zen/secret.ipfs
cat ~/.zen/secret.ipfs
echo
echo
echo "########################################################"
echo "Welcome to the G1 DRIVE"
echo "Configure IPFS: copy the lines above in your console"
echo "then run jq commands and make your IPFS NODE https://Cesium.app compatible"
echo " -> Read your Cesium messages to find how to Bootstrap your node"
echo
echo "cp -f ~/.ipfs/config ~/.ipfs/config.old"
echo "jq -r --arg PeerID \"\$PeerID\" '.Identity.PeerID=\$PeerID' ~/.ipfs/config > /tmp/config.tmp"
echo "jq -r --arg PrivKEY \"\$PrivKEY\" '.Identity.PrivKey=\$PrivKEY' /tmp/config.tmp > ~/.ipfs/config"
echo ""
[[ -f /tmp/init_IPFS_with_cesium_loginKEY.sh ]] && cp -f /tmp/init_IPFS_with_cesium_loginKEY.sh ~/.zen/astrXbian/zen/tools/
rm -f /tmp/secret.dunikey
}