From bfbd44509e3542ce35e14e16d7f3dbeb012e558e Mon Sep 17 00:00:00 2001 From: qo-op Date: Mon, 11 May 2020 01:16:16 +0200 Subject: [PATCH] G1SMS --- g1sms/init.sh | 112 ++++++++++++++++++++++++--------------------- g1sms/init_keys.sh | 45 ++++++++++++++++-- 2 files changed, 101 insertions(+), 56 deletions(-) diff --git a/g1sms/init.sh b/g1sms/init.sh index 5b57f79..1e9ffbc 100755 --- a/g1sms/init.sh +++ b/g1sms/init.sh @@ -29,58 +29,66 @@ else export G1SMS="YES" fi +echo " + _ _ __ + (_)___ (_) /_ + / / __ \/ / __/ + / / / / / / /_ +/_/_/ /_/_/\__/ + +g1sms $G1SMS +" - export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); - cd $MY_PATH - ################################################################## - # Activate logging to /tmp/g1sms.log (YES/NO) - export DOLOG="YES" - export CPERROR="NOYES" - ################################################################## - # Country Node Phone international prefix (TODO Worldwide) - export COUNTRY="+33" +export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); - ################################################################## - # Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents) - export COIN="G1" - ################################################################## - # Limit and commission values - export LIMIT=2 # Solde minimum = 2 G1 - # FIXED COMMISSION SYSTEM - export COMMISSION=1 # transaction commission amount (G1) - export BILLCOM=20 - ################################################################## - # COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK - # PART COMMISSION SYSTEM - export SWARMCOMM=10 - # TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES - export NODECOMM=10 - ################################################################## - # SMS SIM Card Phone Number - export MASTERPHONE="+33695196729" - export ADRESSE="G1Pub" - export G1DAB="NO" - ################################################################## - # ADMIN COMMAND PHONE ORIGIN - export ADMINPHONE="+33647683646" - export ADMINPSEUDO="Fred" - ################################################################## - # DUNITER/CESIUM+ DEFAULT SERVERS - - export DUNITER="https://g1.duniter.org" - export CESIUM="https://g1.data.le-sou.org" - ################################################################## - # DU has a G1 value changed every 6 month! - # "~/.zen/_DU" removed every 6 month for refresh - if [[ -f ~/.zen/_DU ]]; then - export DUFACTOR=$(bc <<< "scale=2; $(cat ~/.zen/_DU) / 100") - else - LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1) || exit 1 - [[ $LASTDU != "" ]] && curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq -r '.dividend' > ~/.zen/_DU || exit 1 - export DUFACTOR=$(bc <<< "scale=2; $(cat ~/.zen/_DU) / 100") - fi - - # TODO Use latest Silkaj from "sudo fredp3 install silkaj" - # export SILKAJ="/usr/local/bin/silkaj" - source $MY_PATH/init_keys.sh +################################################################## +# Activate logging to /tmp/g1sms.log (YES/NO) +export DOLOG="YES" +export CPERROR="NOYES" +################################################################## +# Country Node Phone international prefix (TODO Worldwide) +export COUNTRY="+33" + +################################################################## +# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents) +export COIN="G1" +################################################################## +# Limit and commission values +export LIMIT=2 # Solde minimum = 2 G1 +# FIXED COMMISSION SYSTEM +export COMMISSION=1 # transaction commission amount (G1) +export BILLCOM=20 +################################################################## +# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK +# PART COMMISSION SYSTEM +export SWARMCOMM=10 +# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES +export NODECOMM=10 +################################################################## +# SMS SIM Card Phone Number +export MASTERPHONE="+33695196729" +export ADRESSE="G1Pub" +export G1DAB="NO" +################################################################## +# ADMIN COMMAND PHONE ORIGIN +export ADMINPHONE="+33647683646" +export ADMINPSEUDO="Fred" +################################################################## +# DUNITER/CESIUM+ DEFAULT SERVERS +export DUNITER="https://g1.duniter.org" +export CESIUM="https://g1.data.le-sou.org" +################################################################## +# DU has a G1 value changed every 6 month! +# "~/.zen/_DU" removed every 6 month for refresh +if [[ -f ~/.zen/_DU ]]; then + export DUFACTOR=$(bc <<< "scale=2; $(cat ~/.zen/_DU) / 100") +else + LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1) || exit 1 + [[ $LASTDU != "" ]] && curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq -r '.dividend' > ~/.zen/_DU || exit 1 + export DUFACTOR=$(bc <<< "scale=2; $(cat ~/.zen/_DU) / 100") +fi + +# TODO Use latest Silkaj from "sudo fredp3 install silkaj" +# export SILKAJ="/usr/local/bin/silkaj" +source $MY_PATH/init_keys.sh diff --git a/g1sms/init_keys.sh b/g1sms/init_keys.sh index 02e043a..dbd42a5 100755 --- a/g1sms/init_keys.sh +++ b/g1sms/init_keys.sh @@ -16,8 +16,32 @@ YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail IPFSNODEID=$(ipfs id -f='\n') NANODATE=$(date -u +%s%N) #1569692075385428020 +echo " +$NANODATE + _ _ __ __ + (_)___ (_) /_ / /_____ __ _______ + / / __ \/ / __/ / //_/ _ \/ / / / ___/ + / / / / / / /_ / ,< / __/ /_/ (__ ) +/_/_/ /_/_/\__/ /_/|_|\___/\__, /____/ + /____/ + +$YOU on $IPFSNODEID ipfs node + +" + ################################################################## # G1sms+ Node KEYS (G1wallet, gpg, IPNS) +echo ' + + ________ ___________ ____ _ __ __ + / _/ __ \/ ____/ ___// __ \_____(_) __/ //_/__ __ __ + / // /_/ / /_ \__ \/ /_/ / ___/ / | / / ,< / _ \/ / / / + _/ // ____/ __/ ___/ / ____/ / / /| |/ / /| / __/ /_/ / +/___/_/ /_/ /____/_/ /_/ /_/ |___/_/ |_\___/\__, / + /____/ +Formed with 24 first char IPFS .Identity.PrivKey +Used as gpg symetric key (soon deprecated?) +' ################################################################## IPFSPrivKey=$(cat ~/.ipfs/config | jq -r '.Identity.PrivKey') #" export IPFSPrivKey="${IPFSPrivKey:0:24}" # @@ -32,7 +56,8 @@ if [ ! $IPFSPrivKey ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey IPFSP # ONE TIME GIVE NODE_UIDNA if [[ ! -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]]; then # CREATE NODE G1 KEYS AND FILES - mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TASK + mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TASK + #################################################################### # GIVE NAME TO NODE G1 WALLET: "6789diceware" # And write ~/.zen/g1sms_wallets/.Qm***/G1SSB/(_files) @@ -42,12 +67,22 @@ if [[ ! -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]]; then # Check if already existing among all swarm wallets G1SSB or G1SMS while [[ $(grep -Rwl "$PRE$ZUID" ~/.zen/ipfs_swarm/.*/*/_uidna) ]]; do ZUID=$($MY_PATH/diceware.sh 1 | xargs); done NODE_UIDNA="$PRE$ZUID" - NODE_PIN=$($MY_PATH/diceware.sh | xargs) + +echo " + __ __________ _ _____ + / / / / _/ __ \/ | / / | + / / / // // / / / |/ / /| | +/ /_/ // // /_/ / /| / ___ | +\____/___/_____/_/ |_/_/ |_| + +$NODE_UIDNA +" [[ -f ~/.zen/secret.astroport.key ]] \ && [[ ! $(cat ~/.zen/secret.astroport.key | grep -F 'NODE_UIDNA' )]] \ - && chmod 600 ~/.zen/secret.astroport.key - && echo "NODE_UIDNA=$NODE_UIDNA" >> ~/.zen/secret.astroport.key + && chmod 600 ~/.zen/secret.astroport.key \ + && echo "NODE_UIDNA=$NODE_UIDNA" >> ~/.zen/secret.astroport.key \ + || echo "ERROR NO ~/.zen/secret.astroport.key !!" && exit 1 source ~/.zen/secret.astroport.key @@ -82,7 +117,9 @@ fi ## INIT NODE G1 PUB & PRIV KEY NODE_G1PUBKEY=$ZENG1 +[[ ! $NODE_G1PUBKEY ]] && echo "Missing NODE_G1PUBKEY" && exit 1 NODE_PUBSECFILE="~/.ssb/secret.dunikey" +[[ ! $NODE_PUBSECFILE ]] && echo "Missing NODE_PUBSECFILE" && exit 1 ########################################################## # MEMORIZE NODE NANODATE EXECUTION TIME (for ntpdate regular sync)