better ssb_INIT.sh

This commit is contained in:
qo-op 2020-03-22 04:45:20 +01:00
parent c47d7a1ebf
commit 6e59afd517
3 changed files with 129 additions and 12 deletions

23
zen/g1ssb_ENV.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.22
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$ME'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# [ASTROPORT](https://astroport.com)
########################################################################'
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)

View File

@ -36,31 +36,112 @@ echo '
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
# CREATE ~/.zen/ipfs/.$IPFSNODEID/G1SSB
##############################################
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFSNODEID NODE_G1PUBKEY" && exit 1
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
if [[ $ssbpub == "" ]]; then
EXTERNAL=$(cat /etc/hostname).local
mkdir -p ~/.ssb
echo"
_ __ __ _
_ _ .__|_o _ (_ (_ |_)
(_(_)| || |(_| __)__)|_)
_|
$EXTERNAL
"
[[ -f ~/.ssb/config ]] && cp -f ~/.ssb/config ~/.ssb/config.bkp
cat > ~/.ssb/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public", "external": ["$EXTERNAL"], "transform": "shs", "port": 8008
},
{ "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" }
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF
echo "
__ _ _ _ _
(_ |_|_)\ /|_|_) o._ o_|_
__)|_| \ \/ |_| \ || || |_
"
cat > ~/.zen/run-ssb-PUB_$EXTERNAL.sh <<EOF
#!/bin/bash
while true; do
ssb-server start --host $EXTERNAL 2>/dev/null
done
EOF
chmod 755 ~/.zen/run-ssb-PUB_$EXTERNAL.sh
~/.zen/run-ssb-PUB_$EXTERNAL.sh &
sleep 3
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
fi
echo "
$ssbpub
_____ _____ _
(_ | /\ |_)||_| \
oooooooo__) |/--\| \||_|_/
"
## PUBLISH ABOUT MESSAGE
##############################################
ssbpub=$(sbotc whoami | jq -r .id)
[[ $ssbpub == "" ]] && echo "ERROR missing ssb-server ?" && exit 1
# G1 wallet QRCode
# CREATE G1 wallet QRCode
qrcodefile=~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.qrcode.png
qrencode -s 5 -o $qrcodefile "$NODE_G1PUBKEY"
# Publish About message
# Publish G1 Wallet PUBKEY QRCode to SSB
name=${qrcodefile##*/}
id="$(sbotc blobs.add < $qrcodefile)"
type="$(file -b --mime-type $qrcodefile)"
size="$(wc -c < $qrcodefile)"
# Publish About message
sbot publish --type about --about $ssbpub --description "Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station [$IPFSNODEID](http://localhost/ipns/$IPFSNODEID)" --name "$USER@$(cat /etc/hostname)" --image "$id"
#sbotc publish '{"type":"about","about":"'"$ssbpub"'","description":"Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station\nhttp://'$(cat /etc/hostname)'.local/ipns/$IPFSNODEID","name":'"'$USER'@'$(cat /etc/hostname)'"',"image":'"'$id'"'}'
# Publish ABOUT
sbot publish --type about --about $ssbpub --description "Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station [$IPFSNODEID](http://localhost:8080/ipns/$IPFSNODEID)" --name "$USER@$(cat /etc/hostname)" --image "$id"
# Publish QRCode FILE post
sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to order ZenTag...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
# COPY NODE G1SSB ID to IPFS
echo "$ssbpub" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ssb.whoami
echo "$NODE_G1PUBKEY" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
echo "
/\ |_ _ _|_
/--\|_)(_)|_||_
$ssbpub
http://localhost:8080/ipns/$IPFSNODEID/.$IPFSNODEID/G1SSB/
INVITATION : $(sbotc invite.create 1)
"

View File

@ -204,15 +204,15 @@ READ : $READ Zen
PARK : $PARK Zen
"
fi
########################################################################
# PASSENGER DIRECTORY
# if [[ -d $PASSENGER ]]; then
########################################################################
# TODO # tar.gz and encrypt a whole directory #
# tar -zcf - directory | openssl aes-128-cbc -pbkdf2 -k "$BB" -salt -out directory.tar.gz.aes # Encrypt
# openssl aes-128-cbc -pbkdf2 -k "$BB" -d -salt -in directory.tar.gz.aes | tar -xz -f - # Decrypt
########################################################################
fi
###########################################################
# Copy TAG into IPFS + ipfs name publish -k ${AA}.key
@ -275,6 +275,19 @@ qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.write.png "BJ:${BB}#${J}"
echo "DONE !!
${AA}"
########################################################################
# SBOT PUBLISH
########################################################################
echo '
__ _ ____
(_ |_)/ \|
__)|_)\_/|
'
sbotc publish '{"type":"post","text":"ZenTAG created"}'
########################################################################
# IPFS CLEANING (MANUAL OPERATION)
########################################################################