G1Billets + TAG + init_keys

This commit is contained in:
qo-op 2020-01-06 18:37:28 +01:00
parent f6488164d7
commit efb0e04ddf
18 changed files with 517 additions and 181 deletions

2
_chain
View File

@ -1 +1 @@
QmbVfLJ9UsnyV3Si9UgZVS4srCnL1c2Gqt7XissCV4iC83
QmeNcQbpgX1e3SYZq2PweqYVKeYM923gGCkmLrLpZuKUbQ

View File

@ -178,3 +178,7 @@ OK
2019-12-20: NOW
2019-12-21: Various
2019-12-24:
2020-01-02: Noel merge code
2020-01-02: g1sms.preoni
2020-01-04: BACKUP
2020-01-06: bugs

View File

@ -1 +1 @@
1577203467543924569
1578331888355885994

Binary file not shown.

View File

@ -3,7 +3,7 @@
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# BACKUP G1sms+ current Devlt code and push it with NODE_G1PRIVKEYFILE encryption to IPFS
# BACKUP G1sms+ current Devlt code and push it with SWARM_CODE_MASTER to IPFS
################################################################################
source ./shell/init.sh
source ./shell/functions.sh
@ -37,7 +37,7 @@ cd ..
# with iterative update _chain, _nanodate, _zen, _g1cents values
# + _external UID references & _comments lines
###########################################################################################
echo "PLEASE WAIT.... INITIALIZING G1 Object ipfs chain files:"
echo "PLEASE WAIT...."
echo "GIT" > "./$dir/_type"
hop=$(cat "./$dir/_chain")
LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1); curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq '.dividend' > "./$dir/_DU";
@ -53,7 +53,7 @@ echo $(date +%s%N) > "./$dir/_nanodate"
echo "$now: $COMMENT" >> "./$dir/_comments"
# TAR G1sms+ FILES (WITH EXCLUSIONS!!)
tar -cvzf ~/G1sms+_backup_$now.tar.gz --exclude 'authfile' --exclude 'init.sh' --exclude '.git' --exclude 'billets' --exclude 'constants.py' --exclude 'TAG' --exclude 'history*' --exclude 'trash' --exclude 'print' --exclude 'wallets' --exclude 'wallets_swarm' --exclude 'g1sms.priv.key' ./$dir
tar -cvzf ~/G1sms+_backup_$now.tar.gz --exclude 'g1sms.preoni.*' --exclude 'authfile' --exclude 'init.sh' --exclude '.git' --exclude 'billets' --exclude 'constants.py' --exclude 'TAG' --exclude 'history*' --exclude 'trash' --exclude 'print' --exclude 'wallets' --exclude 'wallets_swarm' --exclude 'g1sms.priv.key' ./$dir
mkdir -p /tmp/CODE/ && tar xzf ~/G1sms+_backup_$now.tar.gz -C /tmp/CODE/ && rm -f ~/G1sms+_backup_$now.tar.gz

View File

@ -123,14 +123,14 @@ if [[ $PHONE ]]; then rm -Rf ./wallets_swarm/$PHONE; fi
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
count=1
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
for id in ./wallets_swarm/.Qm*/;
#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
#for id in ./wallets/.Qm*/;
for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
#log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
rm -Rf ./wallets_swarm/.$id
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
done
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"
@ -250,7 +250,7 @@ function sms_uid2key (){
# Search fo duplicate
DUP=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidname | cut -f 3 -d '/')
if [[ "$DUP" != "" ]]; then
if [[ "$DUP" != "" && "$DUP" != "$PHONE" ]]; then
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE prend le même $ASKWALLET, que $DUP"
sms_SEND "$DUP" "Vous devez savoir que $ASKWALLET est associé à un autre téléphone que le votre également!"
fi
@ -313,7 +313,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
SMSNODE="./wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password
GPGPINFILE="./wallets/$PHONE/$PHONE.pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
AUTHCRYPTFILE="./wallets/$PHONE/$PHONE.authfile.crypt" # TEST!!! crypt with $PHONE wallet keypair
AUTHCRYPTFILE="./wallets/$PHONE/$PHONE.authfile.crypt" # Crypt with $NODE_G1PUBKEY
PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" # Contains phone wallet public key (RIB)
UNITFILE="./wallets/$PHONE/$PHONE.unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
@ -347,7 +347,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
# BACKUP authfile available to authfile or PIN owner (DOUBLON AVEC PIN) TEST
log "__SUB:sms_INIT_ACCOUNT: ./shell/natools.py encrypt -p $PUBKEY -i ""./authfile"" -o ""$AUTHCRYPTFILE"""
./shell/natools.py encrypt -p $PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
rm -f ./authfile
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE $PIN : $PUBKEY"
@ -378,7 +378,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
echo "$PIN" > "$PINFILE"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
PIN=$(cat "$PINFILE" | xargs)
echo "" > "$PINFILE"
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
echo "114" > "$G1COUNTFILE"
echo "$PUBKEY" > "$PUBKEYFILE"
@ -413,6 +413,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
PIN=$(cat "$PINFILE" | xargs)
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE";
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$PINFILE" -o "$PINFILE.node.crypt"
else
# ------------>8------------------
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
@ -420,7 +421,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
# TODO make decypher less stress on filesystem, use /tmp and ramdisk
echo "${GPGPASS}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
PIN=$(cat "$PINFILE" | xargs)
echo "" > "$PINFILE";
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
fi
# CYPHER EMAIL FILE
@ -559,7 +560,6 @@ esac
log "__SUB:make_accounting: LOCAL $VIR amount for $PHONE : $PUBKEY"
# Try to ask silkaj. If timeout, use SWARM last known $PHONE.g1cents value
AMOUNTG1=$(./shell/timeout.sh -t 20 ./silkaj/silkaj amount "$PUBKEY")
if [[ ! $AMOUNTG1 ]]; then AMOUNTG1=$(bc -l <<< "scale=2; $(cat ./wallets_swarm/$PHONE/$PHONE.g1cents) / 100"); fi
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi
# TAX AND MINIMUM WALLET ACCOUNT CALCULATION
PERCENT=0$(bc -l <<< "scale=2; $VIR / $SWARMCOMM")

View File

@ -1,7 +1,7 @@
#!/bin/bash
##################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2
# License: GPL (http://www.google.com/search?q=GPL)
##################################################################
# CHECK & WARN | CREATE Keys (gpg encrypt, G1wallet, IPNS publish)
@ -13,143 +13,136 @@ if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
# TODO Make it directory independant. (for now it is tested for pi running ipfs and code in $HOME/G1sms+
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
NANODATE=$(date -u +%s%N) #1569692075385428020
##################################################################
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
##################################################################
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g)
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g) #"
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
# GET SWARM KEY G1sms+ .ipfs/swarm.key
export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
##################################################################
# G1sms+ Swarm KEYS
##################################################################
# G1sms Service - G1Wallet
if [[ -f "${GPATH}/g1sms.pub.key" && -f "${GPATH}/g1sms.priv.key" ]]; then
chown root:root ${GPATH}/g1sms.priv.key
chmod 600 ${GPATH}/g1sms.priv.key
export NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
export NODE_G1PRIVKEYFILE="${GPATH}/g1sms.priv.key"
else
echo "ATTENTION!! Vous devez posséder la clef du G1 Wallet utilisé par le SWARM G1sms!!"
./shell/parle.sh "Les clefs du portefeuille essaim G1 SMS sont absente. Au revoir."
echo "Fichiers manquants:"
echo "${GPATH}/g1sms.pub.key"
echo "${GPATH}/g1sms.priv.key"
echo "Contactez nous sur https://g1sms.fr"
log "${GPATH}/g1sms.pub.key"
log "${GPATH}/g1sms.priv.key"
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "Clef de G1Wallet du SWARM g1sms.priv.key manquante! contactez-nous pour la recevoir https://g1sms.fr" 1>&2
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "Debug: ${GPATH}/g1sms.pub.key et ${GPATH}/g1sms.priv.key" 1>&2
exit
#
# CLEF G1 DU SWARM
SWARM_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
SWARM_G1AUTHFILE="${GPATH}/g1sms.priv.key"
# CLEF G1 NODE = CLEF G1 SWARM !!
if [[ ! -e "./g1sms.preoni.pub.key" && -f "./g1sms.priv.key" ]]; then
log "__SUB:initkeys.sh: Linking preoni Keys to SWARM G1 Keys"
ln -s ./g1sms.priv.key ./g1sms.preoni.priv.key
ln -s ./g1sms.pub.key ./g1sms.preoni.pub.key
elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
# CREATE NODE G1 KEYS AND FILES
mkdir -p ./wallets/.$IPFSNODEID/TASK
################################################
# GIVE NAME TO NODE G1 WALLET: "0000diceware"
# CREATE "preoni" KeyS & ./wallets/.Qm***/_files
################################################
# 4 derniers chiffres du MASTERPHONE + diceware
PRE=${MASTERPHONE:8:4}
ZUID=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl "$PRE$ZUID" ./wallets_swarm/.*/_uidna) ]]; do ZUID=$(./shell/diceware.sh 1 | xargs); done
NODE_UIDNA="$PRE$ZUID"
NODE_PIN=$(./shell/diceware.sh | xargs)
NODE_G1PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN")
if [[ ! $NODE_G1PUBKEY ]]; then log "PROBLEME CREATION DU WALLET G1 POUR $NODE_UIDNA = $IPFSNODEID"; exit; fi
log "__SUB:initkeys.sh: NODE G1WALLET CESIUM: $NODE_UIDNA / $NODE_PIN CREATED..."
# WRITE NODE_UIDNA
echo "$NODE_UIDNA" > "./wallets/.$IPFSNODEID/_uidna" ################# _uidna
############ SYSTEM MODIFY hosts & hostname ################
# WRITE NODE uidna NAME TO /etc/hosts & .Qm*/_uidna file
echo "127.0.0.101 $NODE_UIDNA" >> "/etc/hosts"
echo $NODE_UIDNA > "/etc/hostname"
############################################################
# BACKUP AUTHFILE FOR FOR SWARM USE (TODO: Refine Swarm, Node access)
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "./wallets/.$IPFSNODEID/_authfile.swarm.crypt"
echo $NODE_G1PUBKEY > "./wallets/.$IPFSNODEID/_pub" ################# _pub
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/_ipfsid" ################# _ipfsid
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY "
# BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ./wallets/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
# Cyper & Empty PIN
echo "${NODE_PIN}" > "./wallets/.$IPFSNODEID/_pin" ################# _pin / _pin.node.crypt / _pin.gpg
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./wallets/.$IPFSNODEID/_pin" -o "./wallets/.$IPFSNODEID/_pin.node.crypt"
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/_pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/_pin"
echo "" > "./wallets/.$IPFSNODEID/_pin"
echo "314" > "./wallets/.$IPFSNODEID/_g1cents" ################# _g1cents
echo $NANODATE > "./wallets/.$IPFSNODEID/_nanodate" ################# _nanodate
# SILKAJ INIT G1 NODE WALLET
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1AUTHFILE" --amount=3.24 --output=$NODEG1WALLET --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $UIDNA $IPFSNODEID" -y)
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS" --amount=0.1 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE $IPFSNODEID:ACK" -y)
log "__SUB:initkeys.sh: [ADMIN] NODE G1sms+ $UIDNA : ls ./wallets/.$IPFSNODEID"
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ NODE $UIDNA ($IPFSNODEID)" 1>&2
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODE_G1PUBKEY" 1>&2
# CREATE preoni FILES
mv ./authfile ./g1sms.preoni.priv.key
echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key
fi
##################################################################
# NODE KEYS (SCRIPT CALLED BY ROOT !!! gammu is root)
##################################################################
export IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
export NANODATE=$(date -u +%s%N) #1569692075385428020
NODE_UIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
## INIT NODE G1 PUB & PRIV KEY
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"
# CHECK LAST TIME NODE HAD ACTION
if [[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate ]]; then
last=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate)
##########################################################
# MEMORIZE NODE NANODATE EXECUTION TIME (for ntpdate regular sync)
if [[ -f ./wallets/.$IPFSNODEID/_nanodate ]]; then
last=$(cat ./wallets/.$IPFSNODEID/_nanodate)
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
# Get median nanodate before
# NODE TIME SYNC 120 milliards de nanosecondes = 120s
if [[ $timediff -gt 120000000000 ]]; then
# NODE TIME SYNC 600 milliards de nanosecondes = 600 s = 10 mn
if [[ $timediff -gt 600000000000 ]]; then
# RUN & LOG ntpdate
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
export NANODATE=$(date -u +%s%N)
fi
echo $NANODATE > ./wallets/.$IPFSNODEID/_nanodate
fi
#################################################################
# CREATE NODE .$IPFSNODEID SPACE (G1Wallet + TASK + NODE DETAILS)
#################################################################
# Create G1sms Wallet with that NODE G1 wallet as member reference
if [[ ! -f "./wallets/.$IPFSNODEID/$IPFSNODEID.pub" ]]; then
mkdir -p ./wallets/.$IPFSNODEID/TASK
# TODO @poka ?? Place in install sequence: Create Node G1 Wallet (login=ipfsID pass=ipfsPrivKey)
NODEG1WALLET=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS")
if [[ ! $NODEG1WALLET ]]; then echo "PROBLEME CREATION DU WALLET G1 DE $IPFSNODEID"; exit; fi
# Backup authfile GPG with IPFS NODE PRIVATE KEY
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
# Backup authfile CYPHER with NODE G1 WALLET PUB KEY
./shell/natools.py encrypt -p $NODEG1WALLET -i "./authfile" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.crypt"
# TODO ADD ACCESS TO OTHER SWARM NODES CYPHERING WITH ALL ACTUAL NODES G1WALLET PUB KEYS
# USEFUL TO OPERATE G1TAG WITHOUT SHARING NODE_G1PRIVKEYFILE...
# for nodepubfile in ./wallets_swarm/.Qm*/*.pub; do
# nodeG1pub=$(cat $nodepubfile)
# nodeID=$(echo $all | cut -d '/' -f 3)
# ./shell/natools.py encrypt -p $nodeG1pub -i "./authfile" -o "./wallets/.$IPFSNODEID/$nodeID.authfile.crypt"
# done
# Keep Node G1 wallet authfile in G1sms+ root
mv -f ./authfile ../
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsid"
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: pub = $NODEG1WALLET "
# BACKUP $IPFSNODEID config
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt"
log "__SUB:initkeys.sh: [ADMIN] BACKUP $IPFSNODEID NODE CONFIG to ./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt "
#######################
# GIVE NAME TO WALLET
#######################
# 4 derniers chiffres du numéro de téléphone
TAIL=${MASTERPHONE:8:4}
# No UIDNA yet. Create new
UIDNA=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets
while [[ $(grep -Rwl "$UIDNA$TAIL" ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
# WRITE NODE uidna NAME TO /etc/hosts & .Qm*/Qm*.uidna file
echo "127.0.0.101 $UIDNA$TAIL" >> "/etc/hosts"
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
# TODO: MAYBE REMOVE THAT CREATE NODE WALLET LIKE A PHONE (Stored in wallets/.$IPFSNODEID) BUT CREATE & ATTACH G1TAG INSTEAD
echo "${GPGPASS}" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
echo "" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
echo "314" > "./wallets/.$IPFSNODEID/$IPFSNODEID.g1cents"
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
# SILKAJ INIT G1 NODE WALLET
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1PRIVKEYFILE" --amount=3.24 --output=$NODEG1WALLET --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $UIDNA$TAIL $IPFSNODEID" -y)
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS" --amount=0.1 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE $IPFSNODEID:ACK" -y)
log "__SUB:initkeys.sh: [ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallet/.$IPFSNODEID"
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallets/.$IPFSNODEID" 1>&2
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODEG1WALLET" 1>&2
fi
echo $NANODATE > ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate
################################################################
#INFORM ABOUT NODE CAPACITIES
export NODEPUB=$(cat "./wallets/.$IPFSNODEID/$IPFSNODEID.pub")
export NODEPUB=$(cat "./wallets/.$IPFSNODEID/_pub")
## IS IT A SMS NODE (gammu-smsd is installed)??
if [[ $G1SMS ]]; then
echo $MASTERPHONE > "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"
echo $MASTERPHONE > "./wallets/.$IPFSNODEID/_sms"
else
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"; fi
if [ -f "./wallets/.$IPFSNODEID/_sms" ]; then rm -f "./wallets/.$IPFSNODEID/_sms"; fi
fi
## IS THERE USB PRINTER CONNECTED?
if [[ -e "/dev/usb/lp0" ]]; then
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
echo $ADRESSE > "./wallets/.$IPFSNODEID/$IPFSNODEID.where"
echo $ADRESSE > "./wallets/.$IPFSNODEID/_where"
fi
## IS THERE SERIAL QR CODE READER CONNECTED?
if [[ -e "/dev/ttyACM0" ]]; then
log "G1CORE: SCAN G1Tag ACTIF .............."
export G1TX="YES"
echo "/dev/ttyACM0" > "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"
echo "/dev/ttyACM0" > "./wallets/.$IPFSNODEID/_scan"
else
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"; fi
if [ -f "./wallets/.$IPFSNODEID/_scan" ]; then rm -f "./wallets/.$IPFSNODEID/_scan"; fi
fi

View File

@ -54,7 +54,7 @@ amount=$(bc <<< "$NBbillets * $VALbillet")
VIR=$(bc -l <<< "scale=2; $amount * $DUFACTOR / 100")
# Need at least $MIN G1 available! $BILLCOM G1 commission
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - 21")
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - $BILLCOM")
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
log "__SUB:sms_BILLET.sh: TEST : $VIR < $MIN ? $testmin"
@ -82,20 +82,17 @@ then
SECRET=$(./shell/diceware.sh 4 | xargs)
# ADD/REMOVE G1sms forced control over G1Billet
# SALT=$(./shell/diceware.sh 3 | xargs)
SALT=""
boucle=$(bc -l <<< "$boucle + 1")
log "__SUB:sms_BILLET.sh: ->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT"
# CREATE "NUMBER SECRET SALT" ACCOUNT for G1 transfert
# CREATE "NUMBER SECRET" ACCOUNT for G1 transfert
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET$SALT")
# COPY authfile for easier usage in 6 month...
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET")
# COPY authfile for Usage in 6 month...
log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.GPGPASS.gpg"
mkdir -p "./billets/$bpath"
echo "${GPGPASS}" | gpg -q --output "./billets/$bpath/note.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "./billets/$bpath/note.authfile.$NODE_UIDNA.crypt"
rm -f "./authfile"
log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY"
@ -110,7 +107,6 @@ then
echo "$NUMBER" > "./billets/$bpath/note.number"
echo "$PHONE" > "./billets/$bpath/note.phone"
echo "$SECRET" > "./billets/$bpath/note.secret"
echo "$SALT" > "./billets/$bpath/note.salt"
echo "$VALbillet" > "./billets/$bpath/note.love"
echo "$TRANSAC" > "./billets/$bpath/note.g1"
echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey"
@ -122,10 +118,10 @@ then
# Transaction to create Link BILLET <-> MEMBER RIB => Decrease BILLET value !
sleep 2
# PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NUMBER" -password="$SECRET $SALT" --amount="0.05" --output="$MEMRIB" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:BILLET:$VALbillet:$UNIT:$NUMBER" -y)
# PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NUMBER" -password="$SECRET" --amount="0.05" --output="$MEMRIB" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:BILLET:$VALbillet:$UNIT:$NUMBER" -y)
else
sms_ERROR "$PHONE" "Un problème est survenu. Contactez $ADMINPSEUDO au $ADMINPHONE"
# Copy & Send produiced files
# Copy & Send produced files
zip /tmp/$PHONE_Bills_$bpath.zip ./billets/MEMBERS/$MEMBER/*.*
mpack -s "[G1sms+]_G1Billets ($bpath) Erreur... création G1Billets..." -d /tmp/message_body.txt /tmp/$PHONE_Bills_$bpath.zip $MAIL && mv /tmp/$PHONE_Bills_$bpath.zip ./billets/MEMBERS/$MEMBER/ && log "__SUB:sms_BILLET.sh: ALERT sent....."
@ -151,9 +147,9 @@ then
Envoyez-nous vos remarques...
https://g1sms.fr" > /tmp/message_body.txt
mpack -s "[G1sms+]_G1Billets ($bpath) A IMPRIMER et détruire cet email..." -d /tmp/message_body.txt /tmp/$PHONE_Bills_$bpath.zip $MAIL && log "__SUB:sms_BILLET.sh: EMAIL sent....."
# rm -f /tmp/$PHONE_Bills_$bpath.zip
# mpack -s "[G1sms+]_G1Billets ($bpath) imprimer recto/verso vos G1Billets?!" -d /tmp/message_body.txt ./Dos_G1Billets.odt $MAIL && log "__SUB:sms_BILLET.sh: + EMAIL recto: OK"
log "__SUB:sms_BILLET.sh: G1Billets $PHONE_Bills_$bpath.pdf envoyé par email à $MEMBER : $MAIL "
mess="[G1SMS]
$NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) créé(s).

View File

@ -35,9 +35,11 @@ else
fi
# SEND EMAIL WITH ssmtp
SUBJECT="[G1sms+] $MEMBER, message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
MESSAGE="Bonjour $MEMBER\n\nVotre porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nPour commander vos G1Billets, envoyez par SMS à $MASTERPHONE :\nBILL 10/20/50/100/200/500/1000\n\n\nA bientot <3\n$ADMINPSEUDO - ($MASTERPHONE) Partenaire G1sms+"
SUBJECT="[G1sms+] $MEMBER, Message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
MESSAGE="Bonjour $MEMBER\n\nVotre porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nPour commander vos G1Billets, envoyez par SMS à $MASTERPHONE :\nBILL 10/20/50/100/200/500/1000\n\n\nA bientot <3\n$ADMINPSEUDO ($ADMINPHONE)"
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
mpack -s "[G1sms+] Exemple de verso pour vos G1Billets?!" ./Dos_G1Billets.odt ${mail}
log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp"
log_history $PHONE "EMAIL, $mail"

View File

@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2020
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
###########################################################################################
# == G1tag ==
@ -15,6 +15,7 @@
# TAG 250 => Imprime un G1Tag rempli de 250 UNIT
# TAG 2 100 => Imprime 100 G1Tag BON de 2 UNIT
# PHONE any ./wallets/IDs
# TODO: for multi-channel -> Use HASHLINK + UIDNA + NODE_UIDNA + AMOUNT ...
###########################################################################################
source ./shell/init.sh
source ./shell/functions.sh
@ -48,19 +49,12 @@ if [[ $UNKNOWN == "unknown" ]]; then
exit
fi
## NEEDED FOR Avatar + GeoPoint
#if [[ ! $PASSENGER && "$MEMBER" == "" ]]; then
# sms_ERROR "$PHONE" "Aucun membre associé à votre Portefeuille!? Envoyer N suivi de votre Pseudo membre pour activer la création de G1Tag..."
# log "__SUB:sms_G1TAG.sh: Aucun membre associé"
# exit
#fi
###########################################################
# CALCULATE if wallet have enough for VIR+PERCENT
AMOUNT=$2 # AMOUNT was changed by sms_INIT_ACCOUNT call !!
AMOUNT=$2 # BE CAREFULL AMOUNT was changed by 1st sms_INIT_ACCOUNT!!
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then
# MULTI TAG NUMBER ($NUMBER = How many tags to print (with different R but same B)
# MULTI TAG NUMBER ($NUMBER = How many tags to print)
AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER")
else
NUMBER=1
@ -73,7 +67,7 @@ VIR=${accounting[1]}
PERCENT=${accounting[2]}
CHARGE=${accounting[3]}
if [[ $testmin -eq 0 ]]; then
sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} G1! Rechargez avec https://cesium.app "
sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} + ${PERCENT} (+ ${LIMIT}) G1! Rechargez avec https://cesium.app"
exit
fi
@ -82,7 +76,7 @@ if [[ ! $PASSENGER && ! $G1DAB ]]; then
if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then
DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE)
if [[ "$DABnode" == "$IPFSNODEID" ]]; then
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag non détectée!! Choisissez un autre G1Dab... $spot"
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag sur $DABnode non détectée!! Choisissez un autre G1Dab..."
log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!"
exit
fi
@ -102,7 +96,7 @@ fi
ML=$(bc -l <<< "scale=2; $VIR + $PERCENT")
PAY=$(./shell/timeout.sh -t 29 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$ML" --output="$NODE_G1PUBKEY" --comment="[G1sms+] ACHAT $3 G1Tag(s) - $2 $UNIT" -y)
if [[ "$PAY" == "" || "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
new=$(./shell/checknodes.sh "BAN")
# new=$(./shell/checknodes.sh "BAN")
sms_ERROR "$PHONE" "Il est survenu un problème lors de votre virement: $PAY / Silkaj: $new";
exit
else
@ -119,8 +113,8 @@ while [[ $c -lt $NUMBER ]]; do
AA=$(./shell/diceware.sh 6 | xargs); # Nom = Diceware de 6 mots
RR=$(echo ${AA} | sed s/\ //g ); # Nom concaténé
PR=$(echo ${AA} | cut -d ' ' -f 1 ); # Prénom du G1Tag
# Create Unique G1tag!
while [[ $(ls "./wallets_swarm/.Qm*/TAG/${RR}") ]]; do
# Create Unique G1tag in all SWARM!
while [[ $(ls ./wallets_swarm/.Qm*/TAG/${RR}) ]]; do
AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g ); PR=$(echo ${AA} | cut -d ' ' -f 1 );
done
# Clef de chiffrage PGP imprimée sur le QRCode BJ
@ -130,27 +124,32 @@ while [[ $c -lt $NUMBER ]]; do
# G1Tag init : Nom et usage des fichiers du G1Tag
# TODO CHECK _nanodate to detect bad nodes/tx behaviour... and banish them)
TAGDATE="./TAG/${RR}/TAG_nanodate" # Nanodate notification (ntpdate in init.sh for NODE sync in case of
TAGNID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
TAGNODEID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
TAGID="./TAG/${RR}/TAG_id" #Nom du TAG
TAGN="./TAG/${RR}/TAG_n" # Tag modification number (0 first)
TAGCURRENCY="./TAG/${RR}/TAG_currency" # ZEN (0.01 G1)
TAGAMOUNT="./TAG/${RR}/TAG_amount" # Tag amount. It is!
TAGTYPE="./TAG/${RR}/TAG_type" # G1 Tag type
TAGPASSENGER="./TAG/${RR}/TAG_passenger" # Reference to G1Tag owner/counter put in "./wallets/.$IPFSNODEID/TAG/${J}"
# ... GESTION DE LA CLEF DE PUBLICATION IPNS ".ipfs/keystore/${RR}" ...
TAGBKEY="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B cyphered
TAGG1smsWKEY="./TAG/${RR}/TAG_publishkey.$PHONE.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
TAGSWARMKEY="./TAG/${RR}/TAG_publishkey.MASTER.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
TAGPUBLISH_B_GPG="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B cyphered
TAGPUBLISH_PHONE_CRYPT="./TAG/${RR}/TAG_publishkey.phone.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
TAGPUBLISH_NODE_CRYPT="./TAG/${RR}/TAG_publishkey.$NODE_UIDNA.crypt" # natools.py crypt with NODE G1sms Wallet PUBKEY
TAGPUBLISH_SWARM_CRYPT="./TAG/${RR}/TAG_publishkey.swarm.crypt" # natools.py crypt with SWARM G1sms Wallet PUBKEY
TAGN="./TAG/${RR}/TAG_n" # Tag modification number (0 first)
TAGIPNS="./TAG/${RR}/TAG_ipns" # /ipns/Qm... link to last G1Tag version
TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# WRITE MULTITAG FILES with AMOUNT
mkdir -p ./TAG/${RR}
LIST="$LIST $RR ($2)"
log "__SUB:sms_G1TAG.sh: G1tag: $RR / ${NANODATE}"
log "__SUB:sms_G1TAG.sh: G1Tag: $RR / ${NANODATE}"
log "__SUB:sms_G1TAG.sh: MEMRIB: $MEMRIB"
log "__SUB:sms_G1TAG.sh: A: ${AA}"
log "__SUB:sms_G1TAG.sh: B: ${BB}"
log "__SUB:sms_G1TAG.sh: USER_KEY: $TAGPUBLISH_B_GPG"
log "__SUB:sms_G1TAG.sh: PHONE G1WALLET_KEY: $TAGPUBLISH_PHONE_CRYPT"
log "__SUB:sms_G1TAG.sh: NODE G1WALLET_KEY: $TAGPUBLISH_NODE_CRYPT"
log "__SUB:sms_G1TAG.sh: SWARM G1WALLET_KEY: $TAGPUBLISH_SWARM_CRYPT"
####################
####################################################
@ -160,7 +159,7 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
echo "${AA}" > "$TAGID"
echo "0" > "$TAGN"
echo "${NANODATE}" > "$TAGDATE"
echo "${IPFSNODEID}" > "$TAGNID"
echo "${IPFSNODEID}" > "$TAGNODEID"
echo "${TYPE}" > "$TAGTYPE"
echo "ZEN" > "$TAGCURRENCY"
@ -175,12 +174,17 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# TODO: Regulate G1Tag Access to LostSecret OR PHONE ./wallets Pubkey OR SWARM G1 KEY
# GIVE QRCODE BJ ACCESS TO G1TAG
# Enregistrement de la clef de publication IPNS du wallet ${R} cryptée par B
echo "${BB}" | gpg -q --output "$TAGBKEY" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}"
# GIVE CREATOR G1WALLET ACCESS TO ZEN TAG
echo "${BB}" | gpg -q --output "$TAGPUBLISH_B_GPG" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}"
# GIVE PHONE CREATOR G1WALLET ACCESS TO ZEN TAG
# Enregistrement de la clef de publication chiffrée par $PUBKEY la clef publique du portefeuille G1 createur.
./shell/natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGG1smsWKEY"
./shell/natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_PHONE_CRYPT"
# GIVE NODE_UIDNA ACCESS TO ZEN TAG
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_NODE_CRYPT"
# GIVE SWARM ACCESS TO ZEN TAG
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGSWARMKEY"
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_SWARM_CRYPT"
###########################################################
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING
@ -197,8 +201,10 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# KEEP G1Tag J MEMORY in NODE ./wallets/.$IPFSNODEID/TAG/ (TODO: OPTIMIZE SWARM SYNC and REPUBLISH)
mkdir -p "./wallets/.$IPFSNODEID/TAG/"
# WRITE PASSENGER to J Link (G1Tag is stick to it: PHONE, NODE, FILE )
# TODO USE SHA256 ID !!!
echo "$PHONE" > "./wallets/.$IPFSNODEID/TAG/${J}"
if [[ $PASSENGER ]]; then
HPASSENGER=$(echo -n $PASSENGER | sha256sum | cut -d ' ' -f 1)
echo "$PASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
fi
@ -244,6 +250,7 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer TODO: Could use DESTNODEPUB instead of NODE_G1PUBKEY ?
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin "
mkdir -p "./wallets/.$destnode/PRINT/"
# TODO: USE $DEST_G1PUBKEY is better
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin"
fi
else
@ -257,8 +264,10 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
fi
done
####################################################
# PRINT $PHONE WALLET PUBKEY
####################################################
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
# PRINT $PHONE WALLET PUBKEY
qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)"
composite -compose Over -gravity West "/tmp/G1PubQR.$PHONE.png" "./shell/g1tag.png" "/tmp/G1PubQR.$PHONE.png"

View File

@ -33,7 +33,7 @@ testmin=${accounting[0]}
VIR=${accounting[1]}
PERCENT=${accounting[2]}
if [[ $testmin -eq 0 ]]; then
sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $VIR G1! Rechargez par Cesium."
sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $VIR + $LIMIT G1! Rechargez par Cesium."
exit
fi

View File

@ -15,7 +15,7 @@
# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n
# QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate
# QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.MASTER.crypt
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.swarm.crypt
# QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg
# TAG_passenger, TAG_file is used to attach G1Tag to file.
# ADD A PASSENGER FILE (Web2.0ID) INTO a G1Tag + Add INIT credit/debit values to live in SWARM.
@ -74,7 +74,7 @@ mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
echo "__SUB:tag_LOAD_passenger.sh: LOG. Hey You get a G1Tag!! GET IT now: ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
chown -R $YOU ./TAG/${JSOURCERR}/
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE" 2>&1
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.crypt"
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount)
TAGNODEID=$(cat ./TAG/${JSOURCERR}/TAG_nodeid)
TAGPASSENGER="./TAG/${JSOURCERR}/TAG_passenger" # contains HASH for PASSENGER FILE (CRYPT & PUBLISH)

View File

@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2020
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
###########################################################################################
# tag_OP.sh OPERATION ON G1TAG...
@ -15,7 +15,7 @@
# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n
# QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate
# QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.MASTER.crypt
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.swarm.crypt
# QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg
# ...
# TAG_passenger, TAG_file is used to attach G1Tag to file.
@ -52,7 +52,7 @@ echo "__SUB:tag_OP.sh: LOG. SOURCE G1Tag OK!! GREAT... Retrieving it all: ipfs g
mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
chown -R $YOU ./TAG/${JSOURCERR}/
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.crypt"
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount);
#############################################
@ -82,7 +82,7 @@ mkdir -p ./TAG/${JDESTRR}; rm -f ./TAG/${JDESTRR}/*
echo "__SUB:tag_OP.sh: LOG. Hey You get a G1Tag!! GREAT... ipfs get --output=./TAG/${JDESTRR}/ /ipns/$JDEST"
chown -R $YOU ./TAG/${JDESTRR}/
su $YOU -c "ipfs get --output=./TAG/${JDESTRR}/ /ipns/$JDEST"
JDESTPUBLISHKEY="./TAG/${JDESTRR}/TAG_publishkey.MASTER.crypt"
JDESTPUBLISHKEY="./TAG/${JDESTRR}/TAG_publishkey.swarm.crypt"
JDESTVALUE=$(cat ./TAG/${JDESTRR}/TAG_amount);
FINALDEST=$(echo "${JDESTVALUE} + ${VALUE}" | bc -l)
# EXTRACT $JSOURCERR PUBLISH KEY to "/home/$YOU/.ipfs/keystore/JSOURCE"

View File

@ -42,7 +42,7 @@ mkdir -p ./TAG/${JSOURCERR}; rm -f ./TAG/${JSOURCERR}/*
echo "__SUB:tag_PLAY_passenger.sh: FOUND G1Tag... GETTING IT: ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
chown -R $YOU ./TAG/${JSOURCERR}/
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE"
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.crypt"
TAGZEN=$(cat "./TAG/${JSOURCERR}/TAG_amount");
DEB=$(cat "./TAG/${JSOURCERR}/TAG_passenger_debit")

View File

@ -155,8 +155,8 @@ cat /dev/ttyACM0 | while read line; do
# Make Silkaj TX
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
log "__SUB:tag_READ.sh: Silkaj TX $NODE_G1PRIVKEYFILE ($G1VAL) -> $CASHBACK"
PAY=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1PRIVKEYFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] CAPTURE G1Tag $RR" -y)
log "__SUB:tag_READ.sh: Silkaj TX $SWARM_G1AUTHFILE ($G1VAL) -> $CASHBACK"
PAY=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] CAPTURE G1Tag $RR" -y)
log "__SUB:tag_READ.sh: Silkaj output = $PAY"
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
@ -221,7 +221,7 @@ cat /dev/ttyACM0 | while read line; do
else
log "__SUB:tag_READ.sh: Transfert de G1 Tag à G1 Tag. $BVALUE $CUR"
./shell/parle.sh "Transfert de ${val[1]} $CUR vers le G1 Tag ${FID}"
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[1]} ${obj[0]} ${val[1]} $NODE_G1PRIVKEYFILE)"
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[1]} ${obj[0]} ${val[1]} $SWARM_G1AUTHFILE)"
fi
CASHBACK=""
fi
@ -234,7 +234,7 @@ cat /dev/ttyACM0 | while read line; do
else
log "__SUB:tag_READ.sh: Transformation du G1 Tag en Rec Tag. ${val[0]} = ${val[1]}"
./shell/parle.sh "Transformation du G1 Tag ${val[0]} $CUR en Rec Tag chargé de ${FID}..."
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $NODE_G1PRIVKEYFILE)"
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $SWARM_G1AUTHFILE)"
fi
CASHBACK=""
fi

View File

@ -20,9 +20,9 @@ function log () {
$1" >> /tmp/tag_READ_X.log
}
NODE_G1PRIVKEYFILE="${MY_PATH}/../g1sms.priv.key"
if [ ! -f $NODE_G1PRIVKEYFILE ]; then echo "ERREUR CLEF DECHIFFRAGE!"; exit; fi
# TODO G1TAG: USE CREATOR NODE KEY FILE INSTEAD OF NODE_G1PRIVKEYFILE SWARM KEY
SWARM_G1AUTHFILE="${MY_PATH}/../g1sms.priv.key"
if [ ! -f $SWARM_G1AUTHFILE ]; then echo "ERREUR CLEF DECHIFFRAGE!"; exit; fi
# TODO G1TAG: USE CREATOR NODE KEY FILE INSTEAD OF SWARM_G1AUTHFILE SWARM KEY
# DOUCHETTE ES TU LA?
if [ ! $G1TX ]; then echo "Branchez votre lecteur de QR code!"; exit; fi
@ -177,8 +177,8 @@ cat /dev/ttyACM0 | while read line; do
# Make Silkaj TX
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
log "__SUB:tag_READ_X.sh: Silkaj TX $NODE_G1PRIVKEYFILE ($G1VAL) -> $CASHBACK"
PAY=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1PRIVKEYFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] G1Tag $RR ZEN -> G1" -y)
log "__SUB:tag_READ_X.sh: Silkaj TX $SWARM_G1AUTHFILE ($G1VAL) -> $CASHBACK"
PAY=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] G1Tag $RR ZEN -> G1" -y)
log "__SUB:tag_READ_X.sh: Silkaj output = $PAY"
# Stop 1LETTER.spinner.py
@ -251,8 +251,8 @@ cat /dev/ttyACM0 | while read line; do
COMBIENZEN=$(bc -l <<< "$COMBIEN * 100")
log "__SUB:tag_READ_X.sh: Transfert de G1 Tag à G1 Tag. $COMBIEN"
./shell/tools/4LETTER.scroll.py "G1TAG ${FID} -> TX $COMBIENZEN ZEN *** $COMBIEN G1"
log "__SUB:tag_READ_X.sh: ./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIENZEN $NODE_G1PRIVKEYFILE"
./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIENZEN "$NODE_G1PRIVKEYFILE"
log "__SUB:tag_READ_X.sh: ./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIENZEN $SWARM_G1AUTHFILE"
./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIENZEN "$SWARM_G1AUTHFILE"
else
./shell/tools/4LETTER.scroll.py "ERREUR $COMBIEN > VALEUR DE ${FID} *** ${val[1]} ZEN"
fi
@ -268,7 +268,7 @@ cat /dev/ttyACM0 | while read line; do
else
log "__SUB:tag_READ_X.sh: Transformation du G1 Tag en Rec Tag. ${val[0]} = ${val[1]}"
./shell/tools/4LETTER.scroll.py "TRASNFORMATION G1TAG ${val[0]} ZEN EN PASSENGER ${FID}";
log "__SUB:tag_READ_X.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $NODE_G1PRIVKEYFILE)"
log "__SUB:tag_READ_X.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $SWARM_G1AUTHFILE)"
fi
CASHBACK=""
fi

View File

@ -0,0 +1,332 @@
#!/bin/bash
###########################################################
# FORK of pishrink.sh
# SHRINK IMAGE OF YOUR RASPIAN PI SD CARD
#
# + TODO: THIS SCRIPT RESET IPFS / G1 Keys / SWARM config
# AND RUN CONFIG on FIRST IMG BOOT in /etc/rc.local
###########################################################
version="v0.1.3"
CURRENT_DIR=$(pwd)
SCRIPTNAME="${0##*/}"
LOGFILE=${CURRENT_DIR}/${SCRIPTNAME%.*}.log
function info() {
echo "$SCRIPTNAME: $1..."
}
function error() {
echo -n "$SCRIPTNAME: ERROR occured in line $1: "
shift
echo "$@"
}
function cleanup() {
if losetup "$loopback" &>/dev/null; then
losetup -d "$loopback"
fi
if [ "$debug" = true ]; then
local old_owner=$(stat -c %u:%g "$src")
chown "$old_owner" "$LOGFILE"
fi
}
function logVariables() {
if [ "$debug" = true ]; then
echo "Line $1" >> "$LOGFILE"
shift
local v var
for var in "$@"; do
eval "v=\$$var"
echo "$var: $v" >> "$LOGFILE"
done
fi
}
function checkFilesystem() {
info "Checking filesystem"
e2fsck -pf "$loopback"
(( $? < 4 )) && return
info "Filesystem error detected!"
info "Trying to recover corrupted filesystem"
e2fsck -y "$loopback"
(( $? < 4 )) && return
if [[ $repair == true ]]; then
info "Trying to recover corrupted filesystem - Phase 2"
e2fsck -fy -b 32768 "$loopback"
(( $? < 4 )) && return
fi
error $LINENO "Filesystem recoveries failed. Giving up..."
exit -9
}
help() {
local help
read -r -d '' help << EOM
Usage: $0 [-sdrzh] imagefile.img [newimagefile.img]
-s: Don't expand filesystem when image is booted the first time
-d: Write debug messages in a debug log file
-r: Use advanced filesystem repair option if the normal one fails
-z: Gzip compress image after shrinking
EOM
echo "$help"
exit -1
}
usage() {
echo "Usage: $0 [-sdrpzh] imagefile.img [newimagefile.img]"
echo ""
echo " -s: Skip autoexpand"
echo " -d: Debug mode on"
echo " -r: Use advanced repair options"
echo " -z: Gzip compress image after shrinking"
echo " -h: display help text"
exit -1
}
should_skip_autoexpand=false
debug=false
repair=false
gzip_compress=false
while getopts ":sdrzh" opt; do
case "${opt}" in
s) should_skip_autoexpand=true ;;
d) debug=true;;
r) repair=true;;
z) gzip_compress=true;;
h) help;;
*) usage ;;
esac
done
shift $((OPTIND-1))
if [ "$debug" = true ]; then
info "Creating log file $LOGFILE"
rm "$LOGFILE" &>/dev/null
exec 1> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&1)
exec 2> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&2)
fi
echo "${0##*/} $version"
#Args
src="$1"
img="$1"
#Usage checks
if [[ -z "$img" ]]; then
usage
fi
if [[ ! -f "$img" ]]; then
error $LINENO "$img is not a file..."
exit -2
fi
if (( EUID != 0 )); then
error $LINENO "You need to be running as root."
exit -3
fi
#Check that what we need is installed
for command in parted losetup tune2fs md5sum e2fsck resize2fs; do
command -v $command >/dev/null 2>&1
if (( $? != 0 )); then
error $LINENO "$command is not installed."
exit -4
fi
done
#Copy to new file if requested
if [ -n "$2" ]; then
info "Copying $1 to $2..."
cp --reflink=auto --sparse=always "$1" "$2"
if (( $? != 0 )); then
error $LINENO "Could not copy file..."
exit -5
fi
old_owner=$(stat -c %u:%g "$1")
chown "$old_owner" "$2"
img="$2"
fi
# cleanup at script exit
trap cleanup ERR EXIT
#Gather info
info "Gatherin data"
beforesize=$(ls -lh "$img" | cut -d ' ' -f 5)
parted_output=$(parted -ms "$img" unit B print | tail -n 1)
partnum=$(echo "$parted_output" | cut -d ':' -f 1)
partstart=$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')
loopback=$(losetup -f --show -o "$partstart" "$img")
tune2fs_output=$(tune2fs -l "$loopback")
currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)
blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)
logVariables $LINENO tune2fs_output currentsize blocksize
#Check if we should make pi expand rootfs on next boot
if [ "$should_skip_autoexpand" = false ]; then
#Make pi expand rootfs on next boot
mountdir=$(mktemp -d)
mount "$loopback" "$mountdir"
if [ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "0542054e9ff2d2e0507ea1ffe7d4fc87" ]; then
echo "Creating new /etc/rc.local"
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
#####Do not touch the following lines#####
cat <<\EOF1 > "$mountdir/etc/rc.local"
#!/bin/bash
do_expand_rootfs() {
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
PART_NUM=${ROOT_PART#mmcblk0p}
if [ "$PART_NUM" = "$ROOT_PART" ]; then
echo "$ROOT_PART is not an SD card. Don't know how to expand"
return 0
fi
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
[ "$PART_START" ] || return 1
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START
p
w
EOF
cat <<EOF > /etc/rc.local &&
#!/bin/sh
echo "Expanding /dev/$ROOT_PART"
resize2fs /dev/$ROOT_PART
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
EOF
reboot
exit
}
raspi_config_expand() {
/usr/bin/env raspi-config --expand-rootfs
if [[ $? != 0 ]]; then
return -1
else
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
reboot
exit
fi
}
raspi_config_expand
echo "WARNING: Using backup expand..."
sleep 5
do_expand_rootfs
echo "ERROR: Expanding failed..."
sleep 5
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
exit 0
EOF1
#####End no touch zone#####
chmod +x "$mountdir/etc/rc.local"
fi
umount "$mountdir"
else
echo "Skipping autoexpanding process..."
fi
#Make sure filesystem is ok
checkFilesystem
if ! minsize=$(resize2fs -P "$loopback"); then
rc=$?
error $LINENO "resize2fs failed with rc $rc"
exit -10
fi
minsize=$(cut -d ':' -f 2 <<< "$minsize" | tr -d ' ')
logVariables $LINENO minsize
if [[ $currentsize -eq $minsize ]]; then
error $LINENO "Image already shrunk to smallest size"
exit -11
fi
#Add some free space to the end of the filesystem
extra_space=$(($currentsize - $minsize))
logVariables $LINENO extra_space
for space in 5000 1000 100; do
if [[ $extra_space -gt $space ]]; then
minsize=$(($minsize + $space))
break
fi
done
logVariables $LINENO minsize
#Shrink filesystem
info "Shrinking filesystem"
resize2fs -p "$loopback" $minsize
if [[ $? != 0 ]]; then
error $LINENO "resize2fs failed"
mount "$loopback" "$mountdir"
mv "$mountdir/etc/rc.local.bak" "$mountdir/etc/rc.local"
umount "$mountdir"
losetup -d "$loopback"
exit -12
fi
sleep 1
#Shrink partition
partnewsize=$(($minsize * $blocksize))
newpartend=$(($partstart + $partnewsize))
logVariables $LINENO partnewsize newpartend
if ! parted -s -a minimal "$img" rm "$partnum"; then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -13
fi
if ! parted -s "$img" unit B mkpart primary "$partstart" "$newpartend"; then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -14
fi
#Truncate the file
info "Shrinking image"
if ! endresult=$(parted -ms "$img" unit B print free); then
rc=$?
error $LINENO "parted failed with rc $rc"
exit -15
fi
endresult=$(tail -1 <<< "$endresult" | cut -d ':' -f 2 | tr -d 'B')
logVariables $LINENO endresult
if ! truncate -s "$endresult" "$img"; then
rc=$?
error $LINENO "trunate failed with rc $rc"
exit -16
fi
if [[ $gzip_compress == true ]]; then
info "Gzipping the shrunk image"
if [[ ! $(gzip -f9 "$img") ]]; then
img=$img.gz
fi
fi
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
logVariables $LINENO aftersize
info "Shrunk $img from $beforesize to $aftersize"

View File

@ -2,4 +2,4 @@ SILKAJ_VERSION = "silkaj 0.5.0"
NO_MATCHING_ID = "No matching identity"
G1_SYMBOL = "Ğ1"
GTEST_SYMBOL = "ĞTest"
G1_DEFAULT_ENDPOINT = "duniter-g1.p2p.legal", "443"
G1_DEFAULT_ENDPOINT = "duniter.moul.re", "443"