diff --git a/_chain b/_chain index 953407d..08f5b4c 100755 --- a/_chain +++ b/_chain @@ -1 +1 @@ -QmbRvGMpwZws4ii5xe5x8EgK1SSxNBaNNjinwdWjhye3TR +QmaN3w2NGxejb8yNN1sP4fvnfDV3YDghStcjbyLr7zchCC diff --git a/_comments b/_comments index 7842c23..8d6d3ca 100755 --- a/_comments +++ b/_comments @@ -175,3 +175,4 @@ OK 2019-12-17: Better G1Tx 2019-12-17: G1TAG REFRESH & more 2019-12-18: RAZ +2019-12-20: NOW diff --git a/_nanodate b/_nanodate index 7778f6d..1a8bd2e 100755 --- a/_nanodate +++ b/_nanodate @@ -1 +1 @@ -1576627244479575204 +1576803110070568420 diff --git a/_publishkey.gpg b/_publishkey.gpg index 619e3dc..69ba96a 100755 Binary files a/_publishkey.gpg and b/_publishkey.gpg differ diff --git a/shell/cron_MINUTE.sh b/shell/cron_MINUTE.sh index 483b68f..688c3cb 100755 --- a/shell/cron_MINUTE.sh +++ b/shell/cron_MINUTE.sh @@ -8,73 +8,89 @@ # IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME ################################################################################ YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) +if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi +if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi IPFSNODEID=$(su $YOU -c "ipfs id -f='\n'") CHEMIN="/home/$YOU/G1sms+" cd $CHEMIN + source ./shell/init.sh source ./shell/functions.sh -timebar=$(date +%H%M) - -if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system. sudo -s ?"; exit; fi -if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi - +timebar=$(date +%H:%M) ################################################################## -# Refresh All peers SWARM Wallets. +if [[ "$1" == "" ]]; then ################################################################## -ipfs_swarm_wallets_refresh "SIMPLE" - -################################################################################ -# PRINT G1Tag PRINTED FROM ANOTHER NODE -# CREATE and REMOVE rr.bin -> done.rr -if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then - log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID" - mkdir -p ./wallets/.$IPFSNODEID/PRINT/ - - for qrrtag in ./wallets_swarm/.$IPFSNODEID/PRINT/*.bin; do - rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1) - if [[ ! -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" ]]; then - log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)" - ./shell/natools.py decrypt -k "$MASTERKEYFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png" - log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)" - brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin" - log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)" - brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0 - log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)" - # INFORM PRINT DONE - echo "OK" > ./wallets/.$IPFSNODEID/PRINT/done.$rr - I=$(ipfs_node_wallets_add) - else - lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g ) - log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ./wallets/.$IPFSNODEID/PRINT/done.$rr" - rm -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" - rm -f "${lqrrtag}" - I=$(ipfs_node_wallets_add) - fi - done - - log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE" - for scan in ./wallets_swarm/.Qm*/PRINT/done.*; do - lscan=$(echo $scan | sed s/_swarm//g ) - lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 ) - lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 ) - log "__SUB:cron_MINUTE.sh: REMOVE ./wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)" - rm -f ./wallets/.$lid/PRINT/$lrr.bin - rm -f "${lscan}" - I=$(ipfs_node_wallets_add) - done - - rm "/tmp/G1Tag.bin" - rm "/tmp/G1Tag.png" -fi - - - -################################################################## -if [[ "$timebar" == "0300" ]]; then -################################################################## - echo "It is 3 in the morning, or in the night? It depends on your day..." + echo "It is $timebar in the morning, or in the night? It depends on your day..." + exit fi ################################################################## + +################################################################## +if [[ "$1" == "PRINT" ]]; then +################################################################## + ################################################################## + # Refresh All peers SWARM Wallets. + ################################################################## + ipfs_swarm_wallets_refresh "SIMPLE" + + ################################################################################ + # PRINT G1Tag PRINTED FROM ANOTHER NODE + # CREATE and REMOVE rr.bin -> done.rr + if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then + log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID" + mkdir -p ./wallets/.$IPFSNODEID/PRINT/ + + for qrrtag in ./wallets_swarm/.$IPFSNODEID/PRINT/*.bin; do + rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1) + if [[ ! -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" ]]; then + log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)" + ./shell/natools.py decrypt -k "$MASTERKEYFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png" + log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)" + brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin" + log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)" + brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0 + log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)" + # INFORM PRINT DONE + echo "OK" > ./wallets/.$IPFSNODEID/PRINT/done.$rr + I=$(ipfs_node_wallets_add) + else + lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g ) + log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ./wallets/.$IPFSNODEID/PRINT/done.$rr" + rm -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" + rm -f "${lqrrtag}" + I=$(ipfs_node_wallets_add) + fi + done + + log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE" + for scan in ./wallets_swarm/.Qm*/PRINT/done.*; do + lscan=$(echo $scan | sed s/_swarm//g ) + lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 ) + lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 ) + log "__SUB:cron_MINUTE.sh: REMOVE ./wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)" + rm -f ./wallets/.$lid/PRINT/$lrr.bin + rm -f "${lscan}" + I=$(ipfs_node_wallets_add) + done + + rm "/tmp/G1Tag.bin" + rm "/tmp/G1Tag.png" + fi +fi +################################################################## + +################################################################## +if [[ "$1" == "KALKUN" ]]; then +################################################################## + for number in ./wallets/*; do + member="" + phone=$(echo $number | cut -d '/' -f 3); + if [[ -f $number/$phone.uidname ]]; then member=$(cat $number/$phone.uidname); fi + if [[ ! $member ]]; then member=$phone; fi + if [[ $phone && $member ]]; then add_contact $phone $member; log "__SUB:cron_MINUTE.sh: KALKUN add_contact $phone $member"; fi + done +fi +################################################################## diff --git a/shell/manual_BILLETS_PERIMES.sh b/shell/manual_BILLETS_PERIMES.sh index 8b202c0..79d4e21 100755 --- a/shell/manual_BILLETS_PERIMES.sh +++ b/shell/manual_BILLETS_PERIMES.sh @@ -36,14 +36,20 @@ for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do echo $secret $salt echo "/usr/local/bin/silkaj tx --amount=\"$virement\" --output=\"$dest\"" - PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" -y) - - if [[ ! $(echo $PAY | grep "successfully sent") ]]; then - echo "!!!! ERREUR: $virement Something Wrong happened with $result" - if [[ ! $virement ]]; then mv $result /tmp/$result; fi + if [[ "$virement" == "0.0" ]]; then + echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result; else - echo "Tout s'est bien passé! On supprime $result et continue avec le billet $Nbillets" - rm -Rf $result + PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" -y) + if [[ ! $(echo $PAY | grep "successfully sent") ]]; then + echo "!!!! ERREUR: $virement Something Wrong happened with $result. Moving to /tmp/$billetname" + mkdir -p /tmp/$billetname + mv $result /tmp/$billetname + else + echo $PAY + echo "OK! On supprime $result et continue avec le billet $Nbillets" + echo + rm -Rf $result + fi fi else echo "MEMBER:" $result diff --git a/shell/sms_AIDE.sh b/shell/sms_AIDE.sh index 404691d..36ca4de 100755 --- a/shell/sms_AIDE.sh +++ b/shell/sms_AIDE.sh @@ -11,21 +11,20 @@ log "X sms_AIDE.sh ($1=phone)" sms_INIT_ACCOUNT "$1" "NOSMS" MESS="[Aide] -N Id-M (Relier au portefeuille Id-M) -U G1/DU/LOVE (UNIT) -S (Solde) -P 06nnnnnnnn 300 (Envoyer 300 UNIT à 06nnnnnnnn)" +N Pseudo (membre ou nom de portefeuille) : Création portefeuille +U G1/DU/LOVE : Unité +S : Solde +P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn" # Send response SMS sms_SEND "$1" "$MESS" -MESS="EMAIL moi@email.tld (Recevoir vos commandes par email) -TAG 10 5 (Créer 5 G1Tag de 10 G1) -VIR 50 Idw (Virer 50 UNIT vers Idw)" +MESS="EMAIL moi@email.tld : Commander G1billets +VIR 50 Pseudo : Virer 50 à Pseudo (membre ou portefeuille)" sms_SEND "$1" "$MESS" -MESS="REC (Pour un payement récurrent) -D (Détail de votre compte) -A votre service. +MESS="REC 50 Dest S 4: Virer 50 à Dest pendant 4 Semaines (J/S/M/A) +RAZ : clôturer compte (vidé vers Pseudo) +OU Dab3241 : Imprimante ses G1Tag sur Dab3241 $ADMINPSEUDO / G1sms+ / $ADMINPHONE https://g1sms.fr" sms_SEND "$1" "$MESS" diff --git a/shell/sms_REC.sh b/shell/sms_REC.sh index 7ec15d1..dab19b3 100755 --- a/shell/sms_REC.sh +++ b/shell/sms_REC.sh @@ -79,20 +79,22 @@ else log "__SUB:sms_REC.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB " DESTMEM="$VIRDEST" # SEARCH IN WALLETS - LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/') + LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/') + if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi if [[ "$LOCAL" != "" ]]; then # LOCAL G1sms account DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub) DESTPHONE=$LOCAL log "__SUB:sms_REC.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)" else - # SEARCH IN WALLETS SWARM - SWARMNB=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/') - if [[ "$LOCAL" != "" ]]; then - REMOTENODE=$(cat ./wallets_swarm/$SWARMNB/MASTERPHONE.sms) - DESTRIB=$(cat ./wallets_swarm/$SWARMNB/$SWARMNB.pub) - DESTPHONE=$SWARMNB - log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($SWARMNB)" + # SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA) + INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/') + if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi + if [[ "$INSWARM" != "" ]]; then + REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms) + DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub) + DESTPHONE=$INSWARM + log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)" else # SEARCH WITH SILKAJ DESTRIB=$(./silkaj/silkaj id "$DESTMEM" | grep -w "$DESTMEM" | awk '{print $2}') diff --git a/shell/sms_VIR.sh b/shell/sms_VIR.sh index ea97204..1f78b73 100755 --- a/shell/sms_VIR.sh +++ b/shell/sms_VIR.sh @@ -48,15 +48,17 @@ else log "__SUB:sms_VIR.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB " DESTMEM="$VIRDEST" # SEARCH IN WALLETS - LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/') + LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/') + if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi if [[ "$LOCAL" != "" ]]; then # LOCAL G1sms account DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub) DESTPHONE=$LOCAL log "__SUB:sms_VIR.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)" else - # SEARCH IN WALLETS SWARM - INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/') + # SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA) + INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/') + if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi if [[ "$INSWARM" != "" ]]; then REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms) DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub)