Compare commits

..

56 Commits

Author SHA1 Message Date
poka f314b9dea3 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/g1sms into dev-multicanal 2020-03-12 15:35:48 +01:00
poka 41629cc938 Remove old Hubot scripts (move to bbot engine) 2020-02-24 02:59:15 +01:00
poka 8be9b7ea3a Security fix 2020-02-24 02:07:45 +01:00
poka 6225b2e5cd Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/g1sms into dev-multicanal 2020-02-23 19:27:29 +01:00
poka 1da87b7002 Fix axiom adhérent in bbot scripts and improve shell 2020-02-23 19:26:19 +01:00
poka ef332a91a3 Maj multicanal 2020-01-18 17:11:48 +01:00
qo-op bf94b41551 SWARM & NODE_G1PUBKEY 2020-01-04 01:04:10 +01:00
poka c82d96394f Fix spam bot 2020-01-02 23:53:25 +01:00
poka b62c8f3853 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/g1sms into dev-multicanal 2020-01-02 01:19:59 +01:00
poka 360c86a771 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2020-01-02 00:14:59 +01:00
poka 3dcf311314 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2020-01-02 00:09:06 +01:00
poka 737f3e2adf Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2020-01-02 00:09:06 +01:00
poka 1fa0e9e017 typ log 2020-01-01 07:54:24 +01:00
poka 2436c862d1 typ log 2020-01-01 07:54:24 +01:00
poka 1194927282 typ log 2020-01-01 07:54:24 +01:00
poka 05c9269ec9 Install: Add rc.local config for GSM_powerkey 2020-01-01 07:40:38 +01:00
poka c8cc511cd3 Install: Add rc.local config for GSM_powerkey 2020-01-01 07:40:38 +01:00
poka 3468ca60e5 Install: Add rc.local config for GSM_powerkey 2020-01-01 07:40:38 +01:00
poka e879dc674e MULTICANAL : FRED : Work in Progress ... 2020-01-01 07:11:38 +01:00
poka 3e226ac676 MULTICANAL : FRED : Work in Progress ... 2020-01-01 07:11:38 +01:00
poka face5133ec MULTICANAL : FRED : Work in Progress ... 2020-01-01 07:11:38 +01:00
poka 38c31c77da Add help de install.sh. Add node_modules path link to 6-install-bbot 2020-01-01 07:10:10 +01:00
poka 206e10582b Add help de install.sh. Add node_modules path link to 6-install-bbot 2020-01-01 07:10:10 +01:00
poka 5d4ac829fe Add help de install.sh. Add node_modules path link to 6-install-bbot 2020-01-01 07:10:10 +01:00
poka 2d7e063685 clean bb_scripts 2020-01-01 07:08:48 +01:00
poka c36c294780 clean bb_scripts 2020-01-01 07:08:48 +01:00
poka 8c790dac9d clean bb_scripts 2020-01-01 07:08:48 +01:00
poka 2b7a63fe2f Improve logging 2020-01-01 07:08:01 +01:00
poka cbfa5c4e4b Improve logging 2020-01-01 07:08:01 +01:00
poka 06cec4b5ed Improve logging 2020-01-01 07:08:01 +01:00
poka f711b47601 GLOBAL BIG CHANGE 2019-12-30 08:33:45 +01:00
poka b80db3cb16 GLOBAL BIG CHANGE 2019-12-30 08:33:45 +01:00
poka 6d261b509b GLOBAL BIG CHANGE 2019-12-30 08:33:45 +01:00
poka 65745ca1fd Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2019-12-30 07:31:07 +01:00
poka 24e4127896 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2019-12-30 07:31:07 +01:00
poka 9a77889738 Merge branch 'dev-multicanal' of https://git.p2p.legal/axiom-team/G1sms into dev-multicanal 2019-12-30 07:31:07 +01:00
qo-op 07865137a7 Restore work for multicanal 2019-12-30 07:26:48 +01:00
qo-op 6e5dfd9e06 Restore work for multicanal 2019-12-30 07:26:48 +01:00
qo-op f18e070d5d Restore work for multicanal 2019-12-30 07:26:48 +01:00
qo-op be099b6f3e Restore work for multicanal 2019-12-29 15:17:57 +01:00
qo-op ccbbb3ae3d Restore work for multicanal 2019-12-29 15:17:57 +01:00
qo-op 22fb57d984 Restore work for multicanal 2019-12-29 15:17:57 +01:00
qo-op 1d2d814999 prepare multicanal 2019-12-29 15:08:27 +01:00
qo-op 80510f259b prepare multicanal 2019-12-29 15:08:27 +01:00
qo-op b26f42b6dd SHA256 PHONE compatibility & SWARMKEY GPG CYPHER 2019-12-26 17:44:26 +01:00
qo-op f67286a1fb SHA256 PHONE compatibility & SWARMKEY GPG CYPHER 2019-12-26 17:44:26 +01:00
qo-op 1bb3c99930 G1Billets +++ HAppy Noel ;p 2019-12-24 17:07:14 +01:00
qo-op 6b3a2f1456 G1Billets +++ HAppy Noel ;p 2019-12-24 17:07:14 +01:00
qo-op e9fc812ac2 New G1Billets compatible (break 1st 2018 Christmas version) 2019-12-24 05:55:47 +01:00
qo-op 1bd4dd2518 New G1Billets compatible (break 1st 2018 Christmas version) 2019-12-24 05:55:47 +01:00
qo-op d68ce6cb6a G1Billets + Aide ° https://g1sms.fr 2019-12-24 05:47:47 +01:00
qo-op df4679d38c G1Billets + Aide ° https://g1sms.fr 2019-12-24 05:47:47 +01:00
qo-op 07cd3d8ead G1Billets + G1Tag cosmetics and shaping 2019-12-22 09:43:33 +01:00
qo-op 90a26f5932 G1Billets and some more 2019-12-21 22:58:36 +01:00
qo-op 168ed8b8ea + correct GPATH in int_keys.sh & Merge remote-tracking branch 'origin/dev-poka' into dev-fred 2019-12-21 03:21:38 +01:00
poka a1be1b53c3 Fix debug/GSM_powerkey.sh do not stop key if is started. Replace by . Add .install/templates/2b/gammu-smsdrc 2019-12-20 19:59:01 +01:00
94 changed files with 1287 additions and 1105 deletions

4
.gitignore vendored
View File

@ -1,8 +1,6 @@
authfile authfile
g1sms.bfproject g1sms.bfproject
g1sms.priv.key g1sms.priv.key
g1sms.preoni.priv.key
g1sms.preoni.pub.key
shell/init.sh shell/init.sh
shell/bad.nodes.txt shell/bad.nodes.txt
shell/good.nodes.txt shell/good.nodes.txt
@ -17,3 +15,5 @@ history.*
.install/log .install/log
.install/.OS .install/.OS
.profile .profile
deps/g1bot/
mesms/

View File

@ -2,9 +2,8 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile || echo -e "${c_red}Le .profile n'existe pas$c_" && exit 1
OS=$(head -n1 $MY_PATH/.OS)
isARM=$(cat $MY_PATH/.OS | grep YES)
unset err unset err
# Basics # Basics
@ -26,7 +25,7 @@ silkaj() {
ipfs() { ipfs() {
echo -e "${c_yellow}Installation d'IPFS...$c_" echo -e "${c_yellow}Installation d'IPFS...$c_"
[[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop [[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop
if [[ $isARM ]]; then if [[ $ARM == "yes" ]]; then
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update" wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"
else else
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update" wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -O $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"

View File

@ -2,10 +2,9 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/../.install/.GPATH
## Récupère les données du profile ## Récupère les données du profile
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile [[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile || echo -e "${c_red}Le .profile n'existe pas$c_" && exit 1
## Désactive les processus écoutant le tty1 ## Désactive les processus écoutant le tty1
[[ $(sudo systemctl status getty@tty1.service | grep "loaded" 2>/dev/null) ]] && sudo systemctl stop getty@tty1.service && sudo systemctl disable getty@tty1.service [[ $(sudo systemctl status getty@tty1.service | grep "loaded" 2>/dev/null) ]] && sudo systemctl stop getty@tty1.service && sudo systemctl disable getty@tty1.service
@ -31,6 +30,12 @@ fi
## Configure rc.local ## Configure rc.local
if [[ ! -f /etc/rc.local ]]; then
sudo cp $MY_PATH/template/rc.local /etc/
else
[[ ! $(grep "exit 0" /etc/rc.local) ]] && echo "exit 0" | tee -a /etc/rc.local
fi
sudo sed -i "/exit 0/i $GPATH/debug/GSM_powerkey.sh\ngammu-smsd-inject TEXT \"0647683646\" -text \"G1sms Plus démarré.\"" /etc/rc.local
exit 0 exit 0

View File

@ -2,9 +2,9 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
templates="$MY_PATH/templates/3" source $MY_PATH/../.profile
isARM=$(cat $MY_PATH/.OS | grep YES) templates="$MY_PATH/templates/3"
################################## ##################################
## INSTALL TOOLS ## INSTALL TOOLS
@ -27,7 +27,7 @@ sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid
wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb
if [[ $isARM ]]; then if [[ $ARM == "yes" ]]; then
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico0.deb wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico0.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb
else else

View File

@ -3,13 +3,12 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile [[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile || echo -e "${c_red}Le .profile n'existe pas$c_" && exit 1
unset err unset err
args=$@ args=$@
[[ $args =~ noask ]] && noask=o && askSSL=o [[ $args =~ noask ]] && noask=o && askSSL=o
OS=$(head -n1 $MY_PATH/.OS)
IP=$(ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{ print $2 }') IP=$(ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{ print $2 }')
if [[ -z $KSMS_DOMAIN ]]; then if [[ -z $KSMS_DOMAIN ]]; then
echo -e "${c_yellow}Choisissez un nom de domaine pour KALKUN (Sinon $IP sera choisi): $c_" && read KSMS_DOMAIN echo -e "${c_yellow}Choisissez un nom de domaine pour KALKUN (Sinon $IP sera choisi): $c_" && read KSMS_DOMAIN

View File

@ -54,7 +54,7 @@ sudo /usr/local/bin/playsmsd start
if [[ -f /etc/rc.local ]]; then if [[ -f /etc/rc.local ]]; then
[[ ! $(grep playsmsd /etc/rc.local) ]] && sudo sed -i '/^exit 0.*/i /usr/local/bin/playsmsd start' /etc/rc.local [[ ! $(grep playsmsd /etc/rc.local) ]] && sudo sed -i '/^exit 0.*/i /usr/local/bin/playsmsd start' /etc/rc.local
else else
echo "/usr/local/bin/playsmsd start" | sudo tee /etc/rc.local echo "/usr/local/bin/playsmsd start" | sudo tee -a /etc/rc.local
fi fi
## Tests ## Tests

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/../.install/.GPATH [[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile || echo -e "${c_red}Le .profile n'existe pas$c_" && exit 1
GPATHS=$(echo $GPATH | sed 's./.\\/.g') GPATHS=$(echo $GPATH | sed 's./.\\/.g')

33
.install/6-install-bbot.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile || echo -e "${c_red}Le .profile n'existe pas$c_" && exit 1
## Install node 13 via NVM
if [[ -z $(which node) ]]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
nvm install 13
nvm use 13
fi
## install pm2 for deamoning
[[ -z $(which pm2) ]] && npm install pm2 -g
## Install g1bot
[[ ! -d $GPATH/deps ]] && mkdir $GPATH/deps
cd $GPATH/deps/
[[ -d g1bot ]] && echo "g1bot est déjà installé" && exit 1
git clone https://git.p2p.legal/axiom-team/g1bot.git g1bot && cd g1bot || exit 1
npm install
cp .env.example .env
echo "Now edit url and password in .env in 3 seconds ..." && sleep 3
nano .env
export NODE_PATH=$GPATH/deps/g1bot/node_modules:$NODE_PATH
[[ -z $(grep "NODE_PATH=" ~/.bashrc) ]] && echo "export NODE_PATH=$GPATH/deps/g1bot/node_modules:$NODE_PATH" >> ~/.bashrc
pm2 kill && sleep 1
pm2 start bbot.js && echo "${c_green}BBOT a été correctement installé et a pu démarrer$c_" || echo "$c{c_gree,}BBOT n'a pas pu démarrer$c_"
exit 0

View File

@ -1,6 +1,15 @@
### PROFILE ###
ADMINPSEUDO=_ADMINPSEUDO ADMINPSEUDO=_ADMINPSEUDO
ADMINPHONE=_ADMINPHONE ADMINPHONE=_ADMINPHONE
MASTERPHONE=_MASTERPHONE MASTERPHONE=_MASTERPHONE
ADRESSE="_ADRESSE" ADRESSE="_ADRESSE"
PIN=_PIN PIN=_PIN
KSMS_DOMAIN= KSMS_DOMAIN=
### SYSTEME ###
GPATH=_GPATH
OS=_OS
ARM=_ARM

View File

@ -4,7 +4,7 @@ After=network.target
[Service] [Service]
User=_USER User=_USER
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient --enable-gc ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
Restart=on-failure Restart=on-failure
[Install] [Install]

View File

@ -1,7 +1,7 @@
# Configuration file for Gammu SMS Daemon # Configuration file for Gammu SMS Daemon
[gammu] [gammu]
port = /dev/ttyAMA0 port = /dev/ttyS0
synchronizetime = yes synchronizetime = yes
gammucoding = utf8 gammucoding = utf8
connection = at connection = at

View File

@ -3,7 +3,7 @@
if(php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) exit("Access Denied."); if(php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) exit("Access Denied.");
// Please configure this // Please configure this
$url = "http://_DOMAIN"; $url = "https://g1sms-blois-2.p2p.legal";
fclose(fopen($url."/index.php/daemon/message_routine/", "r")); fclose(fopen($url."/index.php/daemon/message_routine/", "r"));

View File

@ -2,7 +2,7 @@ server {
listen 80; listen 80;
listen 443; listen 443;
listen [::]:443 ssl; listen [::]:443 ssl;
server_name _DOMAIN; server_name _DOMAIN 127.0.0.1 localhost;
#add_header Content-Security-Policy upgrade-insecure-requests; #add_header Content-Security-Policy upgrade-insecure-requests;
#if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } #if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; }

View File

@ -7,19 +7,25 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi if [[ -f $MY_PATH/.profile ]]; then
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
source /home/pi/.bash_aliases
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS # Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
function log () { function log () {
# log ($1=text) # log ($1=text)
if [ "$DOLOG" == "YES" ] if [ "$DOLOG" == "YES" ]
then then
echo "$PHONE:$1" >> /tmp/g1sms.log echo -e "$PHONE: $1" >> $logfile
fi fi
} }
################################################################################################################################### ###################################################################################################################################
fn_exists() { fn_exists() {
# appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything # appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything
@ -29,13 +35,12 @@ fn_exists() {
if ! fn_exists gammu-smsd-inject; then if ! fn_exists gammu-smsd-inject; then
log ":p) DESACTIVATION ENVOI DE SMS .............." log ":p) DESACTIVATION ENVOI DE SMS .............."
function gammu-smsd-inject () { function gammu-smsd-inject () {
log "$PHONE: >>> SENDING SMS $4 TO $2 " log "$PHONE: >>> SENDING SMS $4 TO $2 "
} }
else else
export G1SMS="YES" export G1SMS="YES"
fi fi
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
cd $GPATH cd $GPATH
################################################################## ##################################################################

View File

@ -0,0 +1,20 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
exit 0

0
Dos_G1Billets.odt Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

View File

@ -2,7 +2,14 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/../.install/.GPATH if [[ -f $MY_PATH/.profile ]]; then
source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
# Clean /tmp/ytdl.list # Clean /tmp/ytdl.list
#echo > /tmp/ytdl.list #echo > /tmp/ytdl.list

1
_chain Executable file
View File

@ -0,0 +1 @@
QmWEyZDyn7XMM3pDFCBkDqC6XPAraTSLHbVD3h7geunNWy

View File

@ -178,10 +178,6 @@ OK
2019-12-20: NOW 2019-12-20: NOW
2019-12-21: Various 2019-12-21: Various
2019-12-24: 2019-12-24:
2020-01-02: Noel merge code 2019-12-26: SWARMKEY
2020-01-02: g1sms.preoni 2019-12-26: ipfs p2p listen /x/$YOU /ip4/127.0.0.1/tcp/80
2020-01-04: BACKUP 2019-12-26: ./wallets/sha256sum(PHONE)
2020-01-06: bugs
2020-01-06: silkaj TX init bad keys
2020-01-07:
2020-01-07: g1.presles.fr

1
_nanodate Executable file
View File

@ -0,0 +1 @@
1577378596986046001

Binary file not shown.

View File

@ -0,0 +1 @@
biz-bot-admin

19
bb_scripts/aide.js Normal file
View File

@ -0,0 +1,19 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('util')
bot.global.text({
contains: ['biz aide','biz help']
}, (b) => {
membres = exec("src/shell/aide.sh text", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'biz-aide'
});

50
bb_scripts/axiom.js Normal file
View File

@ -0,0 +1,50 @@
const bot = require('bbot');
const exec = require('child_process').exec;
//ADMINS
//var adminRooms = exec("cat admins-chan.txt"); //cat admins-chan.txt");
bot.global.text({
contains: ['axiom adhérent','axiom adhérents','axiom adherent','axiom adherents']
}, (b) => {
// cmd = b.message.text
if (b.message.user.room.type == "p") {
roomName = b.message.user.room.name
} else {
roomName = b.message.user.name
}
// if (adminRooms.indexOf(roomName) == -1) {
if (['biz-bot-admin', 'poka', 'brad.pi', '_pole_financements', '_axiom_business_plan', 'compta-axiom', 'communication', '_recrutement'].includes(roomName)) {
cmd = "adherents"
process.env.hb_cmd = cmd
} else {
b.respond("Réservé aux administrateurs de l'association.")
}
pubkey = exec("src/shell/helloasso.sh $hb_cmd", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'axiom-adherents'
});
bot.global.text({
contains: ['axiom cagnotte']
}, (b) => {
membres = exec("src/shell/helloasso.sh cagnotte", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'axiom-cagnotte'
});

17
bb_scripts/debug.js Normal file
View File

@ -0,0 +1,17 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const util = require('util');
bot.global.text({
contains: ['debug user']
}, (b) => {
username = b.message
// const userId = res.message.user.id
// username = robot.adapter.api.get('users.info', { userId })
// process.env.hb_username = username
b.reply("```" + util.inspect(username, {showHidden: false, depth: null}) + "```")
}, {
id: 'debug'
});

View File

@ -0,0 +1,201 @@
const bot = require('bbot')
/**
* All branch examples start from the "global" conversation scope.
* We are working on features to provide branching within a conversational
* context, but as those methods are changing in the beta, they aren't included
* as examples to follow just yet.
*/
/**
* Branch types are declared from their scope, see all available types here:
* http://bbot.chat/docs/path#builtforbranching
*
* `text` branches take the following arguments:
* - matcher: expression, semantic conditions object, or array of conditions
* - callback: to fire on successful match, given the state object (b)
* - [options]: object with `id` (string) and/or `force` (boolean) attributes
*
* Test with "Hello bots!"
*/
bot.global.text(/(hi|hello).*bots?/, (b) => b.respond('Hello :wave:'), {
id: 'hello-bots'
})
/**
* `direct` branch type requires the bot to be explicitly addressed.
*
* `reply` instead of `respond` prepends messages with user's name.
*
* In Rocket.Chat all messages to a bot in a direct room have the name prepended
* by the Rocket.Chat SDK before it's processed by the bot framework.
*
* Test with "@brocket Hello" or just "Hello" in a DM.
*/
bot.global.direct(/hi|hello/i, (b) => b.reply('Hey there.'), {
id: 'hello-direct'
})
/**
* `respondVia` allows using custom platform methods to dispatch response.
*
* Matcher conditions allow semantic attributes with a string or array of
* optional values to match against, possibly capturing content.
* Accepted atts: is, starts, ends, contains, excludes, after, before, range
*
* Test with "Hello anyone?"
*/
bot.global.text({
contains: ['hi', 'hello']
}, (b) => b.respondVia('react', ':wave:'), {
id: 'hello-react'
})
/**
* Branch callbacks allow asynchronous responding, if they return a promise.
* State (b) includes branch matching attributes, see bbot.chat/docs/thought.
*
* Test with "@brocket ping back in 5 seconds"
*/
bot.global.direct(/ping back in (\d*)/i, async (b) => {
const ms = parseInt(b.match[1]) * 1000
await new Promise((resolve) => setTimeout(resolve, ms))
return b.respond('Ping :ping_pong:')
}, {
id: 'ping-delay'
})
/**
* The `respond` method can accept attachment objects as well as strings.
* Rendering support depends on the message platform and adapter. In shell,
* it will display the fallback text.
*
* Test with "bot attach image"
*/
bot.global.text(/attach image/i, (b) => {
return b.respond({
fallback: `See: https://www.wikiwand.com/en/Three_Laws_of_Robotics`,
image: `https://upload.wikimedia.org/wikipedia/en/8/8e/I_Robot_-_Runaround.jpg`,
title: {
text: `Asimov's Three Laws of Robotics`,
link: `https://www.wikiwand.com/en/Three_Laws_of_Robotics`
}
})
}, { id: 'attach-image' })
/**
* The `envelope` provides helpers for adding rich-message payloads before
* responding. Preparing envelopes before dispatch also allows changing the
* user/room the envelope is addressed to or dispatching multiple envelopes.
*
* Test with "I want a prize"
*/
bot.global.text({
contains: 'prize'
}, (b) => {
b.envelope.write('Choose your fate! 🚪... 🎁 ')
b.envelope.attach({ color: '#f4426e' })
b.envelope.payload
.quickReply({ text: 'Door number 1' })
.quickReply({ text: 'Door number 2' })
.quickReply({ text: 'Door number 3' })
return b.respond().catch((err) => console.error(err))
}, { id: 'door-prize-intro' })
/**
* The `conditions` attribute contains results of semantic condition matching
* and capture groups. Each condition can be given a key for easy reference.
*
* Test with "what's behind door number 2"
*/
bot.global.text({
door: { after: 'door', range: '1-3' }
}, (b) => {
switch (b.conditions.captured.door) {
case '1': return b.respond(`You win nothing 💔`)
case '2': return b.respond(`You win a monkey 🐒`)
case '3': return b.respond(`It's a new car!! 🚗`)
}
}, { id: 'door-prize-award' })
/**
* Branch callbacks can be async functions, to awaiting one or more processes
* before responding. This example uses API requests to fill a dynamic array
* of actions, using the url property to provide link action buttons.
*
* Test with "@brocket plan meeting" in a public or private room.
*/
bot.global.direct({
is: 'plan meeting'
}, async (b) => {
if (bot.adapters.message.name !== 'rocketchat-message-adapter') return
b.envelope.write('Please review time zones in the room...')
const { id, type } = b.message.user.room
let room
const q = { roomId: id }
if (type === 'c') {
room = await bot.adapters.message.api.get('channels.members', q, true)
} else if (type === 'p') {
room = await bot.adapters.message.api.get('groups.members', q, true)
} else {
return b.respond('Sorry, that only works in channels and private groups.')
}
const offsets = room.members
.map((member) => member.utcOffset || undefined)
.filter((offset) => !!offset)
for (let utc of offsets) {
b.envelope.payload.quickReply({
text: `🌐 UTC ${utc}`,
url: `https://www.timeanddate.com/worldclock/timezone/utc${utc}`
})
}
b.respond()
})
/**
* @todo This example requires PR #11811 to be merged. Room names are undefined.
*/
bot.global.text(/where am i/i, (b) => {
const { name, type } = b.message.user.room
switch (type) {
case 'c': return b.respond(`You're in the #${name} public channel.`)
case 'p': return b.respond(`You're in a private group called **${name}**.`)
case 'l': return b.respond(`You're in a livechat channel.`)
case 'd': return b.respond(`You're in a DM with me :hugging:`)
}
}, {
id: 'location-check'
})
/**
* Custom options can be added to the bot, with the full config utility of bBot,
* allowing them to be defined as environment variables, command line args or
* package.json attributes. Extend settings with a yargs option format.
*
* Try any of the following:
* - `node index.js --avatar <YOUR_AVATAR_URL>`
* - BOT_AVATAR=<YOUR_AVATAR_URL> in .env
* - `{ "bot": { "avatar": "<YOUR_AVATAR_URL>" } }` in package.json
*/
bot.settings.extend({
avatar: {
'type': 'string',
'description': 'Set a custom avatar for your bot account profile'
}
})
/**
* The bot can access lower level methods of the Rocket.Chat SDK through the
* message adapter, once it's connected. This example sets an avatar on login.
*
* Try replacing the avatar configured in package.json with your own.
*/
bot.events.on('started', () => {
if (bot.adapters.message.name !== 'rocketchat-message-adapter') return
if (bot.settings.get('avatar')) {
bot.logger.info('Setting bot avatar')
bot.adapters.message.api.post('users.setAvatar', {
avatarUrl: bot.settings.get('avatar')
})
}
})

View File

@ -0,0 +1,33 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('util')
bot.global.text({ contains: [''] }, (b) => b.respond(""), {
id: 'id-tpl'
})
// --------
bot.global.text({ contains: [''] }, (b) => {
b.respond("")
}, {
id: 'id-tpl-2'
});
// --------
bot.global.text({
contains: ['']
}, (b) => {
membres = exec("src/shell/.sh", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'id-tpl-3'
});

View File

@ -0,0 +1,57 @@
const bot = require('bbot');
const request = require('request');
const decodeEntities = require('decode-entities');
//var decode = require('unescape');
var request_options = {
headers: {
'User-Agent': 'crabot retrieving url metadata (https://wiki.crapaud-fou.org/crabot)'
}
};
bot.global.text(/(https?:\/\/[^ ,\)"\n]*)/ig, async (b) => {
// console.log(JSON.stringify(b.match, null, 2));
for (url of b.match) {
// console.log(JSON.stringify(url, null, 2));
if (!/(coa|pad)\.crapaud-fou\.org/.test(url)) {
request_options.url = url;
request(request_options, (err, res, body) => {
// console.log(JSON.stringify(res, null, 2));
if (!err && res.statusCode === 200) {
var re = /<title[^>]*>([^<]*)<\/title>/gi;
var match = re.exec(body);
if (match && match[1]) {
var extra = "";
var link = res.request.uri.href;
link = link.replace(/[\?&]fbclid=.+/gi, "");
link = link.replace(/[\?&]ncid=.+/gi, "");
//kopa match[1] = match[1].replace("&#039;", "'");
if (/youtube.com/.test(link)) {
if (t = /[?&]v=([^&]+)/.exec(link)) {
link = "https://www.youtube.com/watch?v=" + t[1];
extra += " - [no-cookie](https://www.youtube-nocookie.com/embed/" + t[1] + ")";
extra += " - [invidious](https://invidio.us/watch?v=" + t[1] + ")";
}
}
b.respond(decodeEntities("[>>>](" + link + ") _" + match[1].replace(/\n/g, " ").trim() + "_" + extra));
// b.respond("\>\>\>\> _" + match[1].replace(/\n/g, " ").trim() + "_" + extra);
}
} else {
console.log('-----------------------------------');
console.log('URL: ' + url);
console.log('ERR - - - - - - - - - - - - - - - -');
console.log(JSON.stringify(err, null, 2));
console.log('RES - - - - - - - - - - - - - - - -');
console.log(JSON.stringify(res, null, 2));
console.log('-----------------------------------');
}
});
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}, {
id: 'get-url-metadata'
});

35
bb_scripts/g1-info.js Normal file
View File

@ -0,0 +1,35 @@
const bot = require('bbot');
const exec = require('child_process').exec;
bot.global.text({
starts: ['pubkey','rib','brocket rib', 'brocket pubkey']
}, (b) => {
username = b.message.user.name
cmd = b.message.text
process.env.hb_username = username
process.env.hb_cmd = cmd
pubkey = exec("src/shell/g1-infos.sh pubkey $hb_username \"$hb_cmd\"", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'g1-pubkey'
});
bot.global.text({
contains: ['membres g1','g1 membre','g1 membres']
}, (b) => {
membres = exec("src/shell/g1-infos.sh membres", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'g1-membres'
});

20
bb_scripts/g1sms.js Normal file
View File

@ -0,0 +1,20 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('util')
bot.global.text({
contains: ['TEST BSMS']
}, async (b) => {
await b.respond("Test de G1SMS ...")
const username = b.message.user.id
membres = exec("g1sms/test.sh chat", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'sms-test'
});

11
bb_scripts/inc/aide.txt Normal file
View File

@ -0,0 +1,11 @@
*Voici ce que je sais faire ...*
```
- biz aide: Affiche cette aide
- biz liens: Donne des liens utiles
- index pads: Donne le lien vers l'index de nos pads
- membres: Affiche le nombre de membres actuelles de la Ğ1
- pubkey [pseudo]: Affiche sa propre clé publique Ğ1 si [pseudo] n'est pas renseigné, ou bien celle du pseudo indiqué
- axiom adhérents: Affiche les adhérents de l'association
- axiom cagnotte: Affiche le status de la cagnotte de l'association
```

6
bb_scripts/inc/liens.txt Normal file
View File

@ -0,0 +1,6 @@
index pad !! https://pad.p2p.legal/axiom_index-pads
Site officiel de l'association Axiom-Team !! https://axiom-team.fr/
Forum de l'asso axiom-team !! https://forum.axiom-team.fr/
Cloud publique axiom - Ressources Agora !! https://cloud.p2p.legal/s/DDbKi2pqdEmixS9
Cloud interne axiom _(Nécessite un accès)_ !! https://cloud.p2p.legal/f/204193`

View File

@ -0,0 +1,9 @@
5 personnes membres vous connaissent-elles bien ? Peuvent-elles vous contacter ? Contacter votre entourage ? Avez-vous sauvegardé votre document de révocation ? Avez-vous installé un client local sur votre ordinateur/smartphone comme Cesium ?
Si oui -> vous connaissez certainement ces personnes vous aussi, et pouvez leur demander.
Si non -> il va vous falloir créer des liens avec des membres, conformément à la **[licence](https://duniter.org/fr/wiki/licence-g1/)** que vous devez lire, comprendre et accepter.
Je vous invite également à lire le **[guide du débutant](https://forum.monnaie-libre.fr/t/00-intro-guide-du-debutant-en-monnaie-libre-g1-june/2777)**, et surtout à vous renseigner sur les rencontres de présentation de la monnaie libre autour de chez vous, pour créer des relations humaines réelles.
Bienvenue, et bonnes découvertes !

View File

@ -0,0 +1,6 @@
OBSCURANTISTE!
MENTEUR!
Toute mlc ne sert qu'à nuire à leveil de conscience sur la création monétaire.
Avez vous déjà vérifié les arguments (fallacieux) servis par les rabatteurs de mlc?
Les mlc coutent un bras au profit des banques et de quelques « chiens de garde» de leur salaire en unl qui en découle (rabatteurs).
La plus grosse mlc de lhistoire jai analysé: La mlc argentine en 2001. Elle a permis lemergence de Monsanto compagny en 2002. Nhésitez pas à vérifier.

23
bb_scripts/jokes.js Normal file
View File

@ -0,0 +1,23 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
bot.global.text({ contains: ['vtfn','si tes pas content','si t\'es pas content'] }, (b) => b.respond(":arrow_right: https://vatefairecuireunnem.com/"), {
id: 'joke-vtfn'
})
bot.global.text({ contains: ['biz présente toi'] }, (b) => b.respond(":arrow_right: https://matiou.biz"), {
id: 'joke-presente'
})
// L'infernal matiou sur les MLC ...
let bizbi = fs.readFileSync('./src/inc/repliques-mlc.txt', 'utf8');
bizbi = bizbi.split('\n')
function randomize(toRand) {
resultRand = toRand[Math.floor(Math.random()*toRand.length)]
return resultRand;
}
bot.global.text({ contains: ['mlc'] }, (b) => b.respond(randomize(bizbi)), {
id: 'joke-presente'
})

21
bb_scripts/liens.js Normal file
View File

@ -0,0 +1,21 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('util')
bot.global.text({
contains: ['biz lien','biz liens']
}, (b) => {
cmd = b.message.text
process.env.hb_cmd = cmd
membres = exec("src/shell/liens.sh $hb_cmd", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue ...")
} else {
b.respond(stdout)
}
});
}, {
id: 'biz-liens'
});

23
bb_scripts/reactions.js Normal file
View File

@ -0,0 +1,23 @@
const bot = require('bbot');
const globe_delay = 60000; // 1 minute
var globe_said = {};
bot.global.text({
contains: ['facebook', 'google', 'amazon', 'apple', 'microsoft', 'youtube']
}, (b) => {
b.respondVia('react', ':hear_no_evil:');
}, {
id: 'gafam-react'
});
bot.global.text(
/pe?tit? globe/i
, (b) => {
if (!globe_said[b.message.user.room] || new Date().getTime() > globe_said[b.message.user.room] + globe_delay) {
b.respond('![pti globe](https://crapaud-fou.org/images/chat-ptiglobe.png)');
globe_said[b.message.user.room] = new Date().getTime();
}
}, {
id: 'ptiglobe-direct'
})

22
bb_scripts/reload.js Normal file
View File

@ -0,0 +1,22 @@
const bot = require('bbot');
const exec = require('child_process').exec;
bot.global.text({
is: ['biz reload']
}, (b) => {
function reload() {
pubkey = exec("pm2 reload bbot --force", function(err, stdout, stderr) {
if (err) {
b.respond("Une erreur est survenue: " + " - " + stderr)
} else {
b.respond("Biz a été rechargé")
}
});
};
b.respond("Biz redémarre ... OK dans 5 secondes")
setTimeout(reload, 10);
}, {
id: 'reload-scripts'
});

12
bb_scripts/repondeur.js Normal file
View File

@ -0,0 +1,12 @@
const bot = require('bbot');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('util')
bot.global.text({ contains: ['me certifier','me faire certifier','je cherche une certification','je cherche des certifications'] }, (b) => {
// Lisez la licence Ḡ1 ...
let newml = fs.readFileSync('./src/inc/need-certif.txt', 'utf8');
b.respond("Bonjour, et bienvenue @" + b.message.user.name + " ! =)" + newml)
}, {
id: 'rep-certif'
});

21
bb_scripts/shell/aide.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
auto() {
echo "*Je suis l'aide auto*"
cd src
#cmds=$(grep "^bot\." *.js -A3 | grep -E "\['|aide = ")
cmds=$(grep "\['" *.js | awk -F "[" '{ print $2 }' | awk -F "]" '{ print $1 }')
IFS=$'\n'
for i in $cmds; do
echo "$i" | awk -F "'" '{ print $2 }'
done
}
text() {
cat src/inc/aide.txt
}
$@
exit 0

28
bb_scripts/shell/g1-infos.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
node="https://duniter-g1.p2p.legal"
pubkey() {
url="$node/wot/members"
if [[ "$@" =~ "brocket" ]]; then
[[ $4 ]] && username=$4 || username=$1
else
[[ $3 ]] && username=$3 || username=$1
fi
username=$(echo $username | tr -d '@')
local pubkey=$(curl -m 5 -s $url | grep -w -i -B 1 $username | grep "pubkey" | awk -F '"' '{ print $4 }')
# TODO: local pubkey=$(curl -m 5 -s $url | jq -r --arg username "$username" '.results[] | select(.uid=="$username") | .pubkey')
[[ $pubkey ]] && echo "@$username Ta clé publique Ğ1 est: $pubkey" || echo "@$username n'est pas pseudo membre de la Ḡ1"
}
membres() {
url="$node/blockchain/current"
local nbr_membres=$(curl -m 5 -s $url | jq '.membersCount')
[[ $nbr_membres ]] && echo "Il y a actuellement $nbr_membres membres de la Ğ1 !" || echo "Service en maintenance, réessayez dans un instant :coffee:"
}
$@
exit 0

42
bb_scripts/shell/helloasso.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
source ~/.adm/helloasso/ids
ha="https://api.helloasso.com/v3"
adherents() {
url="$ha/campaigns/000001053192/actions.json?type"
list=$(curl -m 5 --user $ids -s $url | jq -r '.resources[] | .date + " , " + .first_name + " " + .last_name + " - " + .email' | sed 's/T.*,//')
echo "$list" | awk '!seen[$3]++'
nbrAdherents=$(echo "$list" | awk '!seen[$3]++' | wc -l)
echo "---"
echo -e "\n Il y a actuellement **$nbrAdherents adhérents** de l'association Axiom-Team."
}
adherentsSoft() {
url="$ha/campaigns/000001053192/actions.json?type"
curl -m 5 --user $ids -s $url | jq -r '.resources[] | .date + " , " + .first_name + " " + .last_name' | sed 's/T.*,//'
}
cagnotte() {
url="$ha/campaigns/000001053192.json"
list=$(curl -m 5 --user $ids -s $url | jq -r '.name, {"Donnateurs": .supporters},{"Fonds":.funding},.url' | tr -d '{|}')
# list=$(curl -m 5 --user $ids -s $url | jq -r '{"Donnateurs": .supporters},{"Fonds":.funding},.url' | tr -d '{|}')
name=$(echo "$list" | head -n1)
url=$(echo "$list" | tail -n1)
donnateurs=$(echo "$list" | grep "Donnateurs" | awk '{ print $2 }')
fonds=$(echo "$list" | grep "Fonds" | awk '{ print $2 }')
echo "Il y a **${fonds}€** pour **$donnateurs donnateurs** sur la cagnotte **\"$name\"**"
}
$@
exit 0

12
bb_scripts/shell/liens.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
if [[ -z $3 ]]; then
res=$(sed 's/!!/:arrow_right:/g' src/inc/liens.txt)
else
shift 2
res=$(sed 's/!!/:arrow_right:/g' src/inc/liens.txt | grep -i "$@")
fi
[[ $res ]] && echo "$res" || echo "Aucun lien trouvé avec **$@**"
exit 0

View File

@ -1,11 +0,0 @@
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
while True:
GPIO.output(7, GPIO.LOW)
time.sleep(4)
GPIO.output(7, GPIO.HIGH)
break
GPIO.cleanup()

View File

@ -9,6 +9,8 @@ if [ ! -e /sys/class/gpio/gpio4 ]; then
fi fi
echo "out" > /sys/class/gpio/gpio4/direction echo "out" > /sys/class/gpio/gpio4/direction
echo "0" > /sys/class/gpio/gpio4/value
sleep 3
echo "1" > /sys/class/gpio/gpio4/value echo "1" > /sys/class/gpio/gpio4/value
sleep 3 && $MY_PATH/gammu-restart.sh sleep 3 && $MY_PATH/gammu-restart.sh

View File

@ -7,8 +7,6 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
echo "GPATH=$MY_PATH" > $MY_PATH/.install/.GPATH
source $MY_PATH/.install/.GPATH
init_loc="$MY_PATH/shell/init.sh" init_loc="$MY_PATH/shell/init.sh"
now=$(date +%Y-%m-%d) now=$(date +%Y-%m-%d)
@ -17,19 +15,36 @@ unset err
## Récupère les données du profile ## Récupère les données du profile
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile [[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
help() {
clear
echo -e "${c_light}Bienvenue à bord de Ḡ1Bot !$c_
Laissez vous guider par cet installeur, ou bien renseignez lui en argument:
- all : Répond oui à tous sans poser de questions
- noptions : Ne propose d'installer aucune options, juste le minimum
- force : Met à jour les dépendances
- noask : Ne demande pas de confirmations aux questions
Si vous souhaitez installer un composant précis, vous pouvez executer directement les scripts présents dans le dossier \".install/\"
"
exit 0
}
## Récupère les arguments ## Récupère les arguments
args="$@" args="$@"
[[ $args =~ all ]] && repOption=o [[ $args =~ all ]] && repOption=o
[[ $args =~ noptions ]] && repOption=n [[ $args =~ noptions ]] && repOption=n
[[ $args =~ force ]] && force_req=o [[ $args =~ force ]] && force_req=o
[[ $args =~ noask ]] && noask=o [[ $args =~ noask ]] && noask=o
[[ $args =~ ^(help|-h|--help|aide)$ ]] && help
## Vérifie le type de système ## Vérifie le type de système
[[ $(uname -a | grep arm) ]] && isARM=YES || unset isARM [[ $(uname -a | grep arm) ]] && ARM=yes || unset isARM
if [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then OS=stretch; if [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then OS=stretch;
elif [[ $(grep buster /etc/os-release) ]]; then OS=buster; elif [[ $(grep buster /etc/os-release) ]]; then OS=buster;
else echo "${c_red}Votre OS n'est pas supporté$c_"; exit 1; fi else echo "${c_red}Votre OS n'est pas supporté$c_"; exit 1; fi
echo -e "$OS\n$isARM" > .install/.OS sed -i 's/_OS/$OS/g' $MY_PATH/.profile
sed -i 's/_ARM/$ARM/g' $MY_PATH/.profile
sed -i 's/_GPATH/$MY_PATH/g' $MY_PATH/.profile
unset err unset err
@ -79,18 +94,21 @@ if [[ -f $MY_PATH/.install/templates/init.sh ]]; then
[[ -f shell/init.sh ]] && mv shell/init.sh shell/init.sh.old [[ -f shell/init.sh ]] && mv shell/init.sh shell/init.sh.old
cp $MY_PATH/.install/templates/init.sh shell/init.sh || err+=1 cp $MY_PATH/.install/templates/init.sh shell/init.sh || err+=1
sed -i s/_MASTERPHONE/$MASTERPHONE/g $init_loc sed -i "s/_MASTERPHONE/$MASTERPHONE/g" $init_loc
sed -i s/_ADRESSE/$ADRESSE/g $init_loc sed -i "s/_ADRESSE/$ADRESSE/g" $init_loc
sed -i s/_ADMINPHONE/$ADMINPHONE/g $init_loc sed -i "s/_ADMINPHONE/$ADMINPHONE/g" $init_loc
sed -i s/_ADMINPSEUDO/$ADMINPSEUDO/g $init_loc sed -i "s/_ADMINPSEUDO/$ADMINPSEUDO/g" $init_loc
if [[ ! -f $MY_PATH/.profile ]]; then if [[ ! -f $MY_PATH/.profile ]]; then
cp $MY_PATH/.install/templates/.profile $MY_PATH/ cp $MY_PATH/.install/templates/.profile $MY_PATH/
sed -i s/_MASTERPHONE/$MASTERPHONE/g $MY_PATH/.profile sed -i "s/_MASTERPHONE/$MASTERPHONE/g" $MY_PATH/.profile
sed -i s/_ADRESSE/$ADRESSE/g $MY_PATH/.profile sed -i "s/_ADRESSE/$ADRESSE/g" $MY_PATH/.profile
sed -i s/_ADMINPHONE/$ADMINPHONE/g $MY_PATH/.profile sed -i "s/_ADMINPHONE/$ADMINPHONE/g" $MY_PATH/.profile
sed -i s/_ADMINPSEUDO/$ADMINPSEUDO/g $MY_PATH/.profile sed -i "s/_ADMINPSEUDO/$ADMINPSEUDO/g" $MY_PATH/.profile
sed -i s/_PIN/$PIN/g $MY_PATH/.profile sed -i "s/_PIN/$PIN/g" $MY_PATH/.profile
sed -i "s/_OS/$OS/g" $MY_PATH/.profile
sed -i "s/_ARM/$ARM/g" $MY_PATH/.profile
sed -i "s/_GPATH/$MY_PATH/g" $MY_PATH/.profile
fi fi
else else
@ -111,6 +129,8 @@ if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/3-insta
if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then isKalkun=1; $MY_PATH/.install/4a-install_kalkun.sh || err+=1; fi; repOption=$repOld if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then isKalkun=1; $MY_PATH/.install/4a-install_kalkun.sh || err+=1; fi; repOption=$repOld
[[ -z $repOption && -z $isKalkun ]] && echo -e "${c_yellow}Voulez-vous installer l'interface web playSMS ? (o/n)$c_" && read repOption [[ -z $repOption && -z $isKalkun ]] && echo -e "${c_yellow}Voulez-vous installer l'interface web playSMS ? (o/n)$c_" && read repOption
if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/4b-install_playsms.sh || err+=1; fi; repOption=$repOld if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/4b-install_playsms.sh || err+=1; fi; repOption=$repOld
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer BBOT ? (o/n)$c_" && read repOption
if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/6-install-bbot.sh || err+=1; fi; repOption=$repOld
if [[ $err ]]; then if [[ $err ]]; then
echo -e "---\n${c_red}L'installation générale n'est mal déroulé =($c_" echo -e "---\n${c_red}L'installation générale n'est mal déroulé =($c_"

0
shell/G1Anar.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

0
shell/G1Billet_LOVE.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

0
shell/Oeuro.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

0
shell/OneLove.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 253 KiB

0
shell/TAG_fond.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

0
shell/TAG_fond_G1Tx.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -3,10 +3,10 @@
# Author: Fred (support@qo-op.com) # Author: Fred (support@qo-op.com)
# Version: 0.1 # Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# BACKUP G1sms+ current Devlt code and push it with SWARM_CODE_MASTER to IPFS # BACKUP G1sms+ current Devlt code and push it with NODE_G1AUTHFILE encryption to IPFS
################################################################################ ################################################################################
source ./init.sh source ./shell/init.sh
source ./functions.sh source ./shell/functions.sh
now=$(date +%Y-%m-%d) now=$(date +%Y-%m-%d)
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
@ -37,11 +37,10 @@ cd ..
# with iterative update _chain, _nanodate, _zen, _g1cents values # with iterative update _chain, _nanodate, _zen, _g1cents values
# + _external UID references & _comments lines # + _external UID references & _comments lines
########################################################################################### ###########################################################################################
echo "PLEASE WAIT...." echo "PLEASE WAIT.... INITIALIZING G1 Object ipfs chain files:"
echo "GIT" > "./$dir/_type" echo "GIT" > "./$dir/_type"
hop=$(cat "./$dir/_chain") hop=$(cat "./$dir/_chain")
LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1); LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1); curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq '.dividend' > "./$dir/_DU";
[[ $LASTDU != "" ]] && curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq '.dividend' > "./$dir/_DU" || LASTDU=$(cat ./$dir/_DU)
echo "Valeur courante du DU=$(cat ./$dir/_DU) ZEN - CHAIN: $hop" echo "Valeur courante du DU=$(cat ./$dir/_DU) ZEN - CHAIN: $hop"
read read
@ -54,7 +53,7 @@ echo $(date +%s%N) > "./$dir/_nanodate"
echo "$now: $COMMENT" >> "./$dir/_comments" echo "$now: $COMMENT" >> "./$dir/_comments"
# TAR G1sms+ FILES (WITH EXCLUSIONS!!) # TAR G1sms+ FILES (WITH EXCLUSIONS!!)
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 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
mkdir -p /tmp/CODE/ && tar xzf ~/G1sms+_backup_$now.tar.gz -C /tmp/CODE/ && rm -f ~/G1sms+_backup_$now.tar.gz mkdir -p /tmp/CODE/ && tar xzf ~/G1sms+_backup_$now.tar.gz -C /tmp/CODE/ && rm -f ~/G1sms+_backup_$now.tar.gz

View File

@ -27,7 +27,7 @@ for tag in ./wallets/.$IPFSNODEID/TAG/*; do
tagj=$(echo $tag | cut -d '/' -f 5) tagj=$(echo $tag | cut -d '/' -f 5)
if [[ "${tagj}" == "" ]]; then echo "__SUB:cron_G1TAG_REFRESH.sh: EMPTY"; continue; fi if [[ "${tagj}" == "" ]]; then echo "__SUB:cron_G1TAG_REFRESH.sh: EMPTY"; continue; fi
echo "__SUB:cron_G1TAG_REFRESH.sh: WORKING ON ${tagj}" echo "__SUB:cron_G1TAG_REFRESH.sh: WORKING ON ${tagj}"
RR=$($YOU -c "ipfs cat /ipns/${tagj}/TAG_id | sed s/\ //g"); RR=$(./shell/timeout.sh -t 8 su $YOU -c "ipfs cat /ipns/${tagj}/TAG_id | sed s/\ //g");
if [[ "$RR" == "" ]]; then if [[ "$RR" == "" ]]; then
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag Destroyed !!!??"; echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag Destroyed !!!??";

View File

@ -7,17 +7,27 @@
# Activate SUPPORT MODE: open ssh over IPFS # Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi if [[ -f $MY_PATH/.profile ]]; then
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) source $MY_PATH/../.profile
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi else
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi echo -e "${c_red}Le .profile n'existe pas$c_"
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'") exit 1
fi
cd $GPATH cd $GPATH
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
su $YOU -c "ipfs p2p close --all" su $YOU -c "ipfs p2p close --all"
su $YOU -c "ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22" su $YOU -c "ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22"
su $YOU -c "ipfs p2p listen /x/http /ip4/127.0.0.1/tcp/80" su $YOU -c "ipfs p2p listen /x/http /ip4/127.0.0.1/tcp/80"
su $YOU -c "ipfs p2p listen /x/https /ip4/127.0.0.1/tcp/443" su $YOU -c "ipfs p2p listen /x/https /ip4/127.0.0.1/tcp/443"
su $YOU -c "ipfs p2p ls" $(su $YOU -c "ipfs p2p ls")
echo "==================================
CONNECT TO XPORT = ssh, http, https
XPORT=ssh
LOCALPORT=$((10000 + RANDOM % 64000))
ipfs p2p forward /x/$XPORT /ip4/127.0.0.1/tcp/$LOCALPORT /ipfs/$IPFSNODEID"

View File

@ -10,8 +10,14 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi if [[ -f $MY_PATH/.profile ]]; then
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) 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 [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
@ -31,6 +37,7 @@ if [[ "$1" == "" ]]; then
fi fi
################################################################## ##################################################################
################################################################## ##################################################################
if [[ "$1" == "PRINT" ]]; then if [[ "$1" == "PRINT" ]]; then
################################################################## ##################################################################

View File

@ -42,7 +42,7 @@ while read line
sms_INIT_ACCOUNT "$PHONE" "NOSMS" sms_INIT_ACCOUNT "$PHONE" "NOSMS"
# echo -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" # echo -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB"
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" -y) PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $REF / $NB" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then if [[ "$(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 avec votre virement. Retour silkaj: $PAY ... $new"; sms_ERROR "$PHONE" "Il est survenu un problème avec votre virement. Retour silkaj: $PAY ... $new";

0
shell/diceware-wordlist.txt Normal file → Executable file
View File

View File

@ -17,23 +17,33 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
function sms_SEND () { function sms_SEND () {
# sms_SEND ($1=phone, $2=message) # sms_SEND ($1=phone, $2=message)
local dest="$1" local dest="$1"
local dhash=$(echo -n $dest | sha256sum | cut -d ' ' -f 1)
local mess="$2" local mess="$2"
# IF $dest looks like a phone number
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
if [[ -d ./wallets/$dest ]]; then # Search it in wallets_swarm
# TEST IF $dest IS ON CURRENT NODE if [[ -d ./wallets_swarm/PHONE/$dhash ]]; then
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2 DESTNODEID=$(cat ./wallets_swarm/PHONE/$dhash/MASTERPHONE.ipfsid)
# Other Node is managing wallet, write SMS task to it
if [[ "$DESTNODEID" != "" && "$DESTNODEID" != "$IPFSNODEID" ]]; then
log "$dest is managed by NODE: $DESTNODEID)"
mkdir -p "./wallets/.$DESTNODEID/SMS"
echo $mess > "./wallets/.$DESTNODEID/SMS/$dest.sms2send"
# Push changes to IPFS
I=$(ipfs_node_wallets_add)
else
# Send SMS from here
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
fi
else else
# Send SMS through $dest NODE (TODO: send it like PRINT, TASK, ...) # Send SMS from here
DESTNODEID=$(cat ./wallets_swarm/$dest/MASTERPHONE.ipfsid) gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
log "$dest is managed by NODE: $DESTNODEID)"
mkdir "./wallets/.$DESTNODEID/SMS"
echo $mess > "./wallets/.$DESTNODEID/SMS/$dest.sms2send"
I=$(ipfs_node_wallets_add)
fi fi
else else
log ">>>>>>>>>>SMS ERROR BAD DESTINATION $dest" log "${c_red}>>>>>>>>>>SMS ERROR BAD DESTINATION $dest$c_"
fi fi
log ">>>>>>>>>> SENDING SMS $mess TO $dest ($DESTNODEID)" log "${c_green}>>>>>>>>>> SENDING SMS$c_ \n$mess TO $dest via $DESTNODEID"
} }
@ -41,14 +51,14 @@ function sms_SEND () {
function sms_ERROR () { function sms_ERROR () {
# sms_ERROR ($1=phone, $2=message) # sms_ERROR ($1=phone, $2=message)
local dest="$1" local dest="$1"
local mess="[ERREUR] local mess="[ERREUR]
$2" $2"
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2 gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
else else
log ">>>>>>>>>>SMS ERROR BAD DESTINATION $dest" log "${c_red}>>>>>>>>>>SMS ERROR BAD DESTINATION$c_ $dest"
fi fi
log ">>>>>>>>>> SENDING SMS $mess TO $dest" log "${c_red}>>>>>>>>>> SENDING SMS$c_ \n$mess TO $dest"
# SEND ERROR COPY TO ADMINPHONE # SEND ERROR COPY TO ADMINPHONE
if [[ "$CPERROR" == "YES" ]]; then sms_SEND "$ADMINPHONE" "ADMIN! ERROR ($dest): $mess"; fi if [[ "$CPERROR" == "YES" ]]; then sms_SEND "$ADMINPHONE" "ADMIN! ERROR ($dest): $mess"; fi
} }
@ -69,11 +79,11 @@ function security () {
if [[ "$G1SMS" == "YES" ]]; then # ONLY OF gammu is really sending SMS on that NODE if [[ "$G1SMS" == "YES" ]]; then # ONLY OF gammu is really sending SMS on that NODE
# No Reply to MySelf (or enjoy SMS LOOP of the death) Nobody neither # No Reply to MySelf (or enjoy SMS LOOP of the death) Nobody neither
if [[ "$PHONE" == "$MASTERPHONE" || "$PHONE" == "" ]]; then log "__SUB:security: SMS REJECTED !! $PHONE $TEXT"; exit; fi if [[ "$PHONE" == "$MASTERPHONE" || "$PHONE" == "" ]]; then log "${c_red}__SUB:security: SMS REJECTED !!$c_ $PHONE $TEXT"; exit; fi
# ADAPT TO YOUR PHONE COMPANY / ADVERT ANNOYANCE # ADAPT TO YOUR PHONE COMPANY / ADVERT ANNOYANCE
if [[ "$PHONE" == "Orange Info" ]]; then log "__SUB:security: SMS REJECTED !! $PHONE ADVERT $TEXT"; exit; fi if [[ "$PHONE" == "Orange Info" ]]; then log "${c_red}__SUB:security: SMS REJECTED !! $PHONE ADVERT$c_ $TEXT"; exit; fi
if [[ ${#PHONE} -ne 12 && ${#PHONE} -ne 46 ]]; then log "!! SMS REJECTED !! $PHONE BAD $TEXT"; exit; fi if [[ ${#PHONE} -ne 12 && ${#PHONE} -ne 46 ]]; then log "${c_red}!! SMS REJECTED !! $PHONE BAD$c_ $TEXT"; exit; fi
fi fi
# ANTI SPAM SMS (1 mn entre chaque commande) # ANTI SPAM SMS (1 mn entre chaque commande)
@ -88,7 +98,7 @@ if [[ "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then
echo $(date) > "/tmp/sms_SPAM_$PHONE" echo $(date) > "/tmp/sms_SPAM_$PHONE"
fi fi
log "__SUB:security: ################################" log "__SUB:security: ################################"
log "__SUB:security: $PHONE COMMAND REJECTED: $TEXT" log "${c_red}__SUB:security: $PHONE COMMAND REJECTED:$c_ $TEXT"
exit exit
fi fi
echo "$TEXT" > "/tmp/sms_received_$PHONE" echo "$TEXT" > "/tmp/sms_received_$PHONE"
@ -97,7 +107,7 @@ if [[ "$CMD" != "DELIVERED" && "$CMD" != "PENDING" ]]; then
else else
# THIS IS AN AKNOWLEGEMENT # THIS IS AN AKNOWLEGEMENT
log "__SUB:security: ################################" log "__SUB:security: ################################"
log "__SUB:security: $PHONE COMMAND REJECTED: $TEXT" log "${c_red}__SUB:security: $PHONE COMMAND REJECTED:$c_ $TEXT"
exit exit
fi fi
# Remove SPAM flag older than one day # Remove SPAM flag older than one day
@ -115,27 +125,29 @@ I=$(ipfs_node_wallets_add)
# REFRESH SWARM MEMORY # REFRESH SWARM MEMORY
mkdir -p "./wallets_swarm" mkdir -p "./wallets_swarm"
chown -R $YOU "./wallets_swarm" chown -R $YOU "./wallets_swarm"
log "__SUB:ipfs_swarm_wallets_refresh: REFRESHING SWARM $PHONE shared memory..."
if [[ $PHONE ]]; then rm -Rf ./wallets_swarm/$PHONE; fi log "${yellow}__SUB:ipfs_swarm_wallets_refresh: REFRESHING SWARM $HASHLINK ($PHONE) shared memory...$c_"
if [[ $HASHLINK ]]; then rm -Rf ./wallets_swarm/PHONE/$HASHLINK; fi
# GET IPNS published wallets from ALL SWARM NODES / TODO: IF NODES MISSING, check ./wallets_swarm/.QmNODES... # GET IPNS published wallets from ALL SWARM NODES / TODO: IF NODES MISSING, check ./wallets_swarm/.QmNODES...
#log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID" #log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID" su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
count=1 count=1
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding # Search for All peers Nodes. TODO: To be changed when Swarm is too big and stable
#for id in ./wallets/.Qm*/; for id in ./wallets_swarm/.Qm*/;
for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}'); #for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
do do
count=$((count+1)) count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 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 REFRESHING ./wallets_swarm/.$id"
rm -Rf ./wallets_swarm/.$id rm -Rf ./wallets_swarm/.$id
./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id" su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
done done
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!" log "${c_green}__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!$c_"
############################################################################" ############################################################################"
# TODO: MOVE AS GENERIC IPFS NODE DIALOG FUNCTION
# TREAT move_g1cents Tasks in ./wallets/.$IPFSNODEID # TREAT move_g1cents Tasks in ./wallets/.$IPFSNODEID
# IF NODE find in ./wallets_swarm/.$IPFSNODEID/TASK directory && Have it's G1 Wallet already (for natools crypto) # IF NODE find in ./wallets_swarm/.$IPFSNODEID/TASK directory && Have it's G1 Wallet already (for natools crypto)
if [[ "$1" != "SIMPLE" && -d ./wallets_swarm/.$IPFSNODEID/TASK && -f "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" ]]; then if [[ "$1" != "SIMPLE" && -d ./wallets_swarm/.$IPFSNODEID/TASK && -f "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" ]]; then
@ -146,7 +158,9 @@ do
TNANO=$( echo $FTASK | cut -d '.' -f 1) # $NANODATE TNANO=$( echo $FTASK | cut -d '.' -f 1) # $NANODATE
TTYPE=$( echo $FTASK | cut -d '.' -f 2) # move_g1cents TTYPE=$( echo $FTASK | cut -d '.' -f 2) # move_g1cents
TDEST=$( echo $FTASK | cut -d '.' -f 3) # $DESTPHONE TDEST=$( echo $FTASK | cut -d '.' -f 3) # $DESTPHONE
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) FOUND TASK $TNANO:$TTYPE:$TDEST " HDEST=$(echo -n $TDEST | sha256sum | cut -d ' ' -f 1)
log "${c_yellow}__SUB:ipfs_swarm_wallets_refresh:$c_ .$IPFSNODEID($FTASK) FOUND TASK $TNANO:$TTYPE:$TDEST"
# MAKE LOCAL .$IPFSNODEID directory # MAKE LOCAL .$IPFSNODEID directory
mkdir -p ./wallets/.$IPFSNODEID/TASK/ mkdir -p ./wallets/.$IPFSNODEID/TASK/
# TODO: CHECK BETTER NOT DONE YET and $NANODATE > $TNANO (=> detect NODES writing in the future!!) # TODO: CHECK BETTER NOT DONE YET and $NANODATE > $TNANO (=> detect NODES writing in the future!!)
@ -161,30 +175,30 @@ do
log "__SUB:ipfs_swarm_wallets_refresh: tdiff=$tdiff .$IPFSNODEID G1 = ./NODEG1Wallet.authfile :decrypt: Found $ZENVAL Zen to ADD" log "__SUB:ipfs_swarm_wallets_refresh: tdiff=$tdiff .$IPFSNODEID G1 = ./NODEG1Wallet.authfile :decrypt: Found $ZENVAL Zen to ADD"
rm -f "./NODEG1Wallet.authfile" rm -f "./NODEG1Wallet.authfile"
if [[ $ZENVAL -gt 0 ]]; then if [[ $ZENVAL -gt 0 ]]; then
curvalue=$(cat ./wallets/$TDEST/$TDEST.g1cents) curvalue=$(cat ./wallets/PHONE/$HDEST/_g1cents)
newvalue=$(bc -l <<< "$curvalue + $ZENVAL") newvalue=$(bc -l <<< "$curvalue + $ZENVAL")
echo $newvalue > ./wallets/$TDEST/$TDEST.g1cents echo $newvalue > ./wallets/PHONE/$HDEST/_g1cents
echo "OK.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO echo "OK.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) DONE! OPERATION: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents:: OK" log "${c_green}__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) DONE!$c_ OPERATION: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/PHONE/$HDEST/_g1cents:: OK"
# REFRESH ./wallets and PUBLISH # REFRESH ./wallets and PUBLISH
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
else else
echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO" log "${red}__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR!$c_ BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/PHONE/$HDEST/_g1cents :: ${red}KO$c_"
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
sms_SEND "$ADMINPHONE" "ADMIN! TASK ERROR: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/$TDEST/$TDEST.g1cents :: KO" sms_SEND "$ADMINPHONE" "ADMIN! TASK ERROR: .$IPFSNODEID($FTASK) ERROR! BAD: ($curvalue + $ZENVAL) = $newvalue Zen <=> ./wallets/PHONE/$HDEST/_g1cents :: KO"
fi fi
else else
# TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish? # TODO: Bad NODE in the Future task !!! Make better BAD Node detection = Swarm Banish?
echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO echo "KO.$tdiff" > ./wallets/.$IPFSNODEID/TASK/done.$TNANO
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO" log "${red}__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID($FTASK) ERROR!$c_ DATE PROBLEM: $NANODATE < $TNANO :: ${red}KO$c_"
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
sms_SEND "$ADMINPHONE" "ADMIN! .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO" sms_SEND "$ADMINPHONE" "ADMIN! .$IPFSNODEID($FTASK) ERROR! DATE PROBLEM: $NANODATE < $TNANO :: KO"
fi fi
fi fi
done done
log "__SUB:ipfs_swarm_wallets_refresh: REMOVE OLD TASK MARKED AS DONE" log "${c_yellow}__SUB:ipfs_swarm_wallets_refresh:$c_ REMOVE OLD TASK MARKED AS DONE"
for scan in ./wallets_swarm/.Qm*/TASK/done.*; do for scan in ./wallets_swarm/.Qm*/TASK/done.*; do
lscan=$(echo $scan | sed s/_swarm//g ) lscan=$(echo $scan | sed s/_swarm//g )
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 ) lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
@ -196,7 +210,7 @@ done
fi fi
done done
else else
log "__SUB:ipfs_swarm_wallets_refresh: .$IPFSNODEID :: NO TASK ! " log "${c_yellow}__SUB:ipfs_swarm_wallets_refresh:$c_ .$IPFSNODEID :: NO TASK !"
############################################################################" ############################################################################"
fi fi
} }
@ -210,247 +224,224 @@ function ipfs_node_wallets_add (){
# CHAIN STATE FOR $IPFSNODEID # CHAIN STATE FOR $IPFSNODEID
echo $IWALLETS > ./wallets/.$IPFSNODEID.wallets.chain echo $IWALLETS > ./wallets/.$IPFSNODEID.wallets.chain
log "__SUB:ipfs_node_wallets_add: NEW './wallets' HASH ipfs ls $IWALLETS" log "${c_yellow}__SUB:ipfs_node_wallets_add:$c_ NEW './wallets' HASH ipfs ls /ipfs/$IWALLETS"
# PUBLISH IPNS NODE WALLETS # PUBLISH IPNS NODE WALLETS
NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS") NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS")
log "__SUB:ipfs_node_wallets_add: G1smsWallet = ipfs cat /ipns/$NODEWALLETS/$PHONE/$PHONE.g1cents Zen" log "__SUB:ipfs_node_wallets_add: G1smsWallet = ipfs cat /ipns/$NODEWALLETS/PHONE/$HASHLINK/_g1cents Zen"
echo $IWALLETS echo $IWALLETS
} }
################################################################################################################################# #################################################################################################################################
function sms_uid2key (){ function sms_uid2pubkey (){
RIBFILE="./wallets/$PHONE/$PHONE.uidrib" ## USE $PHONE link instead of real local $HASHLINK directory
NAMEFILE="./wallets/$PHONE/$PHONE.uidname" RIBFILE="./wallets/PHONE/$PHONE/_uidrib"
UIDNAFILE="./wallets/$PHONE/$PHONE.uidna" NAMEFILE="./wallets/PHONE/$PHONE/_uidname"
# New related wallet asked UIDNAFILE="./wallets/PHONE/$PHONE/_uidna"
# ASKWALLET is
ASKWALLET="$1" ASKWALLET="$1"
#For micro payement
#For Micro Payement to DESTRIB (for easy G1sms wallet find in Cesium wallet History)
PHONE="$2" PHONE="$2"
PIN="$3" PIN="$3"
if -f "$UIDNAFILE"; then UIDNA=$(cat "$UIDNAFILE"); else UIDNA=""; fi
log "__SUB:sms_uid2key: $UIDNA Try to associate $ASKWALLET with $PHONE... SEARCHING..."
# Get PHONE wallet UIDNA name
if [[ -f "$UIDNAFILE" ]]; then UIDNA=$(cat "$UIDNAFILE"); else UIDNA=""; fi
log "__SUB:sms_uid2pubkey: $UIDNA Wallet ($PHONE) is trying to associate to $ASKWALLET... SEARCHING..."
# Link to itSelf
if [[ $UIDNA && "$ASKWALLET" == "$UIDNA" ]]; then if [[ $UIDNA && "$ASKWALLET" == "$UIDNA" ]]; then
log "__SUB:sms_uid2key: "$ASKWALLET" == "$UIDNA" !!" log "__SUB:sms_uid2pubkey: "$ASKWALLET" == "$UIDNA" !!"
sms_SEND "$PHONE" "[G1sms+] $UIDNA est le nom de votre porte monnaie libre pour $PHONE. Il ne peut également être compte maître!" sms_SEND "$PHONE" "[G1sms+] $UIDNA est le nom de portefeuille G1sms. Il ne peut pas être associé à lui même!"
fi fi
# Test if member files exists # Test if _uidname file exists
if [ -f "$NAMEFILE" ]; then if [ -f "$NAMEFILE" ]; then
# Actuel related wallet
UIDNAME=$(cat "$NAMEFILE") UIDNAME=$(cat "$NAMEFILE")
log "__SUB:sms_uid2key: ALREADY $UIDNAME related Wallet for $PHONE Wallet change to $ASKWALLET !!" log "__SUB:sms_uid2pubkey: Actual $UIDNA Wallet Related to $UIDNAME. Ask change to $ASKWALLET"
if [["$UIDNAME" != "$ASKWALLET" ]]; then if [["$UIDNAME" != "$ASKWALLET" ]]; then
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE Wallet associé à $UIDNAME change en $ASKWALLET !!" sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE Wallet associé à $UIDNAME change en $ASKWALLET !!"
sms_SEND "$PHONE" "[G1sms+] Votre portefeuille maitre va passer de $UIDNAME à $ASKWALLET!" sms_SEND "$PHONE" "[G1sms+] Votre portefeuille associé va passer de $UIDNAME à $ASKWALLET!"
fi fi
fi fi
# Search fo duplicate # Search fo duplicate (TODO: choose $PHONE result
DUP=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidname | cut -f 3 -d '/') DUP=$(grep -Rwl "$ASKWALLET" ./wallets/PHONE/*/_uidname | tail -n 1 | cut -f 4 -d '/')
if [[ "$DUP" != "" && "$DUP" != "$PHONE" ]]; then if [[ "$DUP" != "" ]]; then
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE prend le même $ASKWALLET, que $DUP" 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!" sms_SEND "$DUP" "Votre portefeuille associé $ASKWALLET vient d'être associé à $PHONE également!"
fi fi
########################################################### ###########################################################
# FIND ASKWALLET into wallets, wallest_swarm OR duniter (silkaj) # FIND ASKWALLET into wallets, wallest_swarm OR duniter (silkaj)
DESTMEM="$VIRDEST" DESTMEM="$VIRDEST"
# SEARCH IN WALLETS # SEARCH IN WALLETS
LOCAL=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidna | cut -f 3 -d '/') LOCAL=$(grep -Rwl "$ASKWALLET" ./wallets/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/')
if [[ "$LOCAL" != "" ]]; then if [[ "$LOCAL" != "" ]]; then
# LOCAL G1sms account # LOCAL G1sms account
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub) DESTRIB=$(cat ./wallets/PHONE/$LOCAL/_pub)
DESTPHONE=$LOCAL DESTPHONE=$LOCAL
log "__SUB:sms_uid2key: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)" log "${c_yellow}__SUB:sms_uid2pubkey:$c_ FOUND LOCAL ($MASTERPHONE) G1sms Wallet: $DESTRIB ($DESTPHONE)"
else else
# SEARCH IN WALLETS SWARM # SEARCH IN WALLETS SWARM
INSWARM=$(grep -Rwl "$ASKWALLET" ./wallets_swarm/*/*.uidna | cut -f 3 -d '/') INSWARM=$(grep -Rwl "$ASKWALLET" ./wallets_swarm/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/')
if [[ "$INSWARM" != "" ]]; then if [[ "$INSWARM" != "" ]]; then
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms) REMOTENODE=$(cat ./wallets_swarm/PHONE/$INSWARM/MASTERPHONE.sms)
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub) REMOTENODEIPFSID=$(cat ./wallets_swarm/PHONE/$INSWARM/MASTERPHONE.ipfsid)
DESTRIB=$(cat ./wallets_swarm/PHONE/$INSWARM/_pub)
DESTPHONE=$INSWARM DESTPHONE=$INSWARM
log "__SUB:sms_uid2key: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)" log "${c_green}__SUB:sms_uid2pubkey: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($DESTPHONE)$c_"
else else
# SEARCH WITH SILKAJ # SEARCH FOR DUNITER MEMBER WITH SILKAJ
log "__SUB:sms_uid2key: GETTING FROM SILKAJ MEMBER ID" log "__SUB:sms_uid2pubkey: GETTING FROM SILKAJ MEMBER ID"
DESTRIB=$(./silkaj/silkaj id "$ASKWALLET" | grep -w "$ASKWALLET" | awk '{print $2}') DESTRIB=$(./silkaj/silkaj id "$ASKWALLET" | grep -w "$ASKWALLET" | awk '{print $2}')
log "__SUB:sms_uid2key: OUT OFF SWARM MEMBER wallet: $DESTRIB" log "__SUB:sms_uid2pubkey: OUT OFF SWARM MEMBER wallet: $DESTRIB"
# GET CESIUM+ geoPoint DATA (TODO: cron for GCHANGE SMS Alert) # GET CESIUM+ geoPoint DATA (TODO: cron for GCHANGE SMS Alert)
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.geoPoint' > "./wallets/$PHONE/$PHONE.uidgeo.json" curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.geoPoint' > "./wallets/PHONE/$PHONE/_uidgeo.json"
log "__SUB:sms_uid2key: GET CESIUM+ geoPoint and AVATAR : $(cat ./wallets/$PHONE/$PHONE.uidgeo.json)" log "__SUB:sms_uid2pubkey: GET CESIUM+ geoPoint and AVATAR : $(cat ./wallets/PHONE/$PHONE/_uidgeo.json)"
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "./wallets/$PHONE/$PHONE.avatar.png" curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "./wallets/PHONE/$PHONE/_avatar.png"
fi fi
fi fi
if [ "$DESTRIB" != "" ]; then if [ "$DESTRIB" != "" ]; then
echo "$DESTRIB" > "$RIBFILE" echo "$DESTRIB" > "$RIBFILE"
echo "$ASKWALLET" > "$NAMEFILE" echo "$ASKWALLET" > "$NAMEFILE"
log "__SUB:sms_uid2key: NEW EXTERNAL RELATED $DESTRIB / FOR MEMBER OR WALLET = $ASKWALLET - INIT 0.1 TX" log "${c_yellow}__SUB:sms_uid2pubkey:$c_ NEW RELATED $DESTRIB FOR G1sms WALLET = $ASKWALLET - INIT 0.1 TX"
INIT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="0.1" --output=$DESTRIB --comment="[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y) INIT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="0.1" --output=$DESTRIB --comment="[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y)
log "__SUB:sms_uid2key: INIT = $INIT | Create Connection with related Wallet." log "__SUB:sms_uid2pubkey: INIT = $INIT | Create Connection with related Wallet."
log_history "$PHONE" "MEMBER, $ASKWALLET" log_history "$PHONE" "MEMBER, $ASKWALLET"
sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE Nouveau compte lié $UIDNA -- $ASKWALLET ($INIT)" sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE ($UIDNA) Compte relié >> $ASKWALLET ($INIT)"
else else
sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE / $ASKWALLET ABSENT" sms_SEND "$ADMINPHONE" "ADMIN! LOG: $PHONE ($UIDNA) RELIER A $ASKWALLET INCONNU"
fi fi
log "__SUB:sms_uid2key: $MEMBER($DESTRIB)" log "__SUB:sms_uid2pubkey: $MEMBER($DESTRIB)"
echo "$DESTRIB" echo "$DESTRIB"
} }
################################################################################################################################# #################################################################################################################################
function sms_INIT_ACCOUNT () { function sms_INIT_ACCOUNT () {
log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)" log "${c_yellow}__SUB:sms_INIT_ACCOUNT:$c_ ($1=phone, $2=NOSMS)"
PHONE="$1" PHONE="$1"
UNKNOWN=0 UNKNOWN=0
# TODO Optimize GLOBAL/local variables use, use more function array output ?!
# Initiate PHONE settings files and values # Initiate PHONE settings files and values
IPFSNODEIDFILE="./wallets/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
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" # 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)
RIBFILE="./wallets/$PHONE/$PHONE.uidrib" # Contains phone wallet related UID Pubkey # WALLETS INTO ./wallets/CHANNEL/sha256sum(PHONE)
NAMEFILE="./wallets/$PHONE/$PHONE.uidname" # Contains the member UID related to wallet HASHLINK=$(echo -n $PHONE | sha256sum | cut -d ' ' -f 1)
MAILFILE="./wallets/$PHONE/$PHONE.email" # Contains the member EMAIL (Send BILLET) # WALLETS INTO ./wallets/CHANNEL/sha256sum(PHONE)
GPGMAILFILE="./wallets/$PHONE/$PHONE.email.gpg" # Contains the member EMAIL (Send BILLET)
UIDNAFILE="./wallets/$PHONE/$PHONE.uidna" # Contains the G1sms+ UID Name for recursive VIR
GEOFILE="./wallets/$PHONE/$PHONE.uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
RECFILE="./wallets/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet IPFSNODEIDFILE="./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
GPGRECFILE="./wallets/$PHONE/VIREMENTS.gpg" # Cypher file with GPGPASS (Node .Identity.PrivKey) SMSNODE="./wallets/PHONE/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
G1COUNTFILE="./wallets/$PHONE/$PHONE.g1cents" # Last sms_COUNT.sh call value PINFILE="./wallets/PHONE/$PHONE/_pin" # Contains phone wallet diceware password
CHAINFILE="./wallets/$PHONE/$PHONE.chain" # Contains wallet last IPFS hash before ZEN value change GPGPINFILE="./wallets/PHONE/$PHONE/_pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
AUTHCRYPTFILE="./wallets/PHONE/$PHONE/_authfile.node.crypt" # authfile backup cyphered by Node G1 Pubkey
PUBKEYFILE="./wallets/PHONE/$PHONE/_pub" # Contains phone wallet public key (RIB)
UNITFILE="./wallets/PHONE/$PHONE/_unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
DABUIDF="./wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name RIBFILE="./wallets/PHONE/$PHONE/_uidrib" # Contains phone wallet related UID Pubkey
NAMEFILE="./wallets/PHONE/$PHONE/_uidname" # Contains Related MEMBER UID or Wallet UIDNA
MAILFILE="./wallets/PHONE/$PHONE/_email" # Contains the member EMAIL (Send BILLET)
GPGMAILFILE="./wallets/PHONE/$PHONE/_email.gpg" # Contains the member EMAIL (Send BILLET)
UIDNAFILE="./wallets/PHONE/$PHONE/_uidna" # Contains the G1sms+ UID Name for recursive VIR
GEOFILE="./wallets/PHONE/$PHONE/_uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
RECFILE="./wallets/PHONE/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet
GPGRECFILE="./wallets/PHONE/$PHONE/VIREMENTS.gpg" # Cypher file with GPGPASS (Node .Identity.PrivKey)
G1COUNTFILE="./wallets/PHONE/$PHONE/_g1cents" # Last sms_COUNT.sh call value
CHAINFILE="./wallets/PHONE/$PHONE/_chain" # Contains wallet last IPFS hash before ZEN value change
NNFILE="./wallets/PHONE/$PHONE/_n" # Contains Changes Number
DABUIDF="./wallets/PHONE/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
# GET CURRENT NODE UIDNA (default DABUID) # GET CURRENT NODE UIDNA (default DABUID)
NODEUIDNA=$(cat "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna") NODEUIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
[[ $NODEUIDNA == "" ]] && NODEUIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
###################################################################### ######################################################################
# (NO PIN) = FIRST ACCOUNT: Create wallet ######################################################################
# (NO $PINFILE) = FIRST ACCOUNT: Create wallet
######################################################################
if [ ! -f "$PINFILE" ]; then if [ ! -f "$PINFILE" ]; then
# NOSMS mode? # NOSMS mode? = DO NOT CREATE
if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi
####################### #######################
# Create Account Files # Create Account Files
####################### #######################
mkdir -p "./wallets/$PHONE/" if [[ ! -d ./wallets/PHONE/$HASHLINK ]]; then
PIN=$(./shell/diceware.sh | xargs) mkdir -p ./wallets/PHONE/$HASHLINK
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$PHONE" -password="$PIN") ln -s ./wallets/PHONE/$HASHLINK ./wallets/PHONE/$PHONE
fi
# LINKS ARE NOT REPLICATED INTO IPFS ;)
# 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 $NODE_G1PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
rm -f ./authfile
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE $PIN : $PUBKEY"
####################### #######################
# GIVE NAME TO WALLET # GIVE NAME TO WALLET
####################### #######################
# 4 derniers chiffres du numéro de téléphone # 4 derniers chiffres du numéro de téléphone
TAIL=${PHONE:8:4} TAIL=${PHONE:8:4}
# No UIDNA yet. Create new # No UIDNA yet. Create new
UIDNA=$(./shell/diceware.sh 1 | xargs) UID=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets # Check if already existing among all swarm wallets
while [[ $(grep -Rwl $UIDNA$TAIL ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done while [[ $(grep -Rwl $UID$TAIL ./wallets_swarm/*/*.uidna) ]]; do UID=$(./shell/diceware.sh 1 | xargs); done
echo "$UIDNA$TAIL" > "$UIDNAFILE" UIDNA=$UIDNA$TAIL
echo "$UIDNA" > "$UIDNAFILE"
PIN=$(./shell/diceware.sh | xargs)
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$UIDNA" -password="$PIN")
# BACKUP authfile available to authfile or PIN owner (DOUBLON AVEC PIN) TEST
log "__SUB:sms_INIT_ACCOUNT: ./shell/natools.py encrypt -p $NODE_G1PUBKEY -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 (HASHLINK=$HASHLINK)"
####################### #######################
# ACTIVATE G1SMS WALLET # ACTIVATE G1SMS WALLET
####################### #######################
# log "$NODE_G1AUTHFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY" # log "$NODE_G1AUTHFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY"
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1AUTHFILE" --amount=3.24 --output=$PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY " -y) TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1AUTHFILE" --amount=3.24 --output=$PUBKEY --comment="[G1sms+] $UIDNA 3RD:$NODE_G1PUBKEY " -y)
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX IN: $TX_IN" log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX IN: $TX_IN"
sleep 2 sleep 2
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount=0.1 --output=$NODE_G1PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY:ACK" -y) TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount=0.1 --output=$NODE_G1PUBKEY --comment="[G1sms+] $UIDNA 3RD:$NODE_G1PUBKEY:ACK" -y)
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT" log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
################ ################
# GPG cypher PIN (ONLY CREATOR NODE CAN ACCESS IT !) # GPG cypher PIN (ONLY CREATOR NODE CAN ACCESS IT !)
################ ################
echo "$PIN" > "$PINFILE" echo "$PIN" > "$PINFILE"
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE" # echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"
PIN=$(cat "$PINFILE" | xargs) ./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$PINFILE" -o "$PINFILE.node.crypt"
# [[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???" ./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "$PINFILE" -o "$PINFILE.swarm.crypt"
# EMPTY CLEAR PIN
echo "" > "$PINFILE"
echo "114" > "$G1COUNTFILE" # WRITE G1sms WALLET FILES
echo "314" > "$G1COUNTFILE"
echo "0" > "$NNFILE"
echo "$PUBKEY" > "$PUBKEYFILE" echo "$PUBKEY" > "$PUBKEYFILE"
echo "$COIN" > "$UNITFILE" echo "$COIN" > "$UNITFILE"
echo "$MASTERPHONE" > "$SMSNODE" echo "$MASTERPHONE" > "$SMSNODE"
log_history "$PHONE" "NEW, $PUBKEY" log_history "$PHONE" "NEW, $PUBKEY"
# ADD WALLET TO IPFS # PUSH WALLET TO IPFS
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
fi fi
################################################# #################################################
# PUBLISH G1sms+ WALLET PROPERTIES MAIN PROCESS # PUBLISH G1sms+ WALLET PROPERTIES MAIN PROCESS
################################################# #################################################
###################################################################### ######################################################################
if [[ ! -f "$GPGPINFILE" ]] log "__SUB:sms_INIT_ACCOUNT: decrypting PIN..."
then # GPG decypher PIN
# ------------8<------------------ # TODO make decypher less stress on filesystem, use /tmp and ramdisk
# WALLET MIGRATION -> CRYPT PIN (For Old G1sms clear PIN WALLETs...) # echo "${GPGPASS}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
# ADD NEW PARAMS TO WALLET [[ "$PIN" == "" ]] && ./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$PINFILE.node.crypt" -o "$PINFILE" && PIN=$(cat "$PINFILE" | xargs) && echo "" > "$PINFILE";
#######################
# 4 derniers chiffres du numéro de téléphone
echo "$MASTERPHONE" > "$SMSNODE"
TAIL=${PHONE: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
echo "$UIDNA$TAIL" > "$UIDNAFILE"
PIN=$(cat "$PINFILE" | xargs) # DECYPHER MAIL
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!" [[ -f "$MAILFILE.node.crypt" ]] && ./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$MAILFILE.node.crypt" -o "$MAILFILE" && MAIL=$(cat "$MAILFILE") && echo "" > "$MAILFILE";
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_UIDNA.crypt"
else
# ------------>8------------------
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
# GPG decypher PIN
# 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)
[[ "$PIN" == "" && -f "$PINFILE.$NODE_UIDNA.crypt" ]] && ./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$PINFILE.$NODE_UIDNA.crypt" -o "$PINFILE" && PIN=$(cat "$PINFILE");
# [[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
fi
# CYPHER EMAIL FILE
if [[ ! -f "$GPGMAILFILE" ]]; then
# ------------8<------------------
log "__SUB:sms_INIT_ACCOUNT: NO EMAIL .gpg file, CREATING it"
if [ -f "$MAILFILE" ]; then
MAIL=$(cat "$MAILFILE");
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
else
MAIL="";
fi
# ------------>8------------------
else
log "__SUB:sms_INIT_ACCOUNT: DECODING EMAIL .gpg... "
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
MAIL=$(cat "$MAILFILE");
[[ $MAIL == "" && -f "$MAILFILE.node.crypt" ]] && ./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$MAILFILE.node.crypt" -o "$MAILFILE" && MAIL=$(cat "$MAILFILE");
# EMPTY CLEAR EMAIL FILE
[[ $MAIL != "" ]] && echo "" > "$MAILFILE" || log "SYSTEM ERROR :: MAIL EMPTY !!! GPG???"
fi
# ------------8<------------------
# REMOVE OLD HISTORY FILES
rm -f ./wallets/$PHONE/$PHONE.hist
# ------------>8------------------
# PUBLISH GLOBAL VARS FROM ACCOUNT FILES # PUBLISH GLOBAL VARS FROM ACCOUNT FILES
echo $IPFSNODEID > $IPFSNODEIDFILE echo $IPFSNODEID > $IPFSNODEIDFILE
PUBKEY=$(cat "$PUBKEYFILE" | xargs) PUBKEY=$(cat "$PUBKEYFILE" | xargs)
@ -479,9 +470,9 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
log "__SUB:sms_INIT_ACCOUNT: $AMOUNTG1 = $AMOUNT $UNIT" log "__SUB:sms_INIT_ACCOUNT: $AMOUNTG1 = $AMOUNT $UNIT"
# LOG # TODO REMOVE PIN LOG!! # LOG # TODO REMOVE PIN LOG!!
log "#####################" log "${c_yellow}#####################$c_"
log "PHONE: $PHONE" log "PHONE: $PHONE"
log "PIN: $PIN" # log "PIN: $PIN"
log "PUBKEY: $PUBKEY" log "PUBKEY: $PUBKEY"
log "G1: $AMOUNTG1" log "G1: $AMOUNTG1"
log "AMOUNT: $AMOUNT $UNIT" log "AMOUNT: $AMOUNT $UNIT"
@ -490,17 +481,17 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
log "MEMRIB: $MEMRIB" log "MEMRIB: $MEMRIB"
log "MAIL: $MAIL" log "MAIL: $MAIL"
log "DABID: $DABID" log "DABID: $DABID"
log "#####################" log "${c_yellow}#####################$c_"
log "__SUB:sms_INIT_ACCOUNT: END" log "${c_green}__SUB:sms_INIT_ACCOUNT: END$c_"
} }
################################################################################################################################# #################################################################################################################################
function check_account (){ function check_account (){
log "__SUB:check_account: SILKAJ...... max 30 sec....." log "__SUB:check_account: SILKAJ...... max 21 sec....."
AMOUNTG1=$(./shell/timeout.sh -t 30 ./silkaj/silkaj amount "$PUBKEY") AMOUNTG1=$(./shell/timeout.sh -t 21 ./silkaj/silkaj amount "$PUBKEY")
AMOUNTDU=$(bc <<< "scale=2; $AMOUNTG1 / $DUFACTOR") AMOUNTDU=$(bc <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc <<< "$AMOUNTG1 * 100 / $DUFACTOR") AMOUNTLOVE=$(bc <<< "$AMOUNTG1 * 100 / $DUFACTOR")
@ -520,30 +511,31 @@ G1cents=$(echo "$AMOUNTG1*100" | bc -l | awk '{print int($0)}')
log "__SUB:check_account: $PHONE: $AMOUNTG1 = $AMOUNT $UNIT ($G1cents) - $PUBKEY" log "__SUB:check_account: $PHONE: $AMOUNTG1 = $AMOUNT $UNIT ($G1cents) - $PUBKEY"
if [[ "$G1cents" != "" ]]; then if [[ "$G1cents" != "" ]]; then
NN=$(cat "./wallets/$PHONE/$PHONE.n") NN=$(cat "./wallets/PHONE/$PHONE/_n") || NN=0
((NN++)) ((NN++))
echo "$NN" > "./wallets/$PHONE/$PHONE.n" echo "$NN" > "./wallets/PHONE/$PHONE/_n"
echo $G1cents > "./wallets/$PHONE/$PHONE.g1cents" echo $G1cents > "./wallets/PHONE/$PHONE/_g1cents"
echo "$NANODATE" > "./wallets/PHONE/$PHONE/_nanodate"
# REFRESH NODE IPFS wallets & PUBLISH # REFRESH NODE IPFS wallets & PUBLISH
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
# Register modification # Register modification
echo "$I" > "./wallets/$PHONE/$PHONE.chain" echo "$I" > "./wallets/PHONE/$PHONE/_chain"
else else
# BAN actual Duniter Node in case of silkaj timeout. # BAN actual Duniter Node in case of silkaj timeout.
export NEWDUNITER=$(./shell/checknodes.sh 'BAN') export NEWDUNITER=$(./shell/checknodes.sh 'BAN')
log "__SUB:check_account: !!! SILKAJ IS TOO SLOW !!! => NEW DUNITER SERVER: $NEWDUNITER" log "${c_red}__SUB:check_account: !!! SILKAJ IS TOO SLOW !!!$c_ => NEW DUNITER SERVER: $NEWDUNITER"
fi fi
declare -a aaa declare -a walletvalues
aaa=( "$AMOUNTG1" "$AMOUNT" "$UNIT" ) walletvalues=( "$AMOUNTG1" "$AMOUNT" "$UNIT" )
log "__SUB:check_account: $(declare -p aaa)" log "__SUB:check_account: $(declare -p walletvalues)"
echo ${aaa[@]} echo ${walletvalues[@]}
} }
################################################################################################################################# #################################################################################################################################
function make_accounting (){ function make_accounting (){
# CONVERT AMOUNT UNIT to VIR G1 # CONVERT $AMOUNT $UNIT to $VIR G1
case "$UNIT" in case "$UNIT" in
G1) G1)
VIR=$AMOUNT; VIR=$AMOUNT;
@ -555,21 +547,25 @@ LOVE)
VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR / 100") VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR / 100")
;; ;;
*) *)
VIR=$(bc -l <<< "scale=2; $AMOUNT * $DUFACTOR / 100") VIR=$AMOUNT;
;; ;;
esac esac
log "${c_yellow}__SUB:make_accounting:$c_ $VIR G1 CHECKING FOR $PHONE / PUBKEY = $PUBKEY"
########################################################### ###########################################################
# GET G1sms wallet AMOUNTG1 and CHECK for right balance # GET G1sms wallet AMOUNTG1 and CHECK for right balance
log "__SUB:make_accounting: LOCAL $VIR amount for $PHONE : $PUBKEY" # Ask silkaj. If timeout, use last known $PHONE _g1cents value
# Try to ask silkaj. If timeout, use SWARM last known $PHONE.g1cents value AMOUNTG1=$(./shell/timeout.sh -t 20 ./silkaj/silkaj amount "$PUBKEY")
AMOUNTG1=$(./shell/timeout.sh -t 30 ./silkaj/silkaj amount "$PUBKEY") [[ ! $AMOUNTG1 ]] && AMOUNTG1=$(bc -l <<< "scale=2; $(cat ./wallets/PHONE/$PHONE/_g1cents) / 100")
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi [[ "$AMOUNTG1" == "" ]] && AMOUNTG1=0
# TAX AND MINIMUM WALLET ACCOUNT CALCULATION # TAX AND MINIMUM WALLET ACCOUNT CALCULATION
PERCENT=0$(bc -l <<< "scale=2; $VIR / $SWARMCOMM") PERCENT=0$(bc -l <<< "scale=2; $VIR / $SWARMCOMM")
MIN=$(bc -l <<< "$AMOUNTG1 - $PERCENT - $LIMIT") MIN=$(bc -l <<< "$AMOUNTG1 - $PERCENT - $LIMIT")
CHARGE=$(bc -l <<< "scale=2; $VIR + $PERCENT + $LIMIT") CHARGE=$(bc -l <<< "scale=2; $VIR + $PERCENT + $LIMIT")
TESTMIN=$( echo "${VIR} < ${MIN}" | bc -l ) TESTMIN=$( echo "${VIR} < ${MIN}" | bc -l )
log "__SUB:make_accounting: TEST $AMOUNT $UNIT :: $VIR + $PERCENT + $LIMIT = $CHARGE < $AMOUNTG1 ? $TESTMIN" log "__SUB:make_accounting: TEST $AMOUNT $UNIT :: $VIR + $PERCENT + $LIMIT = $CHARGE < $AMOUNTG1 ? $TESTMIN"
declare -a myarray declare -a myarray
@ -586,7 +582,7 @@ function move_g1cents (){
phonesrc=$1 phonesrc=$1
pubkeydest=$2 pubkeydest=$2
zenvalue=$3 zenvalue=$3
log "__SUB:move_g1cents: $phonesrc ($zenvalue) -> $pubkeydest :: $G1COUNTFILE ::" log "${c_yellow}__SUB:move_g1cents:$c_ $phonesrc ($zenvalue) -> $pubkeydest :: $G1COUNTFILE ::"
### CHANGE INPUT VALUE #### ### CHANGE INPUT VALUE ####
curvalue=$(cat ./wallets/$phonesrc/$phonesrc.g1cents | cut -d '.' -f 1) curvalue=$(cat ./wallets/$phonesrc/$phonesrc.g1cents | cut -d '.' -f 1)
@ -614,13 +610,13 @@ function move_g1cents (){
# USE natools with NODEPUB crypt # USE natools with NODEPUB crypt
echo "$zenvalue" > "/tmp/move_g1cents.$winnerphone" echo "$zenvalue" > "/tmp/move_g1cents.$winnerphone"
# GET NODE G1sms Wallet PUBKEY # GET NODE G1sms Wallet PUBKEY
NODEPUB=$(cat ./wallets_swarm/.$NODEID/$NODEID.pub) NODEPUB=$(cat ./wallets_swarm/.$NODEID/_pub)
./shell/natools.py encrypt -p $NODEPUB -i "/tmp/move_g1cents.$winnerphone" -o "./wallets/.$NODEID/TASK/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt" ./shell/natools.py encrypt -p $NODEPUB -i "/tmp/move_g1cents.$winnerphone" -o "./wallets/.$NODEID/TASK/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt"
log "__SUB:move_g1cents: CREDIT: WRITE TASK TO ./wallets/.$NODEID/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt " log "__SUB:move_g1cents: CREDIT: WRITE TASK TO ./wallets/.$NODEID/$NANODATE.move_g1cents.$winnerphone.NODEPUB.crypt "
rm -f /tmp/move_g1cents.$winnerphone rm -f /tmp/move_g1cents.$winnerphone
fi fi
else else
log "__SUB:move_g1cents: ERROR: NO $pubkeydest WALLET FOUND" log "${c_red}__SUB:move_g1cents: ERROR: NO $pubkeydest WALLET FOUND$c_"
fi fi
# UPDATE MY new ./wallet STATUS to SWARM # UPDATE MY new ./wallet STATUS to SWARM
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
@ -630,6 +626,7 @@ function move_g1cents (){
################################################################################################################################# #################################################################################################################################
# Contact database management # Contact database management
function add_contact(){ function add_contact(){
log "${c_yellow}Add user contact$c_"
userDB="gammu" userDB="gammu"
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1) pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
local sql="mysql -N -u$userDB -p$pwdDB gammu -e" local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
@ -645,6 +642,7 @@ function add_contact(){
$sql "INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('1', '$MEMBERUID', '$PHONE', '1', 'false')" || exit 1 $sql "INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('1', '$MEMBERUID', '$PHONE', '1', 'false')" || exit 1
local id_user=$($sql "SELECT ID FROM pbk WHERE Number=$PHONE" || exit 1) local id_user=$($sql "SELECT ID FROM pbk WHERE Number=$PHONE" || exit 1)
$sql "INSERT INTO user_group (id_group, id_pbk, id_pbk_groups, id_user) VALUES ('$id_user', '$id_user', '1', '1')" || exit 1 $sql "INSERT INTO user_group (id_group, id_pbk, id_pbk_groups, id_user) VALUES ('$id_user', '$id_user', '1', '1')" || exit 1
log "${c_green}Done$c_"
else else
log "${red}Contact already exist$c_" log "${red}Contact already exist$c_"
fi fi
@ -652,6 +650,7 @@ function add_contact(){
} }
function rm_contact(){ function rm_contact(){
log "${c_yellow}Remove user contact$c_"
userDB="gammu" userDB="gammu"
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1) pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
local sql="mysql -N -u$userDB -p$pwdDB gammu -e" local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
@ -665,6 +664,7 @@ function rm_contact(){
local id_user=$($sql "SELECT ID FROM pbk WHERE Number=$PHONE" || exit 1) local id_user=$($sql "SELECT ID FROM pbk WHERE Number=$PHONE" || exit 1)
$sql "DELETE FROM pbk WHERE Number=$PHONE" || exit 1 $sql "DELETE FROM pbk WHERE Number=$PHONE" || exit 1
$sql "DELETE FROM user_group WHERE id_group='$id_user'" || exit 1 $sql "DELETE FROM user_group WHERE id_group='$id_user'" || exit 1
log "${c_green}Done$c_"
else else
log "${red}Contact doesn't exist$c_" log "${red}Contact doesn't exist$c_"
fi fi

0
shell/g1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

0
shell/g1tag-v0.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

0
shell/g1tag.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

2
shell/good.nodes.txt Normal file → Executable file
View File

@ -2,5 +2,3 @@ duniter.moul.re:443
g1.duniter.fr:443 g1.duniter.fr:443
g1.duniter.org:443 g1.duniter.org:443
g1.le-sou.org:443 g1.le-sou.org:443
g1.monnaielibreoccitanie.org:443
g1.presles.fr:443

View File

@ -7,7 +7,14 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/.install/.GPATH if [[ -f $MY_PATH/.profile ]]; then
source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS # Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
function log () { function log () {

View File

@ -23,8 +23,8 @@ export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
# GET SWARM KEY G1sms+ .ipfs/swarm.key # GET SWARM KEY G1sms+ .ipfs/swarm.key
# export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1) export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
# if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
################################################################## ##################################################################
# G1sms+ Swarm KEYS # G1sms+ Swarm KEYS
@ -40,7 +40,7 @@ if [[ ! -e "./g1sms.preoni.pub.key" && -f "./g1sms.priv.key" ]]; then
log "__SUB:initkeys.sh: Linking preoni Keys to SWARM G1 Keys" log "__SUB:initkeys.sh: Linking preoni Keys to SWARM G1 Keys"
ln -s ./g1sms.priv.key ./g1sms.preoni.priv.key ln -s ./g1sms.priv.key ./g1sms.preoni.priv.key
ln -s ./g1sms.pub.key ./g1sms.preoni.pub.key ln -s ./g1sms.pub.key ./g1sms.preoni.pub.key
elif [[ ! -f ./g1sms.preoni.priv.key ]]; then else
# CREATE NODE G1 KEYS AND FILES # CREATE NODE G1 KEYS AND FILES
mkdir -p ./wallets/.$IPFSNODEID/TASK mkdir -p ./wallets/.$IPFSNODEID/TASK
################################################ ################################################
@ -49,12 +49,11 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
################################################ ################################################
# 4 derniers chiffres du MASTERPHONE + diceware # 4 derniers chiffres du MASTERPHONE + diceware
PRE=${MASTERPHONE:8:4} PRE=${MASTERPHONE:8:4}
ZUID=$(./shell/diceware.sh 1 | xargs) UID=$(./shell/diceware.sh 1 | xargs)
# Check if already existing among all swarm wallets # Check if already existing among all swarm wallets
while [[ $(grep -Rwl "$PRE$ZUID" ./wallets_swarm/.*/_uidna) ]]; do ZUID=$(./shell/diceware.sh 1 | xargs); done while [[ $(grep -Rwl "$PRE$UID" ./wallets_swarm/.*/_uidna) ]]; do UID=$(./shell/diceware.sh 1 | xargs); done
NODE_UIDNA="$PRE$ZUID" NODE_UIDNA="$PRE$UID"
NODE_PIN=$(./shell/diceware.sh | xargs) NODE_PIN=$(./shell/diceware.sh | xargs)
NODE_G1PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN") 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 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..." log "__SUB:initkeys.sh: NODE G1WALLET CESIUM: $NODE_UIDNA / $NODE_PIN CREATED..."
@ -68,14 +67,14 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
echo $NODE_UIDNA > "/etc/hostname" echo $NODE_UIDNA > "/etc/hostname"
############################################################ ############################################################
# BACKUP AUTHFILE FOR FOR SWARM USE (TODO: Refine Swarm, Node access): GIVES SMARM WITHDRAW ACTION # 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" ./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "./wallets/.$IPFSNODEID/_authfile.swarm.crypt"
echo $NODE_G1PUBKEY > "./wallets/.$IPFSNODEID/_pub" ################# _pub echo $NODE_G1PUBKEY > "./wallets/.$IPFSNODEID/_pub" ################# _pub
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/_ipfsid" ################# _ipfsid echo $IPFSNODEID > "./wallets/.$IPFSNODEID/_ipfsid" ################# _ipfsid
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY " log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY "
# BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt : GIVES SMARM NODE RESTORE ACTION # BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/_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" log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ./wallets/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
@ -89,19 +88,19 @@ elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
echo $NANODATE > "./wallets/.$IPFSNODEID/_nanodate" ################# _nanodate echo $NANODATE > "./wallets/.$IPFSNODEID/_nanodate" ################# _nanodate
# SILKAJ INIT G1 NODE WALLET # SILKAJ INIT G1 NODE WALLET
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=3.24 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID" -y) 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="$NODE_UIDNA" -password="$NODE_PIN" --amount=0.1 --output=$SWARM_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_UIDNA $IPFSNODEID:ACK" -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+ $NODE_UIDNA : ls ./wallets/.$IPFSNODEID" log "__SUB:initkeys.sh: [ADMIN] NODE G1sms+ $UIDNA : ls ./wallet/.$IPFSNODEID"
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ NODE $NODE_UIDNA ($IPFSNODEID)" 1>&2 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 gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODE_G1PUBKEY" 1>&2
# CREATE preoni FILES # CREATE preoni FILES
mv ./authfile ./g1sms.preoni.priv.key mv ./authfile ./g1sms.preoni.priv.key
echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key
fi fi
NODE_UIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
## INIT NODE G1 PUB & PRIV KEY ## INIT NODE G1 PUB & PRIV KEY
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key") NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key" NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"

View File

@ -42,7 +42,7 @@ for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do
echo $secret $salt echo $secret $salt
echo "/usr/local/bin/silkaj tx --amount=\"$virement\" --output=\"$dest\"" echo "/usr/local/bin/silkaj tx --amount=\"$virement\" --output=\"$dest\""
if [[ "$virement" == "0.0" ]]; then if [[ "$solde" == "0.0" ]]; then
echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result; echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result;
else else
PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y) PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y)

0
shell/nodes.txt Normal file → Executable file
View File

View File

@ -9,4 +9,4 @@ fi
if [[ ! -f "/tmp/$lang_${f}.wav" ]]; then if [[ ! -f "/tmp/$lang_${f}.wav" ]]; then
pico2wave -l $lang -w /tmp/$lang_${f}.wav "$1" pico2wave -l $lang -w /tmp/$lang_${f}.wav "$1"
fi fi
aplay -q /tmp/$lang_${f}.wav aplay -q /tmp/$lang_${f}.wav

View File

@ -4,27 +4,41 @@
# Version: 0.1 # Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################ ################################################################################
source ./shell/init.sh MY_PATH="`dirname \"$0\"`" # relative
source ./shell/functions.sh MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [[ -f $MY_PATH/.profile ]]; then
source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
#source $GPATH/shell/tata.sh || echo "pas trouvé"
source $GPATH/shell/init.sh
source $GPATH/shell/functions.sh
[[ $1 == "chat" ]] && echo "Bonjours chat" && exit 0
log "X sms_AIDE.sh ($1=phone)" log "X sms_AIDE.sh ($1=phone)"
sms_INIT_ACCOUNT "$1" "NOSMS" sms_INIT_ACCOUNT "$1" "NOSMS"
MESS="[Aide] MESS="N Pseudo : Création Portefeuille rattaché à Pseudo
N Pseudo (membre ou nom de portefeuille) : Création portefeuille S : Synchro Solde
P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn
U G1/DU/LOVE : Unité U G1/DU/LOVE : Unité
S : Solde "
P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn"
# Send response SMS # Send response SMS
sms_SEND "$1" "$MESS" sms_SEND "$1" "$MESS"
MESS="EMAIL moi@email : Indiquer son email MESS="EMAIL moi@email : Email pour commande G1Billets
VIR 50 Pseudo : Virer 50 à Pseudo (membre ou Portefeuille SMS)" BILL n : Recevoir 6 G1Billets remplis de n LOVE"
sms_SEND "$1" "$MESS" sms_SEND "$1" "$MESS"
MESS="REC 50 Dest S 4 : Virer 50 à Dest pendant 4 Semaines (J/S/M/A) MESS="VIR 50 Pseudo : Virer 50 à Pseudo (membre ou Portefeuille SMS)
BILL n : Recevoir 6 G1Billets remplis de n LOVE par email! REC 50 Dest S 4 : Virer 50 à Dest, 4 Semaines (J/S/M/A)
https://g1sms.fr - $ADMINPSEUDO ($ADMINPHONE)" Contact : $ADMINPSEUDO ($ADMINPHONE) - https://g1sms.fr"
sms_SEND "$1" "$MESS" sms_SEND "$1" "$MESS"
log "END sms_AIDE.sh" log "END sms_AIDE.sh"

View File

@ -54,7 +54,7 @@ amount=$(bc <<< "$NBbillets * $VALbillet")
VIR=$(bc -l <<< "scale=2; $amount * $DUFACTOR / 100") VIR=$(bc -l <<< "scale=2; $amount * $DUFACTOR / 100")
# Need at least $MIN G1 available! $BILLCOM G1 commission # Need at least $MIN G1 available! $BILLCOM G1 commission
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - $BILLCOM") MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - 21")
testmin=$( echo "${VIR} < ${MIN}" | bc -l ) testmin=$( echo "${VIR} < ${MIN}" | bc -l )
log "__SUB:sms_BILLET.sh: TEST : $VIR < $MIN ? $testmin" log "__SUB:sms_BILLET.sh: TEST : $VIR < $MIN ? $testmin"
@ -82,23 +82,26 @@ then
SECRET=$(./shell/diceware.sh 4 | xargs) 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") boucle=$(bc -l <<< "$boucle + 1")
log "__SUB:sms_BILLET.sh: ->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT" log "__SUB:sms_BILLET.sh: ->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT"
# CREATE "NUMBER SECRET" ACCOUNT for G1 transfert # CREATE "NUMBER SECRET SALT" ACCOUNT for G1 transfert
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets") TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET") BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET$SALT")
# COPY authfile for Usage in 6 month... # COPY authfile for easier usage in 6 month...
log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.GPGPASS.gpg" log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.GPGPASS.gpg"
mkdir -p "./billets/$bpath" mkdir -p "./billets/$bpath"
echo "${GPGPASS}" | gpg -q --output "./billets/$bpath/note.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile" 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" rm -f "./authfile"
log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY" log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY"
sleep 3 sleep 3
# Fill BILLET with TRANSAC amount # Fill BILLET with TRANSAC amount
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y) PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
# NOTES ARE FILES STORED IN DICEWARE COMPOSED SUBDIR # NOTES ARE FILES STORED IN DICEWARE COMPOSED SUBDIR
echo "$(date +%Y%m%d)" > "./billets/$bpath/note.creationdate" echo "$(date +%Y%m%d)" > "./billets/$bpath/note.creationdate"
@ -107,6 +110,7 @@ then
echo "$NUMBER" > "./billets/$bpath/note.number" echo "$NUMBER" > "./billets/$bpath/note.number"
echo "$PHONE" > "./billets/$bpath/note.phone" echo "$PHONE" > "./billets/$bpath/note.phone"
echo "$SECRET" > "./billets/$bpath/note.secret" echo "$SECRET" > "./billets/$bpath/note.secret"
echo "$SALT" > "./billets/$bpath/note.salt"
echo "$VALbillet" > "./billets/$bpath/note.love" echo "$VALbillet" > "./billets/$bpath/note.love"
echo "$TRANSAC" > "./billets/$bpath/note.g1" echo "$TRANSAC" > "./billets/$bpath/note.g1"
echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey" echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey"
@ -118,10 +122,10 @@ then
# Transaction to create Link BILLET <-> MEMBER RIB => Decrease BILLET value ! # Transaction to create Link BILLET <-> MEMBER RIB => Decrease BILLET value !
sleep 2 sleep 2
# 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) # 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)
else else
sms_ERROR "$PHONE" "Un problème est survenu. Contactez $ADMINPSEUDO au $ADMINPHONE" sms_ERROR "$PHONE" "Un problème est survenu. Contactez $ADMINPSEUDO au $ADMINPHONE"
# Copy & Send produced files # Copy & Send produiced files
zip /tmp/$PHONE_Bills_$bpath.zip ./billets/MEMBERS/$MEMBER/*.* 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....." 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....."
@ -132,7 +136,7 @@ then
# + G1SMS Commission # + G1SMS Commission
sleep 2 sleep 2
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y) COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y)
# POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;) # POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;)
num=$(date +%Y%m%d) num=$(date +%Y%m%d)
@ -147,9 +151,9 @@ then
Envoyez-nous vos remarques... Envoyez-nous vos remarques...
https://g1sms.fr" > /tmp/message_body.txt 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....." 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 " log "__SUB:sms_BILLET.sh: G1Billets $PHONE_Bills_$bpath.pdf envoyé par email à $MEMBER : $MAIL "
mess="[G1SMS] mess="[G1SMS]
$NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) créé(s). $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) créé(s).

View File

@ -21,7 +21,7 @@ then
UNIT=$(cat "./billets/$bpath/note.unit") UNIT=$(cat "./billets/$bpath/note.unit")
BILLETPUBKEY=$(cat "./billets/$bpath/note.pubkey") BILLETPUBKEY=$(cat "./billets/$bpath/note.pubkey")
AMOUNTG1=$(./silkaj/silkaj -p g1.presles.fr:443 amount "$BILLETPUBKEY") AMOUNTG1=$(./silkaj/silkaj amount "$BILLETPUBKEY")
log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY" log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY"
# NO GOOD SECRET # NO GOOD SECRET
@ -41,8 +41,8 @@ https://www.g1sms.fr/contact"
# Account creation # Account creation
sms_INIT_ACCOUNT "$PHONE" sms_INIT_ACCOUNT "$PHONE"
fi fi
log "./silkaj/silkaj transaction -p g1.presles.fr:443 --auth-scrypt -salt=\"$CODE\" -password=\"$SEC$SALT\" --amount=\"$AMOUNTG1\" --output=\"$PUBKEY\" --comment=\"THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:ENCAISSEMENT:$CODE\" -y" log "./silkaj/silkaj transaction --auth-scrypt -salt=\"$CODE\" -password=\"$SEC$SALT\" --amount=\"$AMOUNTG1\" --output=\"$PUBKEY\" --comment=\"THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:ENCAISSEMENT:$CODE\" -y"
PAY=$(./silkaj/silkaj transaction -p g1.presles.fr:443 --auth-scrypt -salt="$CODE" -password="$SEC$SALT" --amount="$AMOUNTG1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:ENCAISSEMENT:$CODE" -y) PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC$SALT" --amount="$AMOUNTG1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:ENCAISSEMENT:$CODE" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
# DESTROY BILLET # DESTROY BILLET

View File

@ -12,10 +12,10 @@ PHONE="$1"
MEMBERUID="$2" MEMBERUID="$2"
TODAY=$(date '+%Y%m%d') TODAY=$(date '+%Y%m%d')
if [[ -f "./wallets/$PHONE/VIREMENTS" ]]; then if [[ -f "./wallets/PHONE/$PHONE/VIREMENTS" ]]; then
# CHECK IF ALL DONE. # CHECK IF ALL DONE.
log "__SUB:sms_DESTROY.sh: FOUND "./wallets/$PHONE/VIREMENTS" decrypting with Node key" log "__SUB:sms_DESTROY.sh: FOUND "./wallets/PHONE/$PHONE/VIREMENTS" decrypting with Node key"
echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "./wallets/$PHONE/VIREMENTS.gpg" echo "${GPGPASS}" | gpg -d -q --output "/tmp/VIREMENTS.$PHONE" --yes --pinentry-mode loopback --passphrase-fd 0 "./wallets/PHONE/$PHONE/VIREMENTS.gpg"
for next in $(cat /tmp/VIREMENTS.$PHONE | cut -d ' ' -f 1); do for next in $(cat /tmp/VIREMENTS.$PHONE | cut -d ' ' -f 1); do
if [[ $next -ge $TODAY ]]; then if [[ $next -ge $TODAY ]]; then
log "__SUB:sms_DESTROY.sh: VIREMENT $next >= $TODAY" log "__SUB:sms_DESTROY.sh: VIREMENT $next >= $TODAY"
@ -36,9 +36,9 @@ if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]
AMOUNTG1=$(./silkaj/silkaj amount "$PUBKEY") AMOUNTG1=$(./silkaj/silkaj amount "$PUBKEY")
GETLIMIT=$(bc <<< "$AMOUNTG1 - $LIMIT") GETLIMIT=$(bc <<< "$AMOUNTG1 - $LIMIT")
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$GETLIMIT" --output="$MEMRIB" --comment="[G1sms+] Wallet DESTROY $MEMBER $MEMBERUID" -y) PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$GETLIMIT" --output="$MEMRIB" --comment="[G1sms+] Wallet DESTROY $MEMBER $MEMBERUID" -y)
sleep 5 sleep 5
back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$LIMIT" --output="$NODEPUB" --comment="[G1sms+] Wallet DESTROY Send $LIMIT To NODE" -y) back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$LIMIT" --output="$NODEPUB" --comment="[G1sms+] Wallet DESTROY Send $LIMIT To NODE" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" && "$(echo $back | cut -d '|' -f 1)" != "KO" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" && "$(echo $back | cut -d '|' -f 1)" != "KO" ]]; then
# DESTROY FILESYSTEM AND G1sms WALLET SWARM REFERENCE # DESTROY FILESYSTEM AND G1sms WALLET SWARM REFERENCE
@ -54,8 +54,8 @@ $ADMINPSEUDO @ $NODEUIDNA
$back" $back"
sms_SEND "$PHONE" "$mess" sms_SEND "$PHONE" "$mess"
rm -Rf ./wallets/$PHONE; rm -Rf ./wallets/PHONE/$PHONE;
rm -Rf ./wallets_swarm/$PHONE; rm -Rf ./wallets_swarm/PHONE/$HASHLINK;
cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1) cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1)
move_g1cents "$PHONE" "$MEMRIB" "$cents" move_g1cents "$PHONE" "$MEMRIB" "$cents"
cents=$(echo $(bc -l <<< "scale=0; $LIMIT * 100") | cut -d '.' -f 1) cents=$(echo $(bc -l <<< "scale=0; $LIMIT * 100") | cut -d '.' -f 1)

View File

@ -16,7 +16,7 @@ log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
phone="$1" phone="$1"
mail="$2" mail="$2"
MAILFILE="./wallets/$phone/$phone.email" # Contains the member EMAIL (Send BILLET) MAILFILE="./wallets/PHONE/$phone/_email" # Contains the member EMAIL (Send BILLET)
# Initialise PHONE, PIN, PUBKEY, UNIT ... # Initialise PHONE, PIN, PUBKEY, UNIT ...
sms_INIT_ACCOUNT "$phone" "NOSMS" sms_INIT_ACCOUNT "$phone" "NOSMS"
@ -27,6 +27,7 @@ Envoyez N suivi de votre pseudo membre (en respectant Majuscule et minuscule)."
fi fi
if [[ "$mail" != "" ]]; then if [[ "$mail" != "" ]]; then
# STORE EMAIL AND NODE CYPHER IT BEFORE PUSH TO IPFS
echo "$mail" > "$MAILFILE" echo "$mail" > "$MAILFILE"
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt" ./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt"
echo "" > "$MAILFILE" echo "" > "$MAILFILE"
@ -37,11 +38,9 @@ else
fi fi
# SEND EMAIL WITH ssmtp # SEND EMAIL WITH ssmtp
SUBJECT="[G1sms+] $MEMBER, Message de votre portefeuille monnaie libre $UIDNA ($PHONE)" 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)" 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+"
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail} cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
mpack -s "[G1sms+] $PHONE, $UIDNA :: Envoyer 'BILL nnn' à $MASTERPHONE pour fabriquer des G1Billets (ci-joint exemple de verso)" ./Dos_G1Billets.odt ${mail}
log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp" log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp"
log_history $PHONE "EMAIL, $mail" log_history $PHONE "EMAIL, $mail"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
################################################################################ ################################################################################
# Author: Fred (support@qo-op.com) # Author: Fred (support@qo-op.com)
# Version: 0.2020 # Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################################### ###########################################################################################
# == G1tag == # == G1tag ==
@ -15,7 +15,6 @@
# TAG 250 => Imprime un G1Tag rempli de 250 UNIT # TAG 250 => Imprime un G1Tag rempli de 250 UNIT
# TAG 2 100 => Imprime 100 G1Tag BON de 2 UNIT # TAG 2 100 => Imprime 100 G1Tag BON de 2 UNIT
# PHONE any ./wallets/IDs # PHONE any ./wallets/IDs
# TODO: for multi-channel -> Use HASHLINK + UIDNA + NODE_UIDNA + AMOUNT ...
########################################################################################### ###########################################################################################
source ./shell/init.sh source ./shell/init.sh
source ./shell/functions.sh source ./shell/functions.sh
@ -49,12 +48,19 @@ if [[ $UNKNOWN == "unknown" ]]; then
exit exit
fi 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 # CALCULATE if wallet have enough for VIR+PERCENT
AMOUNT=$2 # BE CAREFULL AMOUNT was changed by 1st sms_INIT_ACCOUNT!! AMOUNT=$2 # AMOUNT was changed by sms_INIT_ACCOUNT call !!
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then
# MULTI TAG NUMBER ($NUMBER = How many tags to print) # MULTI TAG NUMBER ($NUMBER = How many tags to print (with different R but same B)
AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER") AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER")
else else
NUMBER=1 NUMBER=1
@ -67,16 +73,16 @@ VIR=${accounting[1]}
PERCENT=${accounting[2]} PERCENT=${accounting[2]}
CHARGE=${accounting[3]} CHARGE=${accounting[3]}
if [[ $testmin -eq 0 ]]; then if [[ $testmin -eq 0 ]]; then
sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} + ${PERCENT} (+ ${LIMIT}) G1! Rechargez avec https://cesium.app" sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} G1! Rechargez avec https://cesium.app "
exit exit
fi fi
##### IS G1DAB NODE? ##### IS G1DAB NODE?
if [[ ! $PASSENGER && ! $G1DAB ]]; then if [[ ! $PASSENGER && ! $G1DAB ]]; then
if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then if [[ -f ./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid ]]; then
DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE) DABnode=$(cat ./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid)
if [[ "$DABnode" == "$IPFSNODEID" ]]; then if [[ "$DABnode" == "$IPFSNODEID" ]]; then
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag sur $DABnode non détectée!! Choisissez un autre G1Dab..." sms_ERROR "$PHONE" "IMPRIMANTE G1Tag non détectée!! Choisissez un autre G1Dab... $spot"
log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!" log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!"
exit exit
fi fi
@ -94,9 +100,9 @@ fi
########################################### ###########################################
# PAY VIR + PERCENT G1 # PAY VIR + PERCENT G1
ML=$(bc -l <<< "scale=2; $VIR + $PERCENT") 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) PAY=$(./shell/timeout.sh -t 29 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -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 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"; sms_ERROR "$PHONE" "Il est survenu un problème lors de votre virement: $PAY / Silkaj: $new";
exit exit
else else
@ -113,8 +119,8 @@ while [[ $c -lt $NUMBER ]]; do
AA=$(./shell/diceware.sh 6 | xargs); # Nom = Diceware de 6 mots AA=$(./shell/diceware.sh 6 | xargs); # Nom = Diceware de 6 mots
RR=$(echo ${AA} | sed s/\ //g ); # Nom concaténé RR=$(echo ${AA} | sed s/\ //g ); # Nom concaténé
PR=$(echo ${AA} | cut -d ' ' -f 1 ); # Prénom du G1Tag PR=$(echo ${AA} | cut -d ' ' -f 1 ); # Prénom du G1Tag
# Create Unique G1tag in all SWARM! # Create Unique G1tag!
while [[ $(ls ./wallets_swarm/.Qm*/TAG/${RR}) ]]; do 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 ); AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g ); PR=$(echo ${AA} | cut -d ' ' -f 1 );
done done
# Clef de chiffrage PGP imprimée sur le QRCode BJ # Clef de chiffrage PGP imprimée sur le QRCode BJ
@ -124,32 +130,27 @@ while [[ $c -lt $NUMBER ]]; do
# G1Tag init : Nom et usage des fichiers du G1Tag # G1Tag init : Nom et usage des fichiers du G1Tag
# TODO CHECK _nanodate to detect bad nodes/tx behaviour... and banish them) # 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 TAGDATE="./TAG/${RR}/TAG_nanodate" # Nanodate notification (ntpdate in init.sh for NODE sync in case of
TAGNODEID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag TAGNID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
TAGID="./TAG/${RR}/TAG_id" #Nom du TAG 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) TAGCURRENCY="./TAG/${RR}/TAG_currency" # ZEN (0.01 G1)
TAGAMOUNT="./TAG/${RR}/TAG_amount" # Tag amount. It is! TAGAMOUNT="./TAG/${RR}/TAG_amount" # Tag amount. It is!
TAGTYPE="./TAG/${RR}/TAG_type" # G1 Tag type TAGTYPE="./TAG/${RR}/TAG_type" # G1 Tag type
TAGPASSENGER="./TAG/${RR}/TAG_passenger" # Reference to G1Tag owner/counter put in "./wallets/.$IPFSNODEID/TAG/${J}" 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}" ... # ... GESTION DE LA CLEF DE PUBLICATION IPNS ".ipfs/keystore/${RR}" ...
TAGPUBLISH_B_GPG="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B PGP cyphered TAGBKEY="./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 TAGG1smsWKEY="./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 TAGSWARMKEY="./TAG/${RR}/TAG_publishkey.MASTER.crypt" # natools.py crypt with creator 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 TAGIPNS="./TAG/${RR}/TAG_ipns" # /ipns/Qm... link to last G1Tag version
TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# WRITE MULTITAG FILES with AMOUNT # WRITE MULTITAG FILES with AMOUNT
mkdir -p ./TAG/${RR} 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: MEMRIB: $MEMRIB"
log "__SUB:sms_G1TAG.sh: A: ${AA}" log "__SUB:sms_G1TAG.sh: A: ${AA}"
log "__SUB:sms_G1TAG.sh: B: ${BB}" 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"
#################### ####################
#################################################### ####################################################
@ -159,7 +160,7 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
echo "${AA}" > "$TAGID" echo "${AA}" > "$TAGID"
echo "0" > "$TAGN" echo "0" > "$TAGN"
echo "${NANODATE}" > "$TAGDATE" echo "${NANODATE}" > "$TAGDATE"
echo "${IPFSNODEID}" > "$TAGNODEID" echo "${IPFSNODEID}" > "$TAGNID"
echo "${TYPE}" > "$TAGTYPE" echo "${TYPE}" > "$TAGTYPE"
echo "ZEN" > "$TAGCURRENCY" echo "ZEN" > "$TAGCURRENCY"
@ -171,19 +172,15 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
su $YOU -c "ipfs key gen -t rsa -s 2048 ${RR}" su $YOU -c "ipfs key gen -t rsa -s 2048 ${RR}"
fi fi
# TODO: Regulate G1Tag Access to LostSecret OR PHONE ./wallets Pubkey OR SWARM G1 KEY
# GIVE QRCODE BJ ACCESS TO G1TAG # GIVE QRCODE BJ ACCESS TO G1TAG
# Enregistrement de la clef de publication IPNS du wallet ${R} cryptée par B # Enregistrement de la clef de publication IPNS du wallet ${R} cryptée par B
echo "${BB}" | gpg -q --output "$TAGPUBLISH_B_GPG" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}" 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
# 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. # 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 "$TAGPUBLISH_PHONE_CRYPT" ./shell/natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGG1smsWKEY"
# 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 # GIVE SWARM ACCESS TO ZEN TAG
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_SWARM_CRYPT" ./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGSWARMKEY"
########################################################### ###########################################################
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING # TAG IPFS STORAGE & G1Tag IPNS PUBLISHING
@ -200,15 +197,13 @@ 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) # KEEP G1Tag J MEMORY in NODE ./wallets/.$IPFSNODEID/TAG/ (TODO: OPTIMIZE SWARM SYNC and REPUBLISH)
mkdir -p "./wallets/.$IPFSNODEID/TAG/" mkdir -p "./wallets/.$IPFSNODEID/TAG/"
# WRITE PASSENGER to J Link (G1Tag is stick to it: PHONE, NODE, FILE ) # WRITE PASSENGER to J Link (G1Tag is stick to it: PHONE, NODE, FILE )
# TODO USE SHA256 ID !!!
echo "$PHONE" > "./wallets/.$IPFSNODEID/TAG/${J}" echo "$PHONE" > "./wallets/.$IPFSNODEID/TAG/${J}"
if [[ $PASSENGER ]]; then if [[ $PASSENGER ]]; then
HPASSENGER=$(echo -n $PASSENGER | sha256sum | cut -d ' ' -f 1) echo "$PASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
echo "$HPASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
fi fi
########################################################### ###########################################################
log "__SUB:sms_G1TAG.sh: TAG: ipfs ls /ipns/${J}" log "__SUB:sms_G1TAG.sh: TAG: ipfs ls /ipns/$(cat $TAGIPNS)"
if [[ ! $PASSENGER ]]; then if [[ ! $PASSENGER ]]; then
# QR CODE LECTURE # QR CODE LECTURE
qrencode -s 5 -o "./TAG/${RR}/TAG_READ.png" "RJ:${RR}#${J}" qrencode -s 5 -o "./TAG/${RR}/TAG_READ.png" "RJ:${RR}#${J}"
@ -220,19 +215,18 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# COMPOSE G1TAG PRINT + TAG_READ.png + TAG_WRITE.png # COMPOSE G1TAG PRINT + TAG_READ.png + TAG_WRITE.png
composite -compose Over -resize 133% -gravity West "./TAG/${RR}/TAG_READ.png" "./shell/g1tag.png" "./TAG/${RR}/${RR}.png" composite -compose Over -resize 133% -gravity West "./TAG/${RR}/TAG_READ.png" "./shell/g1tag.png" "./TAG/${RR}/${RR}.png"
composite -compose Over -gravity SouthEast "./TAG/${RR}/TAG_WRITE.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" composite -compose Over -gravity SouthEast "./TAG/${RR}/TAG_WRITE.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
# ADD Avatar in the Center # ADD Avatar in the Center
# if [[ $(file "./wallets/$PHONE/$PHONE.avatar.png" | grep 'PNG') ]]; then # if [[ $(file "./wallets/PHONE/$PHONE/_avatar.png" | grep 'PNG') ]]; then
# composite -compose Over -resize 150% -gravity Center "./wallets/$PHONE/$PHONE.avatar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" # composite -compose Over -resize 150% -gravity Center "./wallets/PHONE/$PHONE/_avatar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
# else # else
# composite -compose Over -resize 100% -gravity Center "./shell/G1Anar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" # composite -compose Over -resize 100% -gravity Center "./shell/G1Anar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
# fi # fi
# WRITE G1Tag G1 amount
convert -pointsize 60 -fill black -gravity Center -draw 'text 0,-100 "'"$2"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"; # if [[ $NUMBER -ne 1 ]]; then
convert -pointsize 60 -fill black -gravity Center -draw 'text 0,-100 "'"$2"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png";
# fi
convert -pointsize 40 -fill black -gravity NorthEast -draw 'text 80,0 "'"${PR}"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" convert -pointsize 40 -fill black -gravity NorthEast -draw 'text 80,0 "'"${PR}"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
# WRITE G1Tag RR # WRITE G1Tag RR
convert -pointsize 40 -fill black -gravity SouthWest -draw 'text 3,0 "'"${RR}"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png" convert -pointsize 40 -fill black -gravity SouthWest -draw 'text 3,0 "'"${RR}"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
@ -240,24 +234,23 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
# ROTATION (FIXE AVATAR & CHIFFRE)? # ROTATION (FIXE AVATAR & CHIFFRE)?
# convert "./TAG/${RR}/${RR}.png" -rotate -180 "./TAG/${RR}/${RR}.png" # convert "./TAG/${RR}/${RR}.png" -rotate -180 "./TAG/${RR}/${RR}.png"
# QL-700 PRINT PREPARE # QL-700 PRINT PREPARE
if [[ -f "./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid" ]]; then
if [[ -f "./wallets/$PHONE/ipfsid.G1TAGNODE" ]]; then destnode=$(cat "./wallets/PHONE/$PHONE/MASTERPHONE.ipfsid")
destnode=$(cat "./wallets/$PHONE/ipfsid.G1TAGNODE")
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
log "__SUB:sms_G1TAG.sh: Local PRINT ${RR} # ipfs ls /ipns/${J}" log "__SUB:sms_G1TAG.sh: Local PRINT ${RR} # ipfs ls /ipns/${J}"
brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin" brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin"
brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0 brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0
else else
# PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer TODO: Could use DESTNODEPUB instead of NODE_G1PUBKEY ? # PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer Use .$destnode/_pub CRYPTINGKEY ?
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin " CRYPTINGKEY=$(cat ./wallets_swarm/.$destnode/_pub)
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.png.node.crypt ($CRYPTINGKEY)"
mkdir -p "./wallets/.$destnode/PRINT/" mkdir -p "./wallets/.$destnode/PRINT/"
# TODO: USE $DEST_G1PUBKEY is better ./shell/natools.py encrypt -p $CRYPTINGKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.png.node.crypt"
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin"
fi fi
else else
# #
log "__SUB:sms_G1TAG.sh: Becoming default PRINTER :: $IPFSNODEID" log "__SUB:sms_G1TAG.sh: Becoming default PRINTER :: $IPFSNODEID"
echo "$IPFSNODEID" > "./wallets/$PHONE/ipfsid.G1TAGNODE" echo "$IPFSNODEID" > "./wallets/PHONE/$PHONE/ipfsid.G1TAGNODE"
brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin" brother_ql_create --model QL-700 "./TAG/${RR}/${RR}.png" --label-size 62 > "./TAG/${RR}/${RR}.bin"
brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0 brother_ql_print "./TAG/${RR}/${RR}.bin" /dev/usb/lp0
destnode="$IPFSNODEID" destnode="$IPFSNODEID"
@ -265,18 +258,16 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
fi fi
done done
####################################################
# PRINT $PHONE WALLET PUBKEY
####################################################
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)" # 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" composite -compose Over -gravity West "/tmp/G1PubQR.$PHONE.png" "./shell/g1tag.png" "/tmp/G1PubQR.$PHONE.png"
if [[ $(file "./wallets/$PHONE/$PHONE.avatar.png" | grep 'PNG') ]]; then if [[ $(file "./wallets/PHONE/$PHONE/_avatar.png" | grep 'PNG') ]]; then
composite -compose Over -gravity Center "./wallets/$PHONE/$PHONE.avatar.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" composite -compose Over -gravity Center "./wallets/PHONE/$PHONE/_avatar.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
fi fi
if [[ -f ./wallets/$PHONE/$PHONE.uidrib ]]; then if [[ -f ./wallets/PHONE/$PHONE/_uidrib ]]; then
qrencode -s 6 -o "/tmp/G1MemQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.uidrib)"; qrencode -s 6 -o "/tmp/G1MemQR.$PHONE.png" "$(cat ./wallets/PHONE/$PHONE/_uidrib)";
composite -compose Over -gravity SouthEast "/tmp/G1MemQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" && rm /tmp/G1MemQR.$PHONE.png composite -compose Over -gravity SouthEast "/tmp/G1MemQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png" && rm /tmp/G1MemQR.$PHONE.png
fi fi

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
################################################################################ ################################################################################
# Author: Fred (support@qo-op.com) # Author: Fred (support@qo-op.com)
# Version: 0.1 # Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################ ################################################################################
# CREATE NEW G1 ./wallets/PHONE/sha256_ID ACCOUNT
source ./shell/init.sh source ./shell/init.sh
source ./shell/functions.sh source ./shell/functions.sh
log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_" log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_"
@ -16,11 +17,14 @@ sms_INIT_ACCOUNT "$PHONE"
if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then
# UID RECEIVED in SMS # UID RECEIVED in SMS
VIRDEST=$MEMBERUID VIRDEST=$MEMBERUID
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN") # GET ASSOCIATED MEMBER OR UIDNA G1 PUB KEY
MEMRIB=$(sms_uid2pubkey "$MEMBERUID" "$PHONE" "$PIN")
# No related wallet found
if [[ $MEMRIB == "" ]]; then exit; fi if [[ $MEMRIB == "" ]]; then exit; fi
MEMBER="$MEMBERUID" MEMBER="$MEMBERUID"
fi fi
# TODO Replace "NOSMS" mode with .profile READ, or similar...
sms_INIT_ACCOUNT "$PHONE" "NOSMS" sms_INIT_ACCOUNT "$PHONE" "NOSMS"
# Check account amount # Check account amount
countvalues=($(check_account)) countvalues=($(check_account))
@ -29,26 +33,19 @@ AMOUNTG1=${countvalues[0]}
AMOUNT=${countvalues[1]} AMOUNT=${countvalues[1]}
UNIT=${countvalues[2]} UNIT=${countvalues[2]}
mess="[G1sms+] mess="[G1sms+] Portefeuille G1
Id: $UIDNA $UIDNA
Solde: $AMOUNT $UNIT $PIN
DAB: $DABID
--- ---
https://cesium.app Solde: $AMOUNT $UNIT
* Identifiant =" https://cesium.app"
sms_SEND "$PHONE" "$mess" sms_SEND "$PHONE" "$mess"
sleep 2 sleep 2
sms_SEND "$PHONE" "$PHONE" sms_SEND "$PHONE" "* Clef Publique G1 (RIB) ="
sleep 2
sms_SEND "$PHONE" "* Mot de passe ="
sleep 2
sms_SEND "$PHONE" "$PIN"
sleep 2
sms_SEND "$PHONE" "* Clef Publique (RIB) ="
sleep 2 sleep 2
sms_SEND "$PHONE" "$PUBKEY" sms_SEND "$PHONE" "$PUBKEY"
sleep 2 sleep 2
[[ $MEMRIB != "" ]] && sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL [[ $MEMBER || $MAIL ]] && sms_SEND "$PHONE" "Compte relié: $MEMBER $MAIL
$MEMRIB" $MEMRIB"
# Add contact to database # Add contact to database

View File

@ -14,9 +14,12 @@ PHONEDEST="$2"
# Initialise PHONE, PIN, PUBKEY, UNIT # Initialise PHONE, PIN, PUBKEY, UNIT
sms_INIT_ACCOUNT "$phone" "NOSMS" sms_INIT_ACCOUNT "$phone" "NOSMS"
pin=$PIN pin=$PIN
uidna=$UIDNA
if [[ $UNKNOWN == "unknown" ]]; then if [[ $UNKNOWN == "unknown" ]]; then
sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer." sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
exit exit
else
log "PIN: $pin"
fi fi
########################################################### ###########################################################
@ -27,22 +30,24 @@ log "__SUB:sms_PAY.sh: $(declare -p accounting)"
testmin=${accounting[0]} testmin=${accounting[0]}
VIR=${accounting[1]} VIR=${accounting[1]}
PERCENT=${accounting[2]} PERCENT=${accounting[2]}
CHARGE=${accounting[3]}
if [[ $testmin -eq 0 ]]; then if [[ $testmin -eq 0 ]]; then
sms_ERROR "$phone" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum: $CHARGE G1! Rechargez avec https://Cesium.app" sms_ERROR "$phone" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum: $((VIR+PERCENT+LIMIT)) G1! Rechargez avec https://Cesium.app"
exit exit
fi fi
# Add COUNTRY code to PHONEDEST + PHONEDEST INIT # Add COUNTRY code to PHONEDEST + PHONEDEST INIT
PHONEDEST="$COUNTRY${PHONEDEST:1:10}" PHONEDEST="$COUNTRY${PHONEDEST:1:10}"
HASHLINKDEST=$(echo -n $PHONEDEST | sha256sum | cut -d ' ' -f 1)
# CHECK if PHONEDEST have an account in IPFS G1sms+ SWARM # CHECK if PHONEDEST have an account in IPFS G1sms+ SWARM
if [[ -f "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub" ]] if [[ -f "./wallets_swarm/PHONE/$HASHLINKDEST/_pub" ]]
then then
PUBKEYDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.pub") PUBKEYDEST=$(cat "./wallets_swarm/PHONE/$HASHLINKDEST/_pub")
UNITDEST=$(cat "./wallets_swarm/$PHONEDEST/$PHONEDEST.unit") UNITDEST=$(cat "./wallets_swarm/PHONE/$HASHLINKDEST/_unit")
log "__SUB:sms_PAY.sh: PUBKEYDEST found in swarn... $PUBKEYDEST"
else else
# NO, then create NEW Wallet # NO, then create NEW Wallet
log "__SUB:sms_PAY.sh: Creating Account for... $PHONEDEST"
sms_INIT_ACCOUNT "$PHONEDEST" sms_INIT_ACCOUNT "$PHONEDEST"
# Refreshed new values # Refreshed new values
PUBKEYDEST="$PUBKEY" PUBKEYDEST="$PUBKEY"
@ -50,10 +55,13 @@ else
fi fi
# Payement # Payement
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY" -y) log "./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST""
PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY $AMOUNT $UNIT" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $PAY"; sms_ERROR "$phone" "PIN : $PAY ? Voyez vous votre code secret: $pin?
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $PAY" NON, Reinitaliser Compte. Envoyer: RAZ
OUI, Bourage Blockchain. Envoyer: S";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj : $PAY"
exit exit
else else
# OK: Sync g1cents TODO check move_g1cents function and generalize on all silkaj transactions # OK: Sync g1cents TODO check move_g1cents function and generalize on all silkaj transactions
@ -64,11 +72,11 @@ fi
sleep 2 sleep 2
# + G1SMS Commission # + G1SMS Commission
COM=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Commission" -y) log "./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY""
if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then COM=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$uidna" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] P Commission" -y)
new=$(./shell/checknodes.sh "BAN") if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$COM" == "" ]]; then
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $COM"; sms_ERROR "$phone" "Problème de bourrage blockchain : $COM";
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $COM" log "__SUB:sms_PAY.sh: Problème de payement avec silkaj : $COM"
exit exit
else else
# OK: Sync g1cents # OK: Sync g1cents

View File

@ -41,7 +41,7 @@ esac
########################################################### ###########################################################
# Initialise PHONE, PIN, PUBKEY, UNIT # Initialise PHONE, PIN, PUBKEY, UNIT
sms_INIT_ACCOUNT "$PHONE" "NOSMS" sms_INIT_ACCOUNT "$PHONE" "NOSMS"
if [[ $MEMBER == "" ]]; then MEMBER=$UIDNA; fi [[ $MEMBER == "" ]] && MEMBER=$UIDNA # Wallet self UIDNA??
########################################################### ###########################################################
# CHECK FOR ERRORS # CHECK FOR ERRORS
if [[ $UNKNOWN == "unknown" ]]; then if [[ $UNKNOWN == "unknown" ]]; then
@ -79,20 +79,20 @@ else
log "__SUB:sms_REC.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB " log "__SUB:sms_REC.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB "
DESTMEM="$VIRDEST" DESTMEM="$VIRDEST"
# SEARCH IN WALLETS # SEARCH IN WALLETS
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/') LOCALPHONE=$(grep -Rwl "$DESTMEM" ./wallets/PHONE/*/_uidname | tail -n 1 | cut -f 4 -d '/')
if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi [[ ! $LOCALPHONE ]] && LOCALPHONE=$(grep -Rwl "$DESTMEM" ./wallets/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/')
if [[ "$LOCAL" != "" ]]; then if [[ "$LOCALPHONE" != "" ]]; then
# LOCAL G1sms account # LOCALPHONE G1sms account
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub) DESTRIB=$(cat ./wallets/PHONE/$LOCALPHONE/_pub)
DESTPHONE=$LOCAL DESTPHONE=$LOCALPHONE
log "__SUB:sms_REC.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)" log "__SUB:sms_REC.sh: FOUND LOCALPHONE ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCALPHONE)"
else else
# SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA) # SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA)
INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/') INSWARMHASH=$(grep -Rwl "$DESTMEM" ./wallets_swarm/PHONE/*/_uidname | tail -n 1 | cut -f 4 -d '/')
if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi [[ ! $INSWARMHASH ]] && INSWARMHASH=$(grep -Rwl "$DESTMEM" ./wallets_swarm/PHONE/*/_uidna | tail -n 1 | cut -f 4 -d '/')
if [[ "$INSWARM" != "" ]]; then if [[ "$INSWARM" != "" ]]; then
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms) REMOTENODE=$(cat ./wallets_swarm/PHONE/$INSWARM/MASTERPHONE.sms)
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub) DESTRIB=$(cat ./wallets_swarm/PHONE/$INSWARM/_pub)
DESTPHONE=$INSWARM DESTPHONE=$INSWARM
log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)" log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)"
else else
@ -106,7 +106,7 @@ fi
# ADD DATES TO VIREMENTS # ADD DATES TO VIREMENTS
if [[ "$DESTRIB" != "" ]]; then if [[ "$DESTRIB" != "" ]]; then
log "__SUB:sms_REC.sh: TRAITEMENT DU VIREMENT DE $AMOUNT $UNIT = 1ER VIREMENT de $VIR G1 vers $VIRDEST ($DESTRIB) $TIME FOIS. OK..." log "__SUB:sms_REC.sh: TRAITEMENT DU VIREMENT DE $AMOUNT $UNIT = 1ER VIREMENT de $VIR G1 vers $VIRDEST ($DESTRIB) $TIME FOIS. OK..."
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] REC 1/$TIME ($PERIOD)" -y) PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] REC 1/$TIME ($PERIOD)" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
new=$(./shell/checknodes.sh "BAN") new=$(./shell/checknodes.sh "BAN")
sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY"; sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY";

View File

@ -33,7 +33,7 @@ testmin=${accounting[0]}
VIR=${accounting[1]} VIR=${accounting[1]}
PERCENT=${accounting[2]} PERCENT=${accounting[2]}
if [[ $testmin -eq 0 ]]; then if [[ $testmin -eq 0 ]]; then
sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $VIR + $LIMIT G1! Rechargez par Cesium." sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $VIR G1! Rechargez par Cesium."
exit exit
fi fi
@ -73,7 +73,7 @@ else
fi fi
if [[ "$DESTRIB" != "" ]]; then if [[ "$DESTRIB" != "" ]]; then
PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $VIR G1" -y) PAY=$(./shell/timeout.sh -t 30 ./silkaj/silkaj transaction --auth-scrypt -salt="$UIDNA" -password="$PIN" --amount="$VIR" --output="$DESTRIB" --comment="[G1sms+] VIR $VIR G1" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" ]]; then if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" ]]; then
log "__SUB:sms_VIR.sh: VIREMENT VERS $DESTMEM OK" log "__SUB:sms_VIR.sh: VIREMENT VERS $DESTMEM OK"
mess="[G1sms+] $MEMBER mess="[G1sms+] $MEMBER

View File

@ -21,19 +21,19 @@ Envoyez N pour créer votre portefeuille G1sms"
fi fi
if [[ "$askeduidna" == "" ]]; then #SELF if [[ "$askeduidna" == "" ]]; then #SELF
if [[ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna" ]]; then if [[ -f "./wallets/.$IPFSNODEID/_uidna" ]]; then
nodeuidnafile="./wallets/.$IPFSNODEID/$IPFSNODEID.uidna" nodeuidnafile="./wallets/.$IPFSNODEID/_uidna"
uidna=$(cat $nodeuidnafile) uidna=$(cat $nodeuidnafile)
fi fi
else else
nodeuidnafile=$(grep -Rwl "$askeduidna" ./wallets_swarm/.*/*.uidna) nodeuidnafile=$(grep -Rwl "$askeduidna" ./wallets_swarm/.Qm*/_uidna | tail -n 1)
uidna=$(cat $nodeuidnafile) uidna=$(cat $nodeuidnafile)
fi fi
if [[ -f $nodeuidnafile && "$uidna" != "" ]]; then if [[ -f $nodeuidnafile && "$uidna" != "" ]]; then
ipfsnodeid=$(echo $nodeuidnafile | cut -d '/' -f 3 | cut -d '.' -f 2 ) ipfsnodeid=$(echo $nodeuidnafile | cut -d '/' -f 3 | cut -d '.' -f 2 )
echo $uidna > ./wallets/$PHONE/uidna.G1TAGNODE echo $uidna > ./wallets/PHONE/$PHONE/uidna.G1TAGNODE
echo $ipfsnodeid > ./wallets/$PHONE/ipfsid.G1TAGNODE echo $ipfsnodeid > ./wallets/PHONE/$PHONE/ipfsid.G1TAGNODE
log "__SUB:sms_WHERE.sh: Distributeur de G1Tag $uidna : $ipfsnodeid " log "__SUB:sms_WHERE.sh: Distributeur de G1Tag $uidna : $ipfsnodeid "
I=$(ipfs_node_wallets_add) I=$(ipfs_node_wallets_add)
log_history $PHONE "G1TagNode, $uidna, $ipfsnodeid" log_history $PHONE "G1TagNode, $uidna, $ipfsnodeid"
@ -47,7 +47,7 @@ fi
mess="[G1sms+] $MEMBER mess="[G1sms+] $MEMBER
Votre distributeur de G1Tag par défaut est Votre distributeur de G1Tag par défaut est
$uidna ($ipfsnodeid), situé: $uidna ($ipfsnodeid), situé:
$(cat ./wallets_swarm/.$ipfsnodeid/$ipfsnodeid.where)" $(cat ./wallets_swarm/.$ipfsnodeid/_where)"
sms_SEND "$PHONE" "$mess" sms_SEND "$PHONE" "$mess"

View File

@ -15,7 +15,7 @@
# QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n # QmUQcSjQx2bg4cSe2rUZyQi6F8QtJFJb74fWL7D784UWf9 2 TAG_n
# QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate # QmdbdBWv4SygqaaeWHAvABiQAa3faf4ncfSyzRnx8BDdCc 20 TAG_nanodate
# QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid # QmbN6gNM2vjLj7yaJ6xJcySDxmuSK2eB9ZDv5dpj2bo5pM 47 TAG_nodeid
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.swarm.crypt # QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.MASTER.crypt
# QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg # QmWHsRZCTSjSxnp1Qm8WcmHNNQTJwDS2ukLE7NTccc3Kp9 1304 TAG_publishkey.B.gpg
# TAG_passenger, TAG_file is used to attach G1Tag to file. # 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. # 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" 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}/ chown -R $YOU ./TAG/${JSOURCERR}/
su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE" 2>&1 su $YOU -c "ipfs get --output=./TAG/${JSOURCERR}/ /ipns/$JSOURCE" 2>&1
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.crypt" JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.MASTER.crypt"
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount) JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount)
TAGNODEID=$(cat ./TAG/${JSOURCERR}/TAG_nodeid) TAGNODEID=$(cat ./TAG/${JSOURCERR}/TAG_nodeid)
TAGPASSENGER="./TAG/${JSOURCERR}/TAG_passenger" # contains HASH for PASSENGER FILE (CRYPT & PUBLISH) TAGPASSENGER="./TAG/${JSOURCERR}/TAG_passenger" # contains HASH for PASSENGER FILE (CRYPT & PUBLISH)

View File

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

View File

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

View File

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

View File

@ -1,300 +0,0 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
###########################################################################################
###########################################################################################
# Lit les données reçues depuis un lecteur de QR Code branché en USB/SERIE (/dev/ttyACM0)
# Interpète les G1QRcodes et les G1Tag (R/W)
# Saisie du montant à transférer par pavé numérique
###########################################################################################
echo "__SUB:tag_READ_XY.sh: QRCODE READER : START"
function log () {
echo "$line
$1" >> /tmp/tag_READ_XY.log
}
source ./shell/init.sh
source ./shell/functions.sh
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
NODE_UIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
SWARM_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
SWARM_G1AUTHFILE="${GPATH}/g1sms.priv.key"
if [[ ! -f $SWARM_G1AUTHFILE ]]; then echo "ERREUR CLEF DECHIFFRAGE!"; exit; fi
## INIT NODE G1 PUB & PRIV KEY
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"
if [[ ! -e "/dev/ttyACM0" ]]; then echo "Branchez votre lecteur de QR code!"; exit; fi
##############################################
# DOUCHETTE ES TU LA?
./shell/tools/4LETTER.scroll.py "G1TX START"
./shell/tools/4LETTER.clock.py &
clockpid=$!
# TABLEAU MEMOIRE DE SCAN
declare -a act
declare -a obj
declare -a val
cat /dev/ttyACM0 | while read line; do
kill $clockpid
lon=${#line}
pref=$(echo $line | cut -d ":" -f 1)
qrvalue=$(echo $line | cut -d ":" -f 2)
log "__SUB:tag_READ_X.sh: SCAN /dev/ttyACM0 ($lon) :: $line"
case $pref in
RJ)
R=$(echo $qrvalue | cut -d '#' -f 1)
J=$(echo $qrvalue | cut -d '#' -f 2)
log "__SUB:tag_READ_X.sh: Lecture G1Tag $R $J"
# IPFS READ
ID=$(su $YOU -c "ipfs cat /ipns/$J/TAG_id");
if [[ "$ID" == "" ]]; then
./shell/tools/4LETTER.scroll.py ">> BAD G1TAG <<"
continue
fi
# Get First R Tag name word and remove space for RR
FID=$(echo $ID | awk '{print toupper($1)}')
RR=$(echo $ID | sed s/\ //g)
./shell/tools/4LETTER.scroll.py "${#act[@]} $FID > "
RVALUE=$(su $YOU -c "ipfs cat /ipns/$J/TAG_amount");
CURRENCY=$(su $YOU -c "ipfs cat /ipns/$J/TAG_currency" | awk '{print tolower($1)}')
PASSENGER=$(su $YOU -c "ipfs cat /ipns/$J/TAG_passenger");
if [[ "$PASSENGER" != "" ]]; then
./shell/tools/4LETTER.scroll.py "G1TAG PASSENGER $RVALUE ZEN"
else
G1VAL=$(bc -l <<< "scale=2; $RVALUE / 100" | cut -d '.' -f 1)
log "__SUB:tag_READ_X.sh: G1Tag $FID. Valeur $RVALUE $CURRENCY = $G1VAL G1"
./shell/tools/4LETTER.scroll.py "$RVALUE ZEN *** $G1VAL G1"
fi
cmd="RJ"
CASHBACK=""
val+=("$RVALUE")
;;
BJ)
BB=$(echo $qrvalue | cut -d '#' -f 1)
J=$(echo $qrvalue | cut -d '#' -f 2)
log "__SUB:tag_READ_X.sh: Ouverture G1Tag $BB $J"
#
ID=$(su $YOU -c "ipfs cat /ipns/$J/TAG_id");
if [[ "$ID" == "" ]]; then
./shell/tools/4LETTER.scroll.py ">> BAD G1TAG <<"
continue
fi
FID=$(echo $ID | awk '{print toupper($1)}')
RR=$(echo $ID | sed s/\ //g)
./shell/tools/4LETTER.scroll.py "${#act[@]} $FID TX >>"
BVALUE=$(su $YOU -c "ipfs cat /ipns/$J/TAG_amount")
CURRENCY=$(su $YOU -c "ipfs cat /ipns/$J/TAG_currency" | awk '{print tolower($1)}')
PASSENGER=$(su $YOU -c "ipfs cat /ipns/$J/TAG_passenger");
# DIG PUBLISHING KEY
if [[ -f /home/$YOU/.ipfs/keystore/$RR ]]; then
log "__SUB:tag_READ_X.sh: Clef de publication IPFS $RR déjà présente"
else
rm /tmp/TAG_publishkey.B.gpg
su $YOU -c "ipfs get -o /tmp/ /ipns/$J/TAG_publishkey.B.gpg"
./shell/tools/4LETTER.scroll.py "** GPG **"
gpg -d --output /tmp/ipns.key --pinentry-mode=loopback --passphrase $BB /tmp/TAG_publishkey.B.gpg
# CHECK IF OK
if [[ ! -f /tmp/ipns.key ]]; then
./shell/tools/4LETTER.scroll.py ">> BAD GPG KEY <<"
continue
fi
mv /tmp/ipns.key /home/$YOU/.ipfs/keystore/$RR
log "__SUB:tag_READ_X.sh: Récupération de la clef de publication $RR"
fi
if [[ "$PASSENGER" != "" ]]; then
log "__SUB:tag_READ_X.sh: !!!! $FID REC Tag = $BVALUE $CURRENCY"
./shell/tools/4LETTER.scroll.py "G1TAG PASSENGER $BVALUE ZEN"
else
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
log "__SUB:tag_READ_X.sh: Ce G1 Tag $FID contient $BVALUE $CURRENCY"
./shell/tools/4LETTER.scroll.py "$BVALUE ZEN *** $G1VAL G1 MAX"
fi
cmd="BJ"
val+=("$BVALUE")
;;
*)
if [[ $lon -eq 44 ]]; then
./shell/tools/4LETTER.scroll.py "PORTEFEUILLE G1 >>>>>>>> ${#act[@]}" &
J=$qrvalue
if [[ "$J" != "${obj[0]}" ]]; then
VALUE=$(./shell/timeout.sh -t 25 ./silkaj/silkaj amount $J)
if [[ "$(echo $VALUE | cut -d ':' -f 1)" != "Error" && "$VALUE" != "" ]]; then
log "__SUB:tag_READ_X.sh: Ce compte monnaie libre contient $VALUE G1"
NOPOINT=$(echo $VALUE | cut -d '.' -f 1)
./shell/tools/4LETTER.scroll.py " $NOPOINT G1 *** $NOPOINT G1 "
CASHBACK="$J"
cmd="G1"
val+=("$VALUE")
else
if [[ "$VALUE" == "" ]]; then
DUNITER=$(./shell/checknodes.sh 'BAN')
log "__SUB:tag_READ_X.sh: ERREUR TIMEOUT. CHANGE SILKAJ SERVER: $DUNITER"
./shell/tools/4LETTER.scroll.py "ERREUR TIMEOUT SILKAJ"
./shell/timeout.sh -t 1 ./shell/tools/4LETTER.spinner.py
CASHBACK=""
else
log "__SUB:tag_READ_X.sh: ERREUR QRCODE ILLISIBLE. longueur $J = ${#J}"
./shell/tools/4LETTER.scroll.py "ERREUR QRCODE INCONNU"
./shell/timeout.sh -t 1 ./shell/tools/4LETTER.spinner.py
CASHBACK=""
fi
fi
else
./shell/tools/4LETTER.scroll.py " 2 X "
fi
else
./shell/tools/4LETTER.scroll.py "ERREUR QRCODE INCONNU"
fi
;;
esac
###############################################################
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
./shell/tools/4LETTER.scroll.py "ZEN -> G1"
log "__SUB:tag_READ_X.sh: G1 tag de $BVALUE G1 ! /ipns/$J Virement vers $CASHBACK? "
./shell/tools/4LETTER.spinner.py &
spinnerpid=$!
# ipfs get G1Tag vers ./TAG/${RR}
mkdir -p ./TAG/${RR}; rm -f ./TAG/${RR}/*; chown -R $YOU ./TAG/${RR}/
log "__SUB:tag_READ_X.sh: ipfs get --output=./TAG/${RR} /ipns/$J"
su $YOU -c "ipfs get --output=./TAG/${RR} /ipns/$J"
if [[ $(cat ./TAG/${RR}/TAG_passenger) != "" ]]; then ./shell/tools/4LETTER.scroll.py "IMPOSSIBLE TAG PASSENGER $BVALUE ZEN"; continue; fi
# Make Silkaj TX
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
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
kill $spinnerpid
if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" && "$PAY" != "" ]]; then
new=$(./shell/checknodes.sh "BAN")
sms_ERROR "$ADMINPHONE" "Il est survenu un problème avec un virement. Retour silkaj: $PAY ... $new";
./shell/tools/4LETTER.scroll.py "ERREUR SILKAJ ERREUR"
else
# ENCAISSEMENT G1Tag
./shell/tools/4LETTER.scroll.py "VIR ${FID} $G1VAL G1 -> OK "
# CAPTURE / DESTRUCTION du G1 Tag
echo "0" > "./TAG/${RR}/TAG_amount"
echo "${J}" > "./TAG/${RR}/TAG_ipns"
# Iterate
if [[ -f ./TAG/${RR}/TAG_n ]]; then NN=$(cat ./TAG/${RR}/TAG_n); ((NN++)); else NN=0; fi
# TAG_actions
echo "$NN" > "./TAG/${RR}/TAG_n"
echo "${NANODATE}" > "./TAG/${RR}/TAG_nanodate"
echo "${IPFSNODEID}" > "./TAG/${RR}/TAG_writerid"
# EMPTY G1TAG ID AND REMOVE PUBLISHKEYS
echo "" > "./TAG/${RR}/TAG_id"
rm -f ./TAG/TAG_publishkey.*
log "__SUB:tag_READ_X.sh: Destruction G1Tag TAG_id $NN.${NANODATE} (par NODE ${IPFSNODEID}) => Value = 0"
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
# TAG_chain
echo "$I" > "./TAG/${RR}/TAG_chain"
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
# IPNS $RR PUBLISH
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
log "__SUB:tag_READ_X.sh: Destruction de ce G1 Tag publish -k ${RR} --quieter /ipfs/${I} :: ipfs ls /ipns/$J"
./shell/tools/4LETTER.scroll.py "DETRUIRE G1TAG ${FID}"
# CLEAN IPFS keystore: remove NOT created NODE keys
SOURCENODEID=$(cat "./TAG/${RR}/TAG_nodeid")
if [[ "${SOURCENODEID}" != "${IPFSNODEID}" ]]; then
rm -f /home/$YOU/.ipfs/keystore/${RR}
fi
fi
else
# AJOUT MEMOIRE SCAN
./shell/timeout.sh -t 1 ./shell/tools/4LETTER.spinner.py
act+=("$cmd")
obj+=("$J")
fi
# FLUSH MEMOIRE 2 SCAN
if [[ ${#act[@]} -eq 2 ]]; then
echo "${act[@]}"
echo "${obj[@]}"
echo "${val[@]}"
###############################################################
# PRESENTATION RJ puis BJ différents Tag WRITE = TRANSFERT G1 TAG
if [[ "${act[0]}" == "RJ" && "${act[1]}" == "BJ" && "${obj[0]}" != "${obj[1]}" ]]; then
PASSENGER=$(su $YOU -c "ipfs cat /ipns/${obj[1]}/TAG_passenger");
if [[ "$PASSENGER" != "" ]]; then
./shell/tools/4LETTER.scroll.py "IMPOSSIBLE TAG PASSENGER";
else
###########################################################
# READ KEYBOARD VALUE !!! 4 DIGIT REMOVING LEADING 0
COMBIEN=$(./shell/tools/matrixKeypad.py | sed 's/^0*//')
if [[ $COMBIEN -le ${val[1]} ]]; then
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 $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
fi
CASHBACK=""
fi
###############################################################
# PRESENTATION BJ identiques TRANSFORMATION G1 TAG en REC TAG
if [[ "${act[0]}" == "BJ" && "${act[1]}" == "BJ" && "${obj[0]}" == "${obj[1]}" ]]; then
PASSENGER=$(su $YOU -c "ipfs cat /ipns/${obj[0]}/TAG_passenger");
if [[ "$PASSENGER" != "" ]]; then
./shell/tools/4LETTER.scroll.py "DEJA TAG PASSENGER";
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 $SWARM_G1AUTHFILE)"
fi
CASHBACK=""
fi
act=()
obj=()
val=()
# END OF 2-PASS READ
./shell/timeout.sh -t 2 ./shell/tools/4LETTER.spinner.py
fi
./shell/tools/4LETTER.blink.py
./shell/tools/4LETTER.clock.py &
clockpid=$!
done

3
shell/tata.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
echo yoyoyo

22
shell/test.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
pwd=$(pwd)
if [[ -f $MY_PATH/.profile ]]; then
source $MY_PATH/.profile
elif [[ -f $MY_PATH/../.profile ]]; then
source $MY_PATH/../.profile
else
echo -e "${c_red}Le .profile n'existe pas$c_"
exit 1
fi
source $GPATH/shell/tata.sh || echo "pas trouvé"
echo "je suis là: $GPATH/shell !"
#$GPATH/shell/sms_AIDE.sh $1
exit 0

View File

@ -1,332 +0,0 @@
#!/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

@ -37,6 +37,7 @@ export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
cd $MY_PATH cd $MY_PATH
source $MY_PATH/shell/init.sh source $MY_PATH/shell/init.sh
source $MY_PATH/shell/functions.sh source $MY_PATH/shell/functions.sh
date=$(date '+%D à %H:%M')
################################################################## ##################################################################
# Get global variables from gammu-smsd # Get global variables from gammu-smsd
@ -46,13 +47,12 @@ TEXT="$SMS_1_TEXT"
CMD=$(echo "$TEXT" | awk '{print toupper($1)}') CMD=$(echo "$TEXT" | awk '{print toupper($1)}')
log "##########################################################################################" log "##########################################################################################"
log "#################################### ${c_yellow}$date$c_ ####################################"
log "##########################################################################################\n"
log "${c_green}SMS received $PHONE $TEXT$c_"
log "#############################################" log "#############################################"
log "#############################################" log "${$c_yellow}NODE: ALL WALLETS: ipfs ls /ipns/$IPFSNODEID$c_"
log "$(date)" log "${$c_yellow}NODE: G1wallet: cat ./wallets/.$IPFSNODEID/NODE.pub$c_"
log "SMS received $PHONE $TEXT"
log "#############################################"
log "NODE: ALL WALLETS: ipfs ls /ipns/$IPFSNODEID"
log "NODE: G1wallet: cat ./wallets/.$IPFSNODEID/NODE.pub"
log "#############################################" log "#############################################"
################################################################## ##################################################################
@ -63,7 +63,7 @@ security
################################################################## ##################################################################
# Refresh All peers SWARM Wallets. # Refresh All peers SWARM Wallets.
################################################################## ##################################################################
# ipfs_swarm_wallets_refresh ipfs_swarm_wallets_refresh
################################################################## ##################################################################
# Check if PHONE is already registred in G1sms+ SWARM # Check if PHONE is already registred in G1sms+ SWARM
@ -73,7 +73,7 @@ then
NODEPHONE=$(cat "./wallets_swarm/$PHONE/MASTERPHONE.sms") NODEPHONE=$(cat "./wallets_swarm/$PHONE/MASTERPHONE.sms")
if [[ "$NODEPHONE" != "$MASTERPHONE" && "$NODEPHONE" != "" ]]; then if [[ "$NODEPHONE" != "$MASTERPHONE" && "$NODEPHONE" != "" ]]; then
sms_SEND "$PHONE" "[G1sms+] Vous avez déjà un compte portefeuille sur $NODEPHONE (Envoyez lui RAZ si vous voulez fermer votre compte)" sms_SEND "$PHONE" "[G1sms+] Vous avez déjà un compte portefeuille sur $NODEPHONE (Envoyez lui RAZ si vous voulez fermer votre compte)"
log "ALERT!! $PHONE compte existant sur le NODE G1sms+ ($NODEPHONE)" log "${c_red}ALERT!! $PHONE compte existant sur le NODE G1sms+ ($NODEPHONE)$c_"
exit exit
fi fi
else else
@ -203,7 +203,7 @@ case "$CMD" in
;; ;;
*) *)
#./shell/sms_ERROR.sh "$PHONE" "$TEXT" & #./shell/sms_ERROR.sh "$PHONE" "$TEXT" &
log "SMS forward to $ADMINPHONE" log "${$c_yellow}SMS forward to $ADMINPHONE$c_"
sms_SEND "$ADMINPHONE" "ADMIN! BAD SMS FROM $PHONE sms_SEND "$ADMINPHONE" "ADMIN! BAD SMS FROM $PHONE
$TEXT" $TEXT"
;; ;;

1
wait_actions/test/tata Normal file
View File

@ -0,0 +1 @@
toto

0
wait_actions/test/tata2 Normal file
View File

View File

View File