Compare commits
168 Commits
Author | SHA1 | Date |
---|---|---|
qo-op | 34dd9fede8 | |
qo-op | c493682de2 | |
qo-op | fbe055a3f7 | |
qo-op | d01d4a705f | |
qo-op | f5ca21b71b | |
qo-op | e0b3da4856 | |
qo-op | bf8a2c626f | |
qo-op | 131cfcc487 | |
poka | eebcf288cc | |
qo-op | b01fda63fb | |
qo-op | efb0e04ddf | |
qo-op | f6488164d7 | |
poka | 6db82d6b3d | |
poka | 628063d6c2 | |
qo-op | 5428251f0b | |
qo-op | 8d7188681e | |
qo-op | c57cc485fc | |
qo-op | 8bf6afe505 | |
qo-op | 9600127295 | |
qo-op | 30690f1ea6 | |
qo-op | bafc401bdc | |
qo-op | e6f403a0fe | |
qo-op | 89667048c0 | |
qo-op | 58453700f3 | |
poka | b2352a972a | |
poka | fe84ee6532 | |
qo-op | 522ef7934c | |
qo-op | 6d80e47c9d | |
qo-op | eb2b59ebc1 | |
qo-op | cdcecb2cec | |
qo-op | cb07116eb8 | |
qo-op | 27ea5c0103 | |
poka | 74d07fee01 | |
poka | c9f00d08de | |
qo-op | dff65df717 | |
qo-op | 17a64e1473 | |
qo-op | 625e1aaba9 | |
qo-op | 69f81ca221 | |
qo-op | abb7ccbdc7 | |
poka | 3c65aba16e | |
poka | 8d2e611162 | |
poka | 3e8a824d89 | |
qo-op | 35f94120ce | |
qo-op | 72f9d06514 | |
poka | dddb82c037 | |
poka | 30e136f3ea | |
qo-op | 7b170d7874 | |
qo-op | e2f57db5e6 | |
poka | 7c0d9977f6 | |
poka | a54df36c2f | |
poka | fac3136524 | |
poka | eb08ec5f11 | |
poka | 7ccfd8f377 | |
poka | e49a34e91b | |
poka | 043b7db512 | |
poka | 6ee31e5d3c | |
poka | ed5af53c90 | |
poka | 2bf4a8bd1d | |
poka | ac356a7ae3 | |
poka | 282c00f425 | |
poka | 123b4ea563 | |
poka | 75a15c3299 | |
qo-op | f07f5f994a | |
qo-op | 65ea7cc097 | |
poka | bd5efb3a67 | |
poka | e3f1dc1f42 | |
poka | a00cfd9e6e | |
poka | 27d6fd33fe | |
qo-op | dd74cff5aa | |
qo-op | a44d892c11 | |
qo-op | 5c0d888bac | |
qo-op | d5d37f03a9 | |
qo-op | d2bd1b6c76 | |
qo-op | ff57c9c81d | |
qo-op | 7126c11e04 | |
qo-op | 829e89b60a | |
poka | aceffcb535 | |
poka | 031d8680fb | |
poka | c03a3245d6 | |
poka | d34559ff5e | |
qo-op | 6e00414c16 | |
qo-op | 1c6dfe1ae0 | |
qo-op | 014634e840 | |
qo-op | da90e19345 | |
poka | 3918e035da | |
poka | 5163a4cb26 | |
qo-op | 975963b9b6 | |
qo-op | 5a862c5f5a | |
poka | 50e73491f0 | |
poka | 30dc5f9b34 | |
poka | d984ebe9f5 | |
poka | 0ac66b60ed | |
poka | 8647b941d6 | |
poka | 08b628a8a9 | |
poka | 9231e6718a | |
poka | ad7c7348da | |
qo-op | 9d1f20ec3b | |
poka | bb5df2ce26 | |
poka | bfbb4a414f | |
poka | 7b18a29c70 | |
poka | a3db607d8e | |
poka | ee3a6bc9f4 | |
poka | aa9a7d2254 | |
poka | b1a333ae2e | |
poka | 6bfae483dc | |
qo-op | b8c8dacb4e | |
qo-op | d9ed8b97af | |
qo-op | 48e4c5865a | |
qo-op | 1bdad857db | |
poka | 3859fcd2d9 | |
poka | 4c9834eb0f | |
poka | bd42f28f94 | |
poka | 2bad497ae2 | |
poka | 2a626348dc | |
poka | 7c1ed25c14 | |
poka | 84e46bbb55 | |
poka | a8514b286c | |
poka | ac01655d13 | |
poka | e971c80fd5 | |
poka | b7dc137a80 | |
poka | cc35674a4f | |
poka | e42796aa8d | |
poka | 3254d4b24f | |
poka | ce7ab33e0d | |
poka | 04f36b73cf | |
poka | ec9a4032fb | |
poka | f89385a27a | |
poka | 92399892a8 | |
poka | a2c42d6d76 | |
poka | 16f6c4c0bf | |
qo-op | e9ad4a7f0e | |
poka | ce4a730f6c | |
poka | fd20423bc4 | |
poka | 03c37f00f1 | |
poka | 7750613dd5 | |
poka | 1b845057e3 | |
poka | ddbda0d6a5 | |
poka | 875611062f | |
poka | 5cab225e79 | |
poka | e6db53a4df | |
poka | 60e5f9a2c7 | |
poka | a23cb3a92c | |
poka | c031e76fb0 | |
poka | 63860d4d63 | |
poka | ee00928a4f | |
poka | 8f7d89d562 | |
poka | 8285ccc858 | |
poka | 4705cc49d1 | |
poka | d0b057d5e3 | |
poka | 46dddbb083 | |
poka | 81d224330f | |
poka | fd860ae85f | |
poka | 50610c24df | |
poka | 2e79716945 | |
poka | bba47844b9 | |
qo-op | 89144aad96 | |
poka | 0da8d19432 | |
qo-op | ccb8b9a214 | |
qo-op | 0eea17bf80 | |
qo-op | 01dc1f88bb | |
poka | 9757e61f98 | |
poka | 5fd9b873be | |
poka | 74c9605bbd | |
poka | 71862814ba | |
poka | c409c517ea | |
poka | d3e223ba90 | |
qo-op | 7a18f76c4f | |
qo-op | b9ef1d62a4 |
|
@ -0,0 +1,19 @@
|
||||||
|
authfile
|
||||||
|
g1sms.bfproject
|
||||||
|
g1sms.priv.key
|
||||||
|
g1sms.preoni.priv.key
|
||||||
|
g1sms.preoni.pub.key
|
||||||
|
shell/init.sh
|
||||||
|
shell/bad.nodes.txt
|
||||||
|
shell/good.nodes.txt
|
||||||
|
shell/trash/
|
||||||
|
wallets/
|
||||||
|
wallets_swarm/
|
||||||
|
TAG/
|
||||||
|
billets/
|
||||||
|
history.*
|
||||||
|
*~
|
||||||
|
.install/errors
|
||||||
|
.install/log
|
||||||
|
.install/.OS
|
||||||
|
.profile
|
|
@ -0,0 +1 @@
|
||||||
|
GPATH=/home/pi/G1sms+
|
|
@ -0,0 +1,99 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
OS=$(head -n1 $MY_PATH/.OS)
|
||||||
|
isARM=$(cat $MY_PATH/.OS | grep YES)
|
||||||
|
unset err
|
||||||
|
|
||||||
|
# Basics
|
||||||
|
sudo apt update
|
||||||
|
echo -e "${c_yellow}Mise à jours des prérequis...$c_"
|
||||||
|
sudo apt install curl jq zip unzip htop tree ntpdate gnupg ssmtp mpack imagemagick qrencode bc libttspico-utils libttspico0 libttspico-data python-fourletterphat -y
|
||||||
|
|
||||||
|
# Silkaj + Duniterpy
|
||||||
|
silkaj() {
|
||||||
|
echo -e "${c_yellow}Installation de Silkaj...$c_"
|
||||||
|
libsodium=$(sudo apt search libsodium 2>/dev/null | grep -v -E "header|debug symbols" | grep "Network communication" -B1 | head -n1 | awk -F '/' '{ print $1 }')
|
||||||
|
[[ $libsodium =~ " " ]] && libsodium=$(echo $libsodium | awk '{ print $2 }')
|
||||||
|
sudo apt install python3-pip $libsodium -y || err+="Install python3 and $libsodium"
|
||||||
|
pip3 install duniterpy || err+="Install duniterpy"
|
||||||
|
pip3 install silkaj --user || err+="Install Silkaj"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install IPFS
|
||||||
|
ipfs() {
|
||||||
|
echo -e "${c_yellow}Installation d'IPFS...$c_"
|
||||||
|
[[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop
|
||||||
|
if [[ $isARM ]]; 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"
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "INSTALL ipfs-update"
|
||||||
|
sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err+="Untar ipfs-update"
|
||||||
|
rm $MY_PATH/ipfs-update.tar.gz
|
||||||
|
cd /usr/src/ipfs-update/
|
||||||
|
sudo ./install.sh || err+="Install ipfs-update"
|
||||||
|
cd $MY_PATH
|
||||||
|
|
||||||
|
echo "INSTALL latest ipfs"
|
||||||
|
sudo ipfs-update install latest || err+="Install IPFS"
|
||||||
|
|
||||||
|
echo "CREATE SYSTEMD ipfs SERVICE"
|
||||||
|
[[ -f /etc/systemd/system/ipfs.service ]] && sudo rm /etc/systemd/system/ipfs.service
|
||||||
|
sudo cp -f $MY_PATH/templates/1/ipfs.service /etc/systemd/system/
|
||||||
|
sudo sed -i "s/_USER/$USER/g" /etc/systemd/system/ipfs.service
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload || err+="Restart IPFS"
|
||||||
|
sudo systemctl enable ipfs || err+="Enable IPFS daemon"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install gammu
|
||||||
|
gammu() {
|
||||||
|
echo -e "${c_yellow}Installation de gammu...$c_"
|
||||||
|
sudo apt install wvdial ppp screen git minicom gammu -y || err+="Install gammu requirements"
|
||||||
|
sleep 1
|
||||||
|
sudo apt install gammu-smsd -y || sudo apt install -f || err+="Install gammu"
|
||||||
|
|
||||||
|
sudo usermod -aG gammu $USER
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install PHP + MySQL
|
||||||
|
php() {
|
||||||
|
echo -e "${c_yellow}Installation de PHP et MySQL$c_"
|
||||||
|
if [[ $OS == "buster" ]]; then
|
||||||
|
sudo apt -y install software-properties-common nginx php php-common php-fpm php-gettext php-gd php-mysql php-curl php-imap php-mbstring php-xml php-cli mariadb-server || err+="Install PHP and MySQL"
|
||||||
|
elif [[ $OS == "stretch" ]]; then
|
||||||
|
sudo apt -y install lsb-release apt-transport-https ca-certificates || err+="Install apt-transport-https"
|
||||||
|
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg || err+="Download PHP key"
|
||||||
|
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
|
||||||
|
sudo apt update
|
||||||
|
sudo apt -y install software-properties-common dirmngr nginx php7.3 php7.3-common php7.3-gettext php7.3-fpm php7.3-gd php7.3-mysql php7.3-curl php7.3-imap php7.3-mbstring php7.3-xml php7.3-cli mariadb-server || err+="Install PHP and MySQL"
|
||||||
|
else
|
||||||
|
echo "${c_red}Votre système n'est pas pris en charge par ce script d'installation.$c_"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
isLocalhostUsers=$(sudo mysql -e "select user from mysql.user;" | grep "localhost")
|
||||||
|
isTestDB=$(sudo mysql -e "show databases" | grep "test")
|
||||||
|
[[ -n $isLocalhostUsers ]] && sudo mysql -e "DROP USER ''@'localhost'; DROP USER ''@'$(hostname)'"
|
||||||
|
[[ -n $isTestDB ]] && sudo mysql -e "DROP DATABASE test"
|
||||||
|
sudo mysql -e "FLUSH PRIVILEGES"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read arguments
|
||||||
|
for i in $@; do
|
||||||
|
echo -e "${c_yellow}Installation de $c_light$i$c_"
|
||||||
|
$i
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $err ]]; then
|
||||||
|
echo -e "${c_red}Installation des prérequis incomplète: $err$c_"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${c_green}Les prérequis ont été correctement installés$c_"
|
||||||
|
exit 0
|
||||||
|
fi
|
|
@ -0,0 +1,56 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
stamp=$(date +%s)
|
||||||
|
templates="$MY_PATH/templates/2a"
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# CONFIGURE IPFS for G1sms+ Pi NODES
|
||||||
|
#######################################
|
||||||
|
|
||||||
|
if [ "$EUID" -eq 0 ]
|
||||||
|
then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_"
|
||||||
|
exit 1
|
||||||
|
else echo -e "${c_yellow}OK $USER, let's go!$c_";
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -d ~/.ipfs/ ]] && rm -rf ~/.ipfs-old && mv ~/.ipfs/ ~/.ipfs-old
|
||||||
|
|
||||||
|
################
|
||||||
|
# BECOME $USER
|
||||||
|
# INIT ipfs
|
||||||
|
ipfs init -p lowpower
|
||||||
|
|
||||||
|
# ACTIVATE CONFIG OPTIONS
|
||||||
|
# PUBSUB
|
||||||
|
ipfs config Pubsub.Router gossipsub
|
||||||
|
# MAXSTORAGE
|
||||||
|
ipfs config Datastore.StorageMax 12GB
|
||||||
|
## PORT FORWARD (SSH)
|
||||||
|
ipfs config --json Experimental.Libp2pStreamMounting true
|
||||||
|
|
||||||
|
######### UPDATE BOOTSTRAP LIST ###########
|
||||||
|
ipfs bootstrap rm --all
|
||||||
|
### fred@onelove.madeinzion.org ###
|
||||||
|
# ID: QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
ipfs bootstrap add /ip6/fe80::207:cbff:fe0b:75bb/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
ipfs bootstrap add /ip4/51.15.2.211/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
||||||
|
### ADD NEW SWARM LEADERS SERVER HERE ###
|
||||||
|
cp $MY_PATH/templates/swarm.key ~/.ipfs/
|
||||||
|
|
||||||
|
# ALLOW REMOTE SSH CONNECTION FROM rec OR onelove (For swarm.key & keystore exchange )
|
||||||
|
# ADD SSH ADMIN/SUPPORT USERS $(cat .ssh/id_rsa.pub)
|
||||||
|
if [[ -z $(grep fred@rec ~/.ssh/authorized_keys) ]]; then
|
||||||
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs6oXRmPukaX7u2tDcFF1cecsDSEA30YyUqDaXSrw+yWQ8G79ktZ7BN0bPYBgfxO59FU8l5Jg1SPPG9kj81jfoCwGJpYdbczmMuP/iqw3aNoGv66swxwxzrqzbHrFFCXgn+6B2spDjn87tFB8JvQQTb2Kc4/sAZ9E6eY61pFiNpqbQehXdqSV5UemV9dkSQrnmJTl1PjUQ474AKQwFPzpdKHD/3VvqQS4i7ZLVeXS65euOP/YY8Bx9HvhsmhJ3h78OOK+D6GFfyv010xXBoG6kCSYR8LYMCEexpPGYV+Mduf/tUHjHP4GuWZAhd+wLRl0uPy6Tv7wHFfLyN01m/9vl fred@rec" >> ~/.ssh/authorized_keys
|
||||||
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFthQ3FggJlz/+ZglZJjVJzYs6ehx/iB7f89KY396K+7ai4ETqFhq6ANVp9xeQ4dLU26w0bFBELcnh9rn5QDSrXjsIptoWXErkSdZOeXqofnLtJEOhZO/I328y0C1vQRwtMMXKLLnqPe14h+zJenc7KJbL5cvB3Hd7nfQ+Q0uEnIsKb0f5wcKagySHIFdmY/FqaGz5g4MXGq7nlX/31hvfTFhF0g+k3mhvTTVQ368Op9qZZIozYhBoojWWvK5mwAovxdS9QT1hKrFXHfjov/aKQxLAy0a0oxFvHKoYN/l4ffGibFMAmedljTxf1VSDBv/k/RN53UU6RufW3qqBjY0b fred@onelove" >> ~/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
||||||
|
# START ipfs
|
||||||
|
echo -e "${c_green}Démarrage de IPFS ...$c_"
|
||||||
|
sudo systemctl start ipfs || echo -e "${c_red}IPFS n'a pas pu démarrer ...$c_"
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
source $MY_PATH/../.install/.GPATH
|
||||||
|
|
||||||
|
## Récupère les données du profile
|
||||||
|
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
if [[ -z $(grep "PIN" /etc/gammu-smsdrc) ]]; then
|
||||||
|
## Copie et sed de /etc/gammu-smsdrc
|
||||||
|
[[ -f /etc/gammu-smsdrc ]] && sudo mv /etc/gammu-smsdrc /etc/gammu-smsdrc.old && echo "/etc/gammu-smsdrc a été renommé en /etc/gammu-smsdrc.old"
|
||||||
|
sudo cp $MY_PATH/templates/2b/gammu-smsdrc /etc/
|
||||||
|
|
||||||
|
GPATHS=$(echo $GPATH | sed 's./.\\/.g')
|
||||||
|
sudo sed -i "s/_GPATH/$GPATHS/g" /etc/gammu-smsdrc
|
||||||
|
sudo sed -i "s/_PIN/$PIN/g" /etc/gammu-smsdrc
|
||||||
|
|
||||||
|
## Redémarre gammu-smsd
|
||||||
|
sudo service gammu-smsd restart && echo -e "${c_green}Gammu a été correctement configuré$c_" || echo -e "${c_green}Un problème est survenu lors de la configuration de gammu$c_"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Configure correctement le UART
|
||||||
|
|
||||||
|
[[ ! $(grep enable_uart=1 /boot/config.txt) ]] && echo "enable_uart=1" | sudo tee -a /boot/config.txt
|
||||||
|
[[ $(grep "console=serial0" /boot/cmdline.txt) ]] && sudo sed -i "s/console=serial0,115200//g" /boot/cmdline.txt
|
||||||
|
[[ $(grep "console=serial0" /boot/cmdline.txt) ]] && echo -e "${c_red}Attention, console=serial0 est toujours présent dans /boot/cmdline.txt !$c_" && err=1
|
||||||
|
|
||||||
|
## Configure rc.local
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
templates="$MY_PATH/templates/3"
|
||||||
|
|
||||||
|
isARM=$(cat $MY_PATH/.OS | grep YES)
|
||||||
|
|
||||||
|
##################################
|
||||||
|
## INSTALL TOOLS
|
||||||
|
######## YOUTUBE-DL ##########
|
||||||
|
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl || err=1
|
||||||
|
sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||||
|
sudo apt install libid3-tools mpd mpc lame omxplayer -y || err=1
|
||||||
|
|
||||||
|
## CONFIG MPD
|
||||||
|
sudo cp -f $templates/mpd.conf /etc/mpd.conf
|
||||||
|
sudo sed -i "s/_USER/$USER/g" /etc/mpd.conf || err=1
|
||||||
|
|
||||||
|
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
||||||
|
sudo service mpd restart || err=1
|
||||||
|
|
||||||
|
|
||||||
|
sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y || err=1
|
||||||
|
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y #libav-tools || err=1
|
||||||
|
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse atomicparsley -y || err=1
|
||||||
|
|
||||||
|
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
|
||||||
|
if [[ $isARM ]]; 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/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb
|
||||||
|
else
|
||||||
|
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-5_amd64.deb -O $MY_PATH/libttspico0.deb
|
||||||
|
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-9_amd64.deb -O $MY_PATH/libttspico-utils.deb
|
||||||
|
fi
|
||||||
|
sudo dpkg -i $MY_PATH/libttspico-data.deb || err=1
|
||||||
|
sudo dpkg -i $MY_PATH/libttspico0.deb || err=1
|
||||||
|
sudo dpkg -i $MY_PATH/libttspico-utils.deb || err=1
|
||||||
|
sudo dpkg -i $MY_PATH/libav-tools.deb || sudo apt --fix-broken install -y || err=1
|
||||||
|
rm $MY_PATH/libttspico-data.deb $MY_PATH/libttspico0.deb $MY_PATH/libttspico-utils.deb $MY_PATH/libav-tools.deb
|
||||||
|
|
||||||
|
|
||||||
|
# CONFIG NGINX
|
||||||
|
sudo cp -f $templates/default /etc/nginx/sites-available/
|
||||||
|
sudo sed -i "s/_USER/$USER/g" /etc/nginx/sites-available/default
|
||||||
|
|
||||||
|
sudo systemctl restart nginx || err=1
|
||||||
|
|
||||||
|
#################################
|
||||||
|
## Get _CopyLaRadio distrib
|
||||||
|
# ipfs get Qm.... > /tmp/copylaradio.zip
|
||||||
|
|
||||||
|
# Add CopyLaRadio to system PATH
|
||||||
|
#export PATH=$PATH:/home/$USER/_CopyLaRadio
|
||||||
|
# etc....
|
||||||
|
|
||||||
|
# INSTALL ROMPR WebSite LINKs
|
||||||
|
sudo ln -s /home/$USER/_CopyLaRadio/www/rompr /var/www/rompr
|
||||||
|
sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/albumart
|
||||||
|
sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/prefs
|
||||||
|
|
||||||
|
if [[ $err ]]; then
|
||||||
|
echo -e "${c_red}Installation de copylaradio incomplète$c_"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${c_green}CopyLaRadio a été installé avec succès$c_"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile
|
||||||
|
unset err
|
||||||
|
|
||||||
|
args=$@
|
||||||
|
[[ $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 }')
|
||||||
|
if [[ -z $KSMS_DOMAIN ]]; then
|
||||||
|
echo -e "${c_yellow}Choisissez un nom de domaine pour KALKUN (Sinon $IP sera choisi): $c_" && read KSMS_DOMAIN
|
||||||
|
[[ -z $KSMS_DOMAIN ]] && KSMS_DOMAIN=$IP && askSSL=n && noask=o
|
||||||
|
sed -i "s/\<KSMS_DOMAIN=/&$KSMS_DOMAIN/" $MY_PATH/../.profile
|
||||||
|
fi
|
||||||
|
|
||||||
|
DOMAIN=$KSMS_DOMAIN
|
||||||
|
|
||||||
|
## Install PHP + MySQL
|
||||||
|
$MY_PATH/1-install_requirements.sh php
|
||||||
|
|
||||||
|
## Create database
|
||||||
|
if [[ $(sudo mysql -e "select * from mysql.user;" | grep gammu) ]]; then
|
||||||
|
pwdDB=$(cat /etc/gammu-smsdrc | grep "password" | grep -v "# " | awk '{ print $3 }')
|
||||||
|
else
|
||||||
|
pwdDB=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 42 | head -n 1)
|
||||||
|
sudo mysql -e "CREATE USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! $(sudo mysql -e "show databases;" | grep gammu) ]]; then
|
||||||
|
echo -e "${c_yellow}Création de la base de donnée...$c_"
|
||||||
|
sudo mysql -e "CREATE DATABASE gammu"
|
||||||
|
sudo mysql -e "GRANT ALL PRIVILEGES ON gammu.* TO 'gammu'@'localhost';"
|
||||||
|
sudo mysql -e "FLUSH PRIVILEGES;"
|
||||||
|
fi
|
||||||
|
if [[ -z $(sudo mysql gammu -e "SHOW TABLES LIKE 'outbox';") ]]; then
|
||||||
|
echo -e "${c_yellow}Importation du dump gammu...$c_"
|
||||||
|
if [[ $OS == "buster" ]]; then
|
||||||
|
sudo mysql gammu < $MY_PATH/templates/4a/mysql.sql || err+="Import dump MySQL"
|
||||||
|
elif [[ $OS == "stretch" ]]; then
|
||||||
|
sudo mysql gammu < $MY_PATH/templates/4a/mysql-stretch.sql || err+="Import dump MySQL"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -z $(sudo mysql gammu -e "SHOW TABLES LIKE 'kalkun';") ]]; then
|
||||||
|
echo -e "${c_yellow}Importation du dump kalkun...$c_"
|
||||||
|
[[ ! $ADRESSE ]] && ADRESSE=G1GROUPE
|
||||||
|
sed -i "s/_GROUPDEF/$ADRESSE/g" $MY_PATH/templates/4a/kalkun.sql
|
||||||
|
sudo mysql gammu < $MY_PATH/templates/4a/kalkun.sql || err+="Import dump Kalkun"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Clone repo KALKUN
|
||||||
|
|
||||||
|
[[ -d $MY_PATH/kalkun ]] && sudo rm -rf $MY_PATH/kalkun
|
||||||
|
echo -e "${c_yellow}Clonage du dépot de Kalkun...$c_"
|
||||||
|
git clone https://github.com/back2arie/Kalkun.git $MY_PATH/kalkun
|
||||||
|
|
||||||
|
cp $MY_PATH/templates/4a/database.php $MY_PATH/kalkun/application/config/
|
||||||
|
cp $MY_PATH/templates/4a/daemon.sh $MY_PATH/templates/4a/daemon.php $MY_PATH/kalkun/scripts
|
||||||
|
sed -i "s/_PWD/$pwdDB/g" $MY_PATH/kalkun/application/config/database.php || err+="Sed database password"
|
||||||
|
sed -i "s/_DOMAIN/$DOMAIN/g" $MY_PATH/templates/4a/daemon.php || err+="Sed domaine to daemon.php"
|
||||||
|
sed -i "s/$config\['append_username_message'\] = \"Sender: @username\";/$config\['append_username_message'\] = \"\";/g" $MY_PATH/kalkun/application/config/kalkun_settings.php
|
||||||
|
|
||||||
|
# touch $MY_PATH/kalkun/install
|
||||||
|
|
||||||
|
## Place le dossier kalkun dans /var/www/
|
||||||
|
[[ -d /var/www/kalkun ]] && sudo rm -rf /var/www/kalkun
|
||||||
|
sudo mv $MY_PATH/kalkun /var/www/ || err+="Move kalkun to /var/www"
|
||||||
|
sudo chown -R www-data:www-data /var/www/kalkun || err+="Chown www-data to kalkun"
|
||||||
|
sudo chmod u+x /var/www/kalkun/scripts/*
|
||||||
|
|
||||||
|
## Add daemon launcher in sms_received.sh
|
||||||
|
[[ ! $(grep "Execute Kalkun daemon" $MY_PATH/../sms_received.sh) ]] && sed -i "/^export YOU/i # Execute Kalkun daemon\n/var/www/kalkun/scripts/daemon.sh &\n" $MY_PATH/../sms_received.sh
|
||||||
|
|
||||||
|
## Active gammu in MySQL mode
|
||||||
|
if [[ $(grep "service = files" /etc/gammu-smsdrc) ]]; then
|
||||||
|
echo -e "${c_yellow}Activation de gammu-smsd en mode MySQL...$c_"
|
||||||
|
sudo sed -i "/^service = files/a service = sql\ndriver = native_mysql\nhost = localhost\nuser = gammu\npassword = $pwdDB\ndatabase = gammu" /etc/gammu-smsdrc || err+="Sed gammu-smsd"
|
||||||
|
sudo sed -i "/service = files/d" /etc/gammu-smsdrc || err+="Sed delete in gammu-smsd"
|
||||||
|
$MY_PATH/../debug/gammu-restart.sh || err+="Restart gammu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Config NGINX
|
||||||
|
|
||||||
|
echo -e "${c_yellow}Configuration de Nginx...$c_"
|
||||||
|
[[ ! -d /etc/nginx/def_conf ]] && sudo mkdir /etc/nginx/def_conf/
|
||||||
|
sudo cp $MY_PATH/templates/rproxy/proxypass.conf /etc/nginx/def_conf/ || err+="Copy proxypass.conf"
|
||||||
|
sudo cp $MY_PATH/templates/4a/kalkun.conf /etc/nginx/conf.d/ || err+="Copy kalkun.conf"
|
||||||
|
sudo sed -i "s/_DOMAIN/$DOMAIN/g" /etc/nginx/conf.d/kalkun.conf || err+="Sed domain in kalkun.conf"
|
||||||
|
|
||||||
|
## Active SSL
|
||||||
|
|
||||||
|
[[ ! $noask ]] && printf "${c_yellow}Voulez-vous installer et activer un certificat SSL maintenant pour $DOMAIN ? (o/n) $c_" && read askSSL
|
||||||
|
if [[ $askSSL =~ ^(o|y|yes|oui|Y|O|YES)$ ]]; then
|
||||||
|
if sudo test ! -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then
|
||||||
|
$MY_PATH/ssl.sh certif APP=kalkun DOMAIN=$DOMAIN || err+="Create SSL certification"
|
||||||
|
fi
|
||||||
|
if sudo test -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then
|
||||||
|
$MY_PATH/ssl.sh on APP=kalkun DOMAIN=$DOMAIN || err+="Enable SSL certification"
|
||||||
|
else
|
||||||
|
echo -e "${c_red}Une erreur s'est produite, basculement vers le mode non SSL$c_"
|
||||||
|
$MY_PATH/ssl.sh off APP=kalkun DOMAIN=$DOMAIN || err+="Disable SSL certification"
|
||||||
|
fi
|
||||||
|
http=https
|
||||||
|
sudo sed -i "s/http/https/g" /var/www/kalkun/scripts/daemon.php || err+="Sed http to https in daemon.php"
|
||||||
|
else
|
||||||
|
$MY_PATH/ssl.sh off APP=kalkun DOMAIN=$DOMAIN || err+="Disable SSL certification"
|
||||||
|
http=http
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${c_yellow}Redémarrage de Nginx...$c_"
|
||||||
|
sudo service nginx restart || err+="Restart Nginx"
|
||||||
|
echo -e "${c_yellow}Redémarrage de gammu-smsd...$c_"
|
||||||
|
$MY_PATH/../debug/gammu-restart.sh || err+="Restart gammu"
|
||||||
|
|
||||||
|
if [[ $err ]]; then
|
||||||
|
echo -e "${c_red}Installation incomplète: $err$c_"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${c_green}Kalkun est accessible via l'URL$c_light $http://$DOMAIN$c_"
|
||||||
|
echo -e "${c_green}Les identifiants de connexion par defaut sont:$c_light admin / admin$c_"
|
||||||
|
exit 0
|
||||||
|
fi
|
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
[[ -f $MY_PATH/../.profile ]] && source $MY_PATH/../.profile
|
||||||
|
unset err
|
||||||
|
pwdDB=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 42 | head -n 1)
|
||||||
|
|
||||||
|
args=$@
|
||||||
|
[[ $args =~ noask ]] && noask=o && askSSL=o
|
||||||
|
|
||||||
|
IP=$(ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{ print $2 }')
|
||||||
|
[[ ! $PSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domaine pour PlaySMS (Sinon $IP sera choisi): $c_" && read PSMS_DOMAIN
|
||||||
|
[[ ! $PSMS_DOMAIN ]] && PSMS_DOMAIN=$IP && askSSL=n && noask=o
|
||||||
|
|
||||||
|
|
||||||
|
DOMAIN=$PSMS_DOMAIN
|
||||||
|
|
||||||
|
## Install PHP + MySQL
|
||||||
|
$MY_PATH/1-install_requirements.sh php
|
||||||
|
|
||||||
|
## Create database
|
||||||
|
|
||||||
|
if [[ $(sudo mysql -e "show databases;" | grep gammu) ]]; then
|
||||||
|
pwdDB=$(cat /etc/gammu-smsdrc | grep "password" | grep -v "# " | awk '{ print $3 }')
|
||||||
|
else
|
||||||
|
sudo mysql -e "CREATE DATABASE gammu"
|
||||||
|
sudo mysql -e "CREATE USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
|
||||||
|
sudo mysql -e "GRANT ALL PRIVILEGES ON gammu.* TO 'gammu'@'localhost';"
|
||||||
|
sudo mysql -e "FLUSH PRIVILEGES;"
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Clone repo playSMS
|
||||||
|
[[ -d $MY_PATH/playsms ]] && sudo rm -rf $MY_PATH/playsms
|
||||||
|
git clone https://github.com/antonraharja/playSMS.git $MY_PATH/playsms
|
||||||
|
|
||||||
|
cp $MY_PATH/templates/4b/install-playsms.conf $MY_PATH/playsms/install.conf
|
||||||
|
sed -i "s/_pwdDB/$pwdDB/g" $MY_PATH/playsms/install.conf
|
||||||
|
|
||||||
|
[[ -d /var/www/playsms ]] && sudo rm -rf /var/www/playsms
|
||||||
|
sudo chmod u+x $MY_PATH/playsms/install-playsms.sh
|
||||||
|
cd $MY_PATH/playsms
|
||||||
|
sed -i "s/read /confirm=y; #read /g" install-playsms.sh
|
||||||
|
sudo ./install-playsms.sh
|
||||||
|
sudo sed -i "/ishttps/d" /var/www/playsms/config.php
|
||||||
|
sudo sed -i "/http or https*/a \$core_config['ishttps'] = true;" /var/www/playsms/config.php
|
||||||
|
[[ -d $MY_PATH/playsms ]] && sudo rm -rf $MY_PATH/playsms
|
||||||
|
cd $MY_PATH
|
||||||
|
|
||||||
|
## Start playsmsd on boot
|
||||||
|
sudo /usr/local/bin/playsmsd start
|
||||||
|
|
||||||
|
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
|
||||||
|
else
|
||||||
|
echo "/usr/local/bin/playsmsd start" | sudo tee /etc/rc.local
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
if [[ $(sudo playsmsd status) =~ "is running" ]]; then
|
||||||
|
echo -e "${c_green}playSMS a été installé correctement et le daemon est démarré =)$c_"
|
||||||
|
else
|
||||||
|
echo -e "${c_red}Une erreur est survenu$c_"
|
||||||
|
err=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Config NGINX
|
||||||
|
|
||||||
|
[[ ! -d /etc/nginx/def_conf ]] && sudo mkdir /etc/nginx/def_conf/
|
||||||
|
sudo cp $MY_PATH/templates/rproxy/proxypass.conf /etc/nginx/def_conf/
|
||||||
|
sudo cp $MY_PATH/templates/4b/playsms.conf /etc/nginx/conf.d/
|
||||||
|
sudo sed -i "s/_DOMAIN/$DOMAIN/" /etc/nginx/conf.d/playsms.conf
|
||||||
|
|
||||||
|
## Active SSL
|
||||||
|
|
||||||
|
echo -e "${c_yellow}playSMS ne fonctionne pas sans certifcat SSL.$c_"
|
||||||
|
[[ ! $noask ]] && printf "${c_yellow}Voulez-vous installer et activer un certificat SSL maintenant pour $DOMAIN ? (o/n) $c_" && read askSSL
|
||||||
|
if [[ $askSSL =~ ^(o|y|yes|oui|Y|O|YES)$ ]]; then
|
||||||
|
$MY_PATH/ssl.sh certif APP=playsms DOMAIN=$DOMAIN
|
||||||
|
if sudo test -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then
|
||||||
|
$MY_PATH/ssl.sh on APP=playsms DOMAIN=$DOMAIN
|
||||||
|
else
|
||||||
|
echo -e "${c_red}Une erreur s'est produite, basculement vers le mode non SSL$c_"
|
||||||
|
$MY_PATH/ssl.sh off APP=playsms DOMAIN=$DOMAIN
|
||||||
|
fi
|
||||||
|
http=https
|
||||||
|
else
|
||||||
|
$MY_PATH/ssl.sh off APP=playsms DOMAIN=$DOMAIN
|
||||||
|
http=http
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo service nginx restart
|
||||||
|
|
||||||
|
if [[ $err ]]; then
|
||||||
|
echo -e "${c_red}Installation incomplète$c_"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo -e "${c_green}PlaySMS est accessible via l'URL $http://$DOMAIN$c_"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
source $MY_PATH/../.install/.GPATH
|
||||||
|
|
||||||
|
GPATHS=$(echo $GPATH | sed 's./.\\/.g')
|
||||||
|
|
||||||
|
sudo cp $MY_PATH/templates/5/youtube-dl.php $GPATH/www/rompr/REC/youtube-dl.php
|
||||||
|
sudo sed -i "s/_GPATH/$GPATHS/g" $GPATH/www/rompr/REC/youtube-dl.php
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
# Tout les reste ...
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f ~/.bash_aliases && ! -z $(cat ~/.bash_aliases | grep c_red) ]] && echo "Les couleurs sont déjà déclarés dans l'environnement" && exit 1
|
||||||
|
|
||||||
|
echo 'export c_blinkfast="\033[6m"
|
||||||
|
export c_light="\033[1m"
|
||||||
|
export c_white_bg="\033[47m"
|
||||||
|
export c_blue="\033[34m"
|
||||||
|
export c_red_bg="\033[41m"
|
||||||
|
export c_hide="\033[8m"
|
||||||
|
export c_purple_bg="\033[45m"
|
||||||
|
export c_yellow_bg="\033[43m"
|
||||||
|
export c_dark="\033[2m"
|
||||||
|
export c_reverse="003[7m"
|
||||||
|
export c_underline="\033[4m"
|
||||||
|
export c_blinkslow="\033[5m"
|
||||||
|
export c_red="\033[31m"
|
||||||
|
export c_white="\033[37m"
|
||||||
|
export c_cyan_bg="\033[46m"
|
||||||
|
export c_italic="\033[3m"
|
||||||
|
export c_black="\033[30m"
|
||||||
|
export c_cross="\033[9m"
|
||||||
|
export c_green="\033[32m"
|
||||||
|
export c_purple="\033[35m"
|
||||||
|
export c_="\033[0m"
|
||||||
|
export c_cyan="\033[36m"
|
||||||
|
export c_black_bg="\033[40m"
|
||||||
|
export c_yellow="\033[33m"
|
||||||
|
export c_blue_bg="\033[44m"
|
||||||
|
export c_green_bg="\033[42m"' >> ~/.bash_aliases
|
||||||
|
|
||||||
|
source ~/.bash_aliases
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
### Vars
|
||||||
|
args=$(echo $@ | tr " " "\n")
|
||||||
|
|
||||||
|
if [[ "$args" =~ "DOMAIN=" ]]; then
|
||||||
|
DOMAIN=$(echo "$args" | grep "\<DOMAIN=" | awk -F '=' '{ print $2 }')
|
||||||
|
else
|
||||||
|
echo "Veuillez sélectionner un domaine avec DOMAIN=mondommain.com"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$args" =~ "APP=" ]]; then
|
||||||
|
APP=$(echo "$args" | grep "\<APP=" | awk -F '=' '{ print $2 }')
|
||||||
|
else
|
||||||
|
echo "Veuillez sélectionner une application avec APP=monapp"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
action=$(echo "$args" | grep -v "=")
|
||||||
|
[[ ! $action =~ ^(on|off|certif)$ ]] && echo "Veuillez choisir on, off ou certif pour créer un certificat ssl" && exit 1
|
||||||
|
###
|
||||||
|
|
||||||
|
install_certbot(){
|
||||||
|
sudo apt update
|
||||||
|
if [[ $(grep -E 'stretch|buster' /etc/os-release) ]]; then
|
||||||
|
sudo apt install certbot python-certbot-nginx -y
|
||||||
|
elif [[ $(grep -E '16.|17.|18.|19.' /etc/os-release) ]]; then
|
||||||
|
sudo apt install software-properties-common
|
||||||
|
sudo add-apt-repository universe
|
||||||
|
sudo add-apt-repository ppa:certbot/certbot
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install certbot python-certbot-nginx
|
||||||
|
else
|
||||||
|
echo "OS non supporté pour certbot." && exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_certificate() {
|
||||||
|
sudo certbot --nginx certonly --non-interactive --agree-tos -m $USER@$DOMAIN -d $DOMAIN && echo "Le certificat de $DOMAIN a bien été déployé" || echo "Une erreur s'est produite lors de la création du certificat SSL"
|
||||||
|
|
||||||
|
## Cronification
|
||||||
|
[[ ! -e /opt/scripts ]] && sudo mkdir /opt/scripts
|
||||||
|
sudo cp $MY_PATH/templates/rproxy/ssl_renew.sh /opt/scripts/
|
||||||
|
[[ -z $(sudo crontab -l | grep "/opt/scripts/ssl_renew.sh") ]] && (sudo crontab -l ; sudo echo "12 2 * * 1 /opt/scripts/ssl_renew.sh") | sudo crontab -u root -
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case $action in
|
||||||
|
on)
|
||||||
|
sudo sed -i 's/ #if/ if/g' /etc/nginx/conf.d/$APP.conf
|
||||||
|
sudo sed -i 's/ #add/ add/g' /etc/nginx/conf.d/$APP.conf
|
||||||
|
|
||||||
|
sudo sed -i "s/listen 443;/listen 443 ssl;/g" /etc/nginx/conf.d/$APP.conf
|
||||||
|
[[ ! -d /etc/nginx/includes ]] && sudo mkdir /etc/nginx/includes
|
||||||
|
sudo cp $MY_PATH/templates/rproxy/ssl.conf /etc/nginx/includes/
|
||||||
|
sudo sed -i "/Content-Security-Policy/a \ include includes/ssl.conf;\n ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;" /etc/nginx/conf.d/$APP.conf
|
||||||
|
;;
|
||||||
|
|
||||||
|
off)
|
||||||
|
sudo sed -i "s/ if/ #if/g" /etc/nginx/conf.d/$APP.conf
|
||||||
|
sudo sed -i "s/ add/ #add/g" /etc/nginx/conf.d/$APP.conf
|
||||||
|
|
||||||
|
sudo sed -i "/ssl.conf;/d" /etc/nginx/conf.d/$APP.conf
|
||||||
|
sudo sed -i "/ssl_certificate/d" /etc/nginx/conf.d/$APP.conf
|
||||||
|
;;
|
||||||
|
certif)
|
||||||
|
[[ ! $(which certbot) ]] && install_certbot
|
||||||
|
if sudo test ! -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then create_certificate; fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
|
@ -0,0 +1,6 @@
|
||||||
|
ADMINPSEUDO=_ADMINPSEUDO
|
||||||
|
ADMINPHONE=_ADMINPHONE
|
||||||
|
MASTERPHONE=_MASTERPHONE
|
||||||
|
ADRESSE="_ADRESSE"
|
||||||
|
PIN=_PIN
|
||||||
|
KSMS_DOMAIN=
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Configuration file for Gammu SMS Daemon
|
||||||
|
|
||||||
|
# Gammu library configuration, see gammurc(5)
|
||||||
|
[gammu]
|
||||||
|
# Please configure this!
|
||||||
|
port = /dev/ttyUSB0
|
||||||
|
synchronizetime = yes
|
||||||
|
gammucoding = utf8
|
||||||
|
connection = at
|
||||||
|
# Debugging
|
||||||
|
logformat = textall
|
||||||
|
|
||||||
|
# SMSD configuration, see gammu-smsdrc(5)
|
||||||
|
[smsd]
|
||||||
|
#service = files
|
||||||
|
service = sql
|
||||||
|
driver = native_mysql
|
||||||
|
host = localhost
|
||||||
|
user = playsms
|
||||||
|
password = DlNHoAZQbuCBJYYI0a1TWfu8X6197pDY6GfARLLUSB
|
||||||
|
database = kalkun
|
||||||
|
|
||||||
|
logfile = /var/log/gammu-smsd.log
|
||||||
|
# Increase for debugging information
|
||||||
|
smsc = 33695000695
|
||||||
|
PIN = 1234
|
||||||
|
|
||||||
|
# Paths where messages are stored
|
||||||
|
inboxpath = /var/spool/gammu/inbox/
|
||||||
|
outboxpath = /var/spool/gammu/outbox/
|
||||||
|
sentsmspath = /var/spool/gammu/sent/
|
||||||
|
errorsmspath = /var/spool/gammu/error/
|
||||||
|
|
||||||
|
debuglevel = 4
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=IPFS daemon
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=_USER
|
||||||
|
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient --enable-gc
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Configuration file for Gammu SMS Daemon
|
||||||
|
|
||||||
|
[gammu]
|
||||||
|
port = /dev/ttyAMA0
|
||||||
|
synchronizetime = yes
|
||||||
|
gammucoding = utf8
|
||||||
|
connection = at
|
||||||
|
# Debugging
|
||||||
|
logformat = textall
|
||||||
|
|
||||||
|
# SMSD configuration, see gammu-smsdrc(5)
|
||||||
|
[smsd]
|
||||||
|
service = files
|
||||||
|
|
||||||
|
logfile = /var/log/gammu-smsd.log
|
||||||
|
PIN = _PIN
|
||||||
|
|
||||||
|
# Paths where messages are stored (Not use if service = sql)
|
||||||
|
inboxpath = /var/spool/gammu/inbox/
|
||||||
|
outboxpath = /var/spool/gammu/outbox/
|
||||||
|
sentsmspath = /var/spool/gammu/sent/
|
||||||
|
errorsmspath = /var/spool/gammu/error/
|
||||||
|
|
||||||
|
RunOnReceive = _GPATH/sms_received.sh
|
||||||
|
#IncludeSMSCFile = _GPATH/debug/smsc.txt
|
||||||
|
debuglevel = 3
|
|
@ -0,0 +1,35 @@
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /home/_USER/G1sms+/www/rompr;
|
||||||
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location /g1tag {
|
||||||
|
proxy_pass http://127.0.0.1:81;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /code/ {
|
||||||
|
proxy_pass http://127.0.0.1:8080/ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif/;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ipfs {
|
||||||
|
proxy_pass http://127.0.0.1:8080;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ipns {
|
||||||
|
proxy_pass http://127.0.0.1:8080;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
music_directory "/home/_USER/music"
|
||||||
|
playlist_directory "/home/_USER/playlists"
|
||||||
|
user "$USER"
|
||||||
|
bind_to_address "any"
|
||||||
|
auto_update "yes"
|
||||||
|
zeroconf_enabled "yes"
|
||||||
|
zeroconf_name "CopyLaRadio Music Recorder"
|
||||||
|
|
||||||
|
filesystem_charset "UTF-8"
|
||||||
|
id3v1_encoding "UTF-8"
|
||||||
|
###############################
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "pulse"
|
||||||
|
name "My Pulse Output"
|
||||||
|
server "127.0.0.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "httpd"
|
||||||
|
name "CopyLaRadio HTTP Stream"
|
||||||
|
encoder "lame"
|
||||||
|
port "8000"
|
||||||
|
quality "5.0"
|
||||||
|
# bitrate "128"
|
||||||
|
format "44100:16:1"
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
// Make sure it's run from CLI
|
||||||
|
if(php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) exit("Access Denied.");
|
||||||
|
|
||||||
|
// Please configure this
|
||||||
|
$url = "http://_DOMAIN";
|
||||||
|
|
||||||
|
fclose(fopen($url."/index.php/daemon/message_routine/", "r"));
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Configure this (use absolute path)
|
||||||
|
PHP=/usr/bin/php # php cli path
|
||||||
|
DAEMON=/var/www/kalkun/scripts/daemon.php # daemon.php path
|
||||||
|
|
||||||
|
# Execute
|
||||||
|
$PHP $DAEMON
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/*
|
||||||
|
| -------------------------------------------------------------------
|
||||||
|
| DATABASE CONNECTIVITY SETTINGS
|
||||||
|
| -------------------------------------------------------------------
|
||||||
|
| This file will contain the settings needed to access your database.
|
||||||
|
|
|
||||||
|
| For complete instructions please consult the "Database Connection"
|
||||||
|
| page of the User Guide.
|
||||||
|
|
|
||||||
|
| -------------------------------------------------------------------
|
||||||
|
| EXPLANATION OF VARIABLES
|
||||||
|
| -------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| ['hostname'] The hostname of your database server.
|
||||||
|
| ['username'] The username used to connect to the database
|
||||||
|
| ['password'] The password used to connect to the database
|
||||||
|
| ['database'] The name of the database you want to connect to
|
||||||
|
| ['dbdriver'] The database type. ie: mysql. Currently supported:
|
||||||
|
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
||||||
|
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||||
|
| to the table name when using the Active Record class
|
||||||
|
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
||||||
|
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
||||||
|
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
||||||
|
| ['cachedir'] The path to the folder where cache files should be stored
|
||||||
|
| ['char_set'] The character set used in communicating with the database
|
||||||
|
| ['dbcollat'] The character collation used in communicating with the database
|
||||||
|
|
|
||||||
|
| The $active_group variable lets you choose which connection group to
|
||||||
|
| make active. By default there is only one group (the "default" group).
|
||||||
|
|
|
||||||
|
| The $active_record variables lets you determine whether or not to load
|
||||||
|
| the active record class
|
||||||
|
*/
|
||||||
|
|
||||||
|
$active_group = "default";
|
||||||
|
$active_record = TRUE;
|
||||||
|
|
||||||
|
$db['default']['hostname'] = "127.0.0.1";
|
||||||
|
|
||||||
|
// MySQL
|
||||||
|
$db['default']['username'] = "gammu";
|
||||||
|
$db['default']['password'] = "_PWD";
|
||||||
|
$db['default']['database'] = "gammu";
|
||||||
|
$db['default']['dbdriver'] = "mysqli";
|
||||||
|
|
||||||
|
$db['default']['dbprefix'] = "";
|
||||||
|
$db['default']['pconnect'] = FALSE;
|
||||||
|
$db['default']['db_debug'] = TRUE;
|
||||||
|
$db['default']['cache_on'] = FALSE;
|
||||||
|
$db['default']['cachedir'] = "";
|
||||||
|
$db['default']['char_set'] = "utf8";
|
||||||
|
$db['default']['dbcollat'] = "utf8_general_ci";
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file database.php */
|
||||||
|
/* Location: ./application/config/database.php */
|
|
@ -0,0 +1,38 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen 443;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
server_name _DOMAIN;
|
||||||
|
|
||||||
|
#add_header Content-Security-Policy upgrade-insecure-requests;
|
||||||
|
#if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; }
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri/ $uri /index.php?/$request_uri; # =404;
|
||||||
|
include /etc/nginx/def_conf/proxypass.conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
index index.php index.html;
|
||||||
|
root /var/www/kalkun;
|
||||||
|
|
||||||
|
# set expiration of assets to MAX for caching
|
||||||
|
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
|
||||||
|
expires max;
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# php parsing
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/nginx/kalkun_error.log;
|
||||||
|
access_log /var/log/nginx/kalkun_access.log;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,340 @@
|
||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 3.2.0.1
|
||||||
|
-- http://www.phpmyadmin.net
|
||||||
|
--
|
||||||
|
-- Host: localhost
|
||||||
|
-- Generation Time: Feb 22, 2011 at 05:38 PM
|
||||||
|
-- Server version: 5.1.37
|
||||||
|
-- PHP Version: 5.3.0
|
||||||
|
|
||||||
|
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Database: `kalkun`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `kalkun`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `kalkun` (
|
||||||
|
`version` text NOT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `sms_used`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sms_used` (
|
||||||
|
`id_sms_used` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`sms_date` date NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`out_sms_count` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`in_sms_count` int(11) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id_sms_used`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user` (
|
||||||
|
`id_user` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`username` varchar(12) NOT NULL,
|
||||||
|
`realname` varchar(100) NOT NULL,
|
||||||
|
`password` varchar(255) NOT NULL,
|
||||||
|
`phone_number` varchar(15) NOT NULL,
|
||||||
|
`level` enum('admin','user') NOT NULL DEFAULT 'user',
|
||||||
|
PRIMARY KEY (`id_user`),
|
||||||
|
UNIQUE KEY `username` (`username`),
|
||||||
|
UNIQUE KEY `phone_number` (`phone_number`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `user`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `user` (`id_user`, `username`, `realname`, `password`, `phone_number`, `level`) VALUES
|
||||||
|
(1, 'admin', 'G1Admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', '0600000000', 'admin');
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_folders`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_folders` (
|
||||||
|
`id_folder` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(50) NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_folder`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `user_folders`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `user_folders` (`id_folder`, `name`, `id_user`) VALUES
|
||||||
|
(1, 'inbox', 0),
|
||||||
|
(2, 'outbox', 0),
|
||||||
|
(3, 'sent_items', 0),
|
||||||
|
(4, 'draft', 0),
|
||||||
|
(5, 'Trash', 0),
|
||||||
|
(6, 'Spam', 0);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_inbox` (
|
||||||
|
`id_inbox` int(11) NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`trash` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id_inbox`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_outbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_outbox` (
|
||||||
|
`id_outbox` int(11) NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_outbox`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_sentitems`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_sentitems` (
|
||||||
|
`id_sentitems` int(11) NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`trash` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id_sentitems`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_settings`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_settings` (
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`theme` varchar(10) NOT NULL DEFAULT 'blue',
|
||||||
|
`signature` varchar(50) NOT NULL,
|
||||||
|
`permanent_delete` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`paging` int(2) NOT NULL DEFAULT '10',
|
||||||
|
`bg_image` varchar(50) NOT NULL,
|
||||||
|
`delivery_report` enum('default','yes','no') NOT NULL DEFAULT 'default',
|
||||||
|
`language` varchar(20) NOT NULL DEFAULT 'french',
|
||||||
|
`conversation_sort` enum('asc','desc') NOT NULL DEFAULT 'asc',
|
||||||
|
`country_code` varchar(2) NOT NULL DEFAULT 'FR',
|
||||||
|
PRIMARY KEY (`id_user`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `user_settings`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `user_settings` (`id_user`, `theme`, `signature`, `permanent_delete`, `paging`, `bg_image`, `delivery_report`, `language`, `conversation_sort`) VALUES
|
||||||
|
(1, 'green', 'false;--\nVotre signature ici', 'false', 20, 'true;background.jpg', 'default' , 'french', 'asc');
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Alter table structure for table `inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE `inbox` ADD `id_folder` INT( 11 ) NOT NULL DEFAULT '1',
|
||||||
|
ADD `readed` ENUM( 'false', 'true' ) NOT NULL DEFAULT 'false';
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Alter table structure for table `sentitems`
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE `sentitems` ADD `id_folder` INT( 11 ) NOT NULL DEFAULT '3';
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
-- mulai versi db 16, pbk dan pbk__groups dihapus di gammu
|
||||||
|
--
|
||||||
|
-- Alter table structure for table `pbk`
|
||||||
|
--
|
||||||
|
CREATE TABLE `pbk` (
|
||||||
|
`ID` integer NOT NULL auto_increment,
|
||||||
|
`GroupID` integer NOT NULL default '-1',
|
||||||
|
`Name` text NOT NULL,
|
||||||
|
`Number` text NOT NULL,
|
||||||
|
PRIMARY KEY (`ID`)
|
||||||
|
);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `pbk`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `pbk_groups`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `pbk_groups` (
|
||||||
|
`Name` text NOT NULL,
|
||||||
|
`ID` integer NOT NULL auto_increment,
|
||||||
|
PRIMARY KEY `ID` (`ID`)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE `pbk` ADD `id_user` INT( 11 ) NOT NULL;
|
||||||
|
ALTER TABLE `pbk` ADD `is_public` enum('true','false') NOT NULL DEFAULT 'false';
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Alter table structure for table `pbk_groups`
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE `pbk_groups` ADD `id_user` INT( 11 ) NOT NULL;
|
||||||
|
ALTER TABLE `pbk_groups` ADD `is_public` enum('true','false') NOT NULL DEFAULT 'false';
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_group`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_group` (
|
||||||
|
`id_group` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_pbk` int(11) NOT NULL,
|
||||||
|
`id_pbk_groups` int(11) NOT NULL,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_group`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_templates`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_templates` (
|
||||||
|
`id_template` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`Name` varchar(64) NOT NULL,
|
||||||
|
`Message` text NOT NULL,
|
||||||
|
PRIMARY KEY (`id_template`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `b8_wordlist`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `b8_wordlist` (
|
||||||
|
`token` varchar(255) character set utf8 collate utf8_bin NOT NULL,
|
||||||
|
`count` varchar(255) default NULL,
|
||||||
|
PRIMARY KEY (`token`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
INSERT INTO `b8_wordlist` VALUES ('bayes*dbversion', '2');
|
||||||
|
INSERT INTO `b8_wordlist` VALUES ('bayes*texts.ham', '0');
|
||||||
|
INSERT INTO `b8_wordlist` VALUES ('bayes*texts.spam', '0');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `plugins`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `plugins` (
|
||||||
|
`plugin_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`plugin_system_name` varchar(255) NOT NULL,
|
||||||
|
`plugin_name` varchar(255) NOT NULL,
|
||||||
|
`plugin_uri` varchar(120) DEFAULT NULL,
|
||||||
|
`plugin_version` varchar(30) NULL,
|
||||||
|
`plugin_description` text,
|
||||||
|
`plugin_author` varchar(120) DEFAULT NULL,
|
||||||
|
`plugin_author_uri` varchar(120) DEFAULT NULL,
|
||||||
|
`plugin_data` longtext,
|
||||||
|
PRIMARY KEY (`plugin_id`),
|
||||||
|
UNIQUE KEY `plugin_index` (`plugin_system_name`) USING BTREE
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_forgot_password`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_forgot_password` (
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`token` varchar(255) NOT NULL,
|
||||||
|
`valid_until` datetime NOT NULL,
|
||||||
|
PRIMARY KEY (`id_user`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `user_filters`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_filters` (
|
||||||
|
`id_filter` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_user` int(11) NOT NULL,
|
||||||
|
`from` varchar(15) NOT NULL,
|
||||||
|
`has_the_words` varchar(50) NOT NULL,
|
||||||
|
`id_folder` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_filter`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `ci_sessions` (
|
||||||
|
`id` varchar(40) NOT NULL,
|
||||||
|
`ip_address` varchar(45) NOT NULL,
|
||||||
|
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`data` blob NOT NULL,
|
||||||
|
KEY `ci_sessions_timestamp` (`timestamp`)
|
||||||
|
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Insert default contact group
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `pbk_groups` (`ID`, `Name`, `id_user`, `is_public`) VALUES
|
||||||
|
('1', 'Blois', '1', 'false');
|
|
@ -0,0 +1,227 @@
|
||||||
|
--
|
||||||
|
-- Database for Gammu SMSD
|
||||||
|
--
|
||||||
|
-- In case you get errors about not supported charset, please
|
||||||
|
-- replace utf8mb4 with utf8.
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `gammu`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `gammu` (
|
||||||
|
`Version` integer NOT NULL default '0' PRIMARY KEY
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `gammu`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `gammu` (`Version`) VALUES (16);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `inbox` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`ReceivingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`Text` text NOT NULL,
|
||||||
|
`SenderNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text NOT NULL,
|
||||||
|
`SMSCNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Class` integer NOT NULL default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL auto_increment,
|
||||||
|
`RecipientID` text NOT NULL,
|
||||||
|
`Processed` enum('false','true') NOT NULL default 'false',
|
||||||
|
PRIMARY KEY `ID` (`ID`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `outbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `outbox` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`SendingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`SendBefore` time NOT NULL DEFAULT '23:59:59',
|
||||||
|
`SendAfter` time NOT NULL DEFAULT '00:00:00',
|
||||||
|
`Text` text,
|
||||||
|
`DestinationNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text,
|
||||||
|
`Class` integer default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL auto_increment,
|
||||||
|
`MultiPart` enum('false','true') default 'false',
|
||||||
|
`RelativeValidity` integer default '-1',
|
||||||
|
`SenderID` varchar(255),
|
||||||
|
`SendingTimeOut` timestamp NULL default '0000-00-00 00:00:00',
|
||||||
|
`DeliveryReport` enum('default','yes','no') default 'default',
|
||||||
|
`CreatorID` text NOT NULL,
|
||||||
|
`Retries` int(3) default 0,
|
||||||
|
`Priority` integer default 0,
|
||||||
|
PRIMARY KEY `ID` (`ID`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
|
||||||
|
CREATE INDEX outbox_sender ON outbox(SenderID(250));
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `outbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `outbox_multipart`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `outbox_multipart` (
|
||||||
|
`Text` text,
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text,
|
||||||
|
`Class` integer default '-1',
|
||||||
|
`TextDecoded` text,
|
||||||
|
`ID` integer unsigned NOT NULL default '0',
|
||||||
|
`SequencePosition` integer NOT NULL default '1',
|
||||||
|
PRIMARY KEY (`ID`, `SequencePosition`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `outbox_multipart`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `phones`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `phones` (
|
||||||
|
`ID` text NOT NULL,
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`TimeOut` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`Send` enum('yes','no') NOT NULL default 'no',
|
||||||
|
`Receive` enum('yes','no') NOT NULL default 'no',
|
||||||
|
`IMEI` varchar(35) NOT NULL,
|
||||||
|
`IMSI` varchar(35) NOT NULL,
|
||||||
|
`NetCode` varchar(10) default 'ERROR',
|
||||||
|
`NetName` varchar(35) default 'ERROR',
|
||||||
|
`Client` text NOT NULL,
|
||||||
|
`Battery` integer NOT NULL DEFAULT -1,
|
||||||
|
`Signal` integer NOT NULL DEFAULT -1,
|
||||||
|
`Sent` int NOT NULL DEFAULT 0,
|
||||||
|
`Received` int NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`IMEI`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `phones`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `sentitems`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `sentitems` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`SendingDateTime` timestamp NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`DeliveryDateTime` timestamp NULL,
|
||||||
|
`Text` text NOT NULL,
|
||||||
|
`DestinationNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text NOT NULL,
|
||||||
|
`SMSCNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Class` integer NOT NULL default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL default '0',
|
||||||
|
`SenderID` varchar(255) NOT NULL,
|
||||||
|
`SequencePosition` integer NOT NULL default '1',
|
||||||
|
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL default 'SendingOK',
|
||||||
|
`StatusError` integer NOT NULL default '-1',
|
||||||
|
`TPMR` integer NOT NULL default '-1',
|
||||||
|
`RelativeValidity` integer NOT NULL default '-1',
|
||||||
|
`CreatorID` text NOT NULL,
|
||||||
|
PRIMARY KEY (`ID`, `SequencePosition`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
|
||||||
|
CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
|
||||||
|
CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
|
||||||
|
CREATE INDEX sentitems_sender ON sentitems(SenderID(250));
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `sentitems`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Triggers for setting default timestamps
|
||||||
|
--
|
||||||
|
|
||||||
|
DELIMITER //
|
||||||
|
|
||||||
|
CREATE TRIGGER inbox_timestamp BEFORE INSERT ON inbox
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.ReceivingDateTime = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.ReceivingDateTime = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
END;//
|
||||||
|
|
||||||
|
CREATE TRIGGER outbox_timestamp BEFORE INSERT ON outbox
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
IF NEW.SendingTimeOut = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.SendingTimeOut = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
END;//
|
||||||
|
|
||||||
|
CREATE TRIGGER phones_timestamp BEFORE INSERT ON phones
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
IF NEW.TimeOut = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.TimeOut = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
END;//
|
||||||
|
|
||||||
|
CREATE TRIGGER sentitems_timestamp BEFORE INSERT ON sentitems
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.InsertIntoDB = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.InsertIntoDB = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
IF NEW.SendingDateTime = '0000-00-00 00:00:00' THEN
|
||||||
|
SET NEW.SendingDateTime = CURRENT_TIMESTAMP();
|
||||||
|
END IF;
|
||||||
|
END;//
|
||||||
|
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,180 @@
|
||||||
|
--
|
||||||
|
-- Database for Gammu SMSD
|
||||||
|
--
|
||||||
|
-- In case you get errors about not supported charset, please
|
||||||
|
-- replace utf8mb4 with utf8.
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `gammu`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `gammu` (
|
||||||
|
`Version` integer NOT NULL default '0' PRIMARY KEY
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `gammu`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `gammu` (`Version`) VALUES (17);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `inbox` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`ReceivingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`Text` text NOT NULL,
|
||||||
|
`SenderNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text NOT NULL,
|
||||||
|
`SMSCNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Class` integer NOT NULL default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL auto_increment,
|
||||||
|
`RecipientID` text NOT NULL,
|
||||||
|
`Processed` enum('false','true') NOT NULL default 'false',
|
||||||
|
`Status` integer NOT NULL default '-1',
|
||||||
|
PRIMARY KEY `ID` (`ID`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `inbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `outbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `outbox` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`SendBefore` time NOT NULL DEFAULT '23:59:59',
|
||||||
|
`SendAfter` time NOT NULL DEFAULT '00:00:00',
|
||||||
|
`Text` text,
|
||||||
|
`DestinationNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text,
|
||||||
|
`Class` integer default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL auto_increment,
|
||||||
|
`MultiPart` enum('false','true') default 'false',
|
||||||
|
`RelativeValidity` integer default '-1',
|
||||||
|
`SenderID` varchar(255),
|
||||||
|
`SendingTimeOut` timestamp NULL default CURRENT_TIMESTAMP,
|
||||||
|
`DeliveryReport` enum('default','yes','no') default 'default',
|
||||||
|
`CreatorID` text NOT NULL,
|
||||||
|
`Retries` int(3) default 0,
|
||||||
|
`Priority` integer default 0,
|
||||||
|
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
|
||||||
|
`StatusCode` integer NOT NULL default '-1',
|
||||||
|
PRIMARY KEY `ID` (`ID`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
|
||||||
|
CREATE INDEX outbox_sender ON outbox(SenderID(250));
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `outbox`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `outbox_multipart`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `outbox_multipart` (
|
||||||
|
`Text` text,
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text,
|
||||||
|
`Class` integer default '-1',
|
||||||
|
`TextDecoded` text,
|
||||||
|
`ID` integer unsigned NOT NULL default '0',
|
||||||
|
`SequencePosition` integer NOT NULL default '1',
|
||||||
|
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
|
||||||
|
`StatusCode` integer NOT NULL default '-1',
|
||||||
|
PRIMARY KEY (`ID`, `SequencePosition`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `outbox_multipart`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `phones`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `phones` (
|
||||||
|
`ID` text NOT NULL,
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`TimeOut` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`Send` enum('yes','no') NOT NULL default 'no',
|
||||||
|
`Receive` enum('yes','no') NOT NULL default 'no',
|
||||||
|
`IMEI` varchar(35) NOT NULL,
|
||||||
|
`IMSI` varchar(35) NOT NULL,
|
||||||
|
`NetCode` varchar(10) default 'ERROR',
|
||||||
|
`NetName` varchar(35) default 'ERROR',
|
||||||
|
`Client` text NOT NULL,
|
||||||
|
`Battery` integer NOT NULL DEFAULT -1,
|
||||||
|
`Signal` integer NOT NULL DEFAULT -1,
|
||||||
|
`Sent` int NOT NULL DEFAULT 0,
|
||||||
|
`Received` int NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`IMEI`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `phones`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `sentitems`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sentitems` (
|
||||||
|
`UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||||
|
`InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`DeliveryDateTime` timestamp NULL,
|
||||||
|
`Text` text NOT NULL,
|
||||||
|
`DestinationNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
|
||||||
|
`UDH` text NOT NULL,
|
||||||
|
`SMSCNumber` varchar(20) NOT NULL default '',
|
||||||
|
`Class` integer NOT NULL default '-1',
|
||||||
|
`TextDecoded` text NOT NULL,
|
||||||
|
`ID` integer unsigned NOT NULL default '0',
|
||||||
|
`SenderID` varchar(255) NOT NULL,
|
||||||
|
`SequencePosition` integer NOT NULL default '1',
|
||||||
|
`Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL default 'SendingOK',
|
||||||
|
`StatusError` integer NOT NULL default '-1',
|
||||||
|
`TPMR` integer NOT NULL default '-1',
|
||||||
|
`RelativeValidity` integer NOT NULL default '-1',
|
||||||
|
`CreatorID` text NOT NULL,
|
||||||
|
`StatusCode` integer NOT NULL default '-1',
|
||||||
|
PRIMARY KEY (`ID`, `SequencePosition`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
|
||||||
|
CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
|
||||||
|
CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
|
||||||
|
CREATE INDEX sentitems_sender ON sentitems(SenderID(250));
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Dumping data for table `sentitems`
|
||||||
|
--
|
|
@ -0,0 +1,43 @@
|
||||||
|
# MySQL database username
|
||||||
|
DBUSER="gammu"
|
||||||
|
|
||||||
|
# MySQL database password
|
||||||
|
DBPASS="_pwdDB"
|
||||||
|
|
||||||
|
# MySQL database name
|
||||||
|
DBNAME="gammu"
|
||||||
|
|
||||||
|
# MySQL database host
|
||||||
|
DBHOST="localhost"
|
||||||
|
|
||||||
|
# MySQL database port
|
||||||
|
DBPORT="3306"
|
||||||
|
|
||||||
|
# Web server's user, for example apache2 user by default is www-data
|
||||||
|
# note: please make sure your web server user
|
||||||
|
WEBSERVERUSER="www-data"
|
||||||
|
|
||||||
|
# Web server's group, for example apache2 group by default is www-data
|
||||||
|
# note: please make sure your web server group
|
||||||
|
WEBSERVERGROUP="www-data"
|
||||||
|
|
||||||
|
# Path to playSMS extracted source files
|
||||||
|
PATHSRC="$(pwd)"
|
||||||
|
|
||||||
|
# Path to playSMS web files
|
||||||
|
# note: please make sure your web root path, in this example its /var/www/html
|
||||||
|
PATHWEB="/var/www/playsms"
|
||||||
|
|
||||||
|
# Path to playSMS additional files
|
||||||
|
PATHLIB="/var/www/playsms/lib/"
|
||||||
|
|
||||||
|
# Path to playSMS daemon and other binary files
|
||||||
|
PATHBIN="/usr/local/bin"
|
||||||
|
|
||||||
|
# Path to playSMS log files
|
||||||
|
PATHLOG="/var/log/playsms"
|
||||||
|
|
||||||
|
# Path to playSMS daemon configuration file
|
||||||
|
# note: this example will create playsmsd.conf in /etc
|
||||||
|
PATHCONF="/etc"
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen 443;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
server_name _DOMAIN;
|
||||||
|
|
||||||
|
add_header Content-Security-Policy upgrade-insecure-requests;
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
|
||||||
|
#if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; }
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri/ $uri /index.php?/$request_uri; # =404;
|
||||||
|
include /etc/nginx/def_conf/proxypass.conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
index index.php index.html;
|
||||||
|
root /var/www/playsms;
|
||||||
|
|
||||||
|
# set expiration of assets to MAX for caching
|
||||||
|
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
|
||||||
|
expires max;
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# php parsing
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/nginx/playsms_error.log;
|
||||||
|
access_log /var/log/nginx/playsms_access.log;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
DONE!!!? WRITE THAT CODE IN infobar2.js : arrount line 158 before "return lines;"
|
||||||
|
// ZEEBOX HACK ZONE
|
||||||
|
var reclink = '/REC/youtube-dl.php?q=REC&artist=' + escape(encodeURIComponent(npinfo.Artist)) + '&title=' + escape(encodeURIComponent(npinfo.Title)) + '&radio='+ escape(encodeURIComponent(npinfo.stream)) +'&maxResults=1';
|
||||||
|
var zcopylink = ' <a id="REC" title="Enregistrer sur Youtube" href="#" onclick=\'javascript:window.open("'+ reclink +'","REC","menubar=no, scrollbars=no, top=10, left=10, width=384, height=546");return false;\'>[REC]</a>';
|
||||||
|
zcopylink += ' <a title="RECHERCHE LIBRE" href="/REC/youtube-dl.php" target="youtube">*</a>';
|
||||||
|
lines[0].text += zcopylink;
|
||||||
|
// ZEEBOX HACK ZONE
|
||||||
|
*/
|
||||||
|
// RUN CLI if($argc>1) parse_str(implode('&',array_slice($argv, 1)), $_REQUEST);
|
||||||
|
$search=$radio=$artist=$title=$lnk=$lnkform=$cmd=$len="";
|
||||||
|
$search = trim(urldecode($_REQUEST['q']));
|
||||||
|
|
||||||
|
$radio = urldecode($_REQUEST['radio']);
|
||||||
|
$artist = urldecode($_REQUEST['artist']);
|
||||||
|
$title = urldecode($_REQUEST['title']);
|
||||||
|
$lnk = trim(urldecode($_REQUEST['lnk']));
|
||||||
|
$cmd="$radio|$artist|$title";
|
||||||
|
$len=strlen($artist.$title);
|
||||||
|
|
||||||
|
//$result='<a href="#null" onclick="javascript:window.close();"><img src="/REC/REC.png"></a><br>';
|
||||||
|
$result='<a href="https://www.copylaradio.com" target="copylaradio"><img src="/REC/REC.png"></a><br>';
|
||||||
|
if( $radio == "" ) { $radio = "CopyLaRadio"; }
|
||||||
|
if( $radio == "Nova zz" ) {
|
||||||
|
$artist = "undefined";
|
||||||
|
$title = "undefined";
|
||||||
|
}
|
||||||
|
// Write request for copy.sh triggering
|
||||||
|
if( $search == "REC" ) {
|
||||||
|
///////////////////
|
||||||
|
$result.='<h2>♫ '.$radio.' ♫</h2>';
|
||||||
|
// LINK RECEIVED
|
||||||
|
if ($lnk) {
|
||||||
|
$artist="";
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Lien reçu."');
|
||||||
|
// Not making double request
|
||||||
|
if( ! exec('grep '.escapeshellarg($lnk).' /tmp/ytdl.list') ) {
|
||||||
|
file_put_contents("/tmp/ytdl.list","CopyLibre||$lnk\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
$result.='<p><a href="'.$lnk.'" target="check">LIEN: '.$lnk.'</a></p>';
|
||||||
|
///////////////////
|
||||||
|
// TRACK COPY (not for undefined or local file)
|
||||||
|
} else if ($radio && $artist != $title && $artist != "undefined" && $title != "undefined" && strlen(explode(".", $title)[1]) != 3 && explode(".", $title)[1] != "opus" ) {
|
||||||
|
// Not making double request
|
||||||
|
if( ! exec('grep '.escapeshellarg($cmd).' /tmp/ytdl.list') ) {
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Enregistrement ajouté."');
|
||||||
|
file_put_contents("/tmp/ytdl.list","$cmd\n", FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Copie déjà lancée"');
|
||||||
|
}
|
||||||
|
$result.='<a style="color:#FFFFFF" href="https://www.youtube.com/results?search_query='.urlencode($artist).'%20'.urlencode($title).'" target="check">
|
||||||
|
<h4>'.$artist.' / '.$title.'</h4>
|
||||||
|
</a>';
|
||||||
|
///////////////////
|
||||||
|
// RADIO EXTERNAL TRACK SCRAPER
|
||||||
|
} else if($radio != "" && $artist == "undefined" && $title == "undefined" ){
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Recherche externe pour '.$radio.'"');
|
||||||
|
file_put_contents("/tmp/youtube-dl.log", "_GPATH/_CopyLaRadio/libradio/".escapeshellcmd($radio).".php".PHP_EOL, FILE_APPEND);
|
||||||
|
if ( file_exists("_GPATH/_CopyLaRadio/libradio/".escapeshellcmd($radio).".php") ) {
|
||||||
|
file_put_contents("/tmp/ytdl.list","$radio||".PHP_EOL, FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Aucun module"');
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
shell_exec('_GPATH/_CopyLaRadio/parle.sh "Identification imprécise. Podcast? Fichier local?"');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$ytform = '<form action="/REC/youtube-dl.php" method="GET">
|
||||||
|
<div>
|
||||||
|
<h3>ARTISTE: <input type="search" id="artist" name="artist" size="17" placeholder="Indiquez un artiste" value="'.$artist.'"></h3>
|
||||||
|
<h3>TITRE: <input type="search" id="title" name="title" size="20" placeholder="Titre de la chanson" value="'.$title.'"></h3>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" id="radio" name="radio" value="'.$radio.'">
|
||||||
|
<input type="hidden" id="q" name="q" value="REC">
|
||||||
|
<br>
|
||||||
|
<input type="submit" value="♫ Copie Youtube ♫">
|
||||||
|
</form>
|
||||||
|
';
|
||||||
|
|
||||||
|
$lnkform.='<form action="/REC/youtube-dl.php" method="GET">
|
||||||
|
<a href="https://youtube.com" target="search"><img src="/REC/youtube.png"></a>
|
||||||
|
<p><h1>youtube-dl</h1>
|
||||||
|
<a style="color:#FFFFFF" href="https://ytdl-org.github.io/youtube-dl/supportedsites.html" target="_blank">- Sites compatibles -</a>
|
||||||
|
<input type="search" id="lnk" name="lnk" placeholder="Inscrivez le lien à copier" value="" size="40">
|
||||||
|
<input type="hidden" id="q" name="q" value="REC">
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<input type="submit" value="Copie du Lien">
|
||||||
|
</div>
|
||||||
|
</form>';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="fred" >
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
|
||||||
|
<title><?php echo $search;?> - Recherche YouTube & Copie privée</title>
|
||||||
|
<link href="/REC/bootstrap.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body style='background: url("/REC/fond.jpg") no-repeat scroll center center / cover rgb(0, 0, 0); color:#FFFFFF;'>
|
||||||
|
<section class="content-section text-center">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="container" id="result" >
|
||||||
|
<div class="col-lg-8 col-lg-offset-2 page-scroll">
|
||||||
|
<ul>
|
||||||
|
<?php echo $result; ?>
|
||||||
|
<hr>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<?php echo $ytform; ?>
|
||||||
|
<hr>
|
||||||
|
<?php echo $lnkform; ?>
|
||||||
|
<hr>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
##################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
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/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
|
||||||
|
|
||||||
|
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
|
||||||
|
function log () {
|
||||||
|
# log ($1=text)
|
||||||
|
if [ "$DOLOG" == "YES" ]
|
||||||
|
then
|
||||||
|
echo "$PHONE:$1" >> /tmp/g1sms.log
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################################################
|
||||||
|
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
|
||||||
|
[ `type -t $1`"" == 'file' ]
|
||||||
|
}
|
||||||
|
# ATOMATIC gammu-smsd-inject desactivation if no gammu is installed on system
|
||||||
|
if ! fn_exists gammu-smsd-inject; then
|
||||||
|
log ":p) DESACTIVATION ENVOI DE SMS .............."
|
||||||
|
function gammu-smsd-inject () {
|
||||||
|
log "$PHONE: >>> SENDING SMS $4 TO $2 "
|
||||||
|
}
|
||||||
|
else
|
||||||
|
export G1SMS="YES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
||||||
|
cd $GPATH
|
||||||
|
##################################################################
|
||||||
|
# Activate logging to /tmp/g1sms.log (YES/NO)
|
||||||
|
export DOLOG="YES"
|
||||||
|
export CPERROR="NOYES"
|
||||||
|
##################################################################
|
||||||
|
# Country Node Phone international prefix (TODO Worldwide)
|
||||||
|
export COUNTRY="+33"
|
||||||
|
##################################################################
|
||||||
|
# DU has a G1 value changed every 6 month!
|
||||||
|
# ./_DU Updated by cron_CODE.backup.sh
|
||||||
|
if [[ -f "./_DU" ]]; then export DUFACTOR=$(bc <<< "scale=2; $(cat "./_DU") / 100"); else log "__SUB:init.sh: FAILING TO FIND ./_DU EXIT!!!"; exit; fi
|
||||||
|
##################################################################
|
||||||
|
# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents)
|
||||||
|
export COIN="G1"
|
||||||
|
##################################################################
|
||||||
|
# Limit and commission values
|
||||||
|
export LIMIT=2 # Solde minimum = 2 G1
|
||||||
|
# FIXED COMMISSION SYSTEM
|
||||||
|
export COMMISSION=1 # transaction commission amount (G1)
|
||||||
|
export BILLCOM=20
|
||||||
|
##################################################################
|
||||||
|
# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK
|
||||||
|
# PART COMMISSION SYSTEM
|
||||||
|
export SWARMCOMM=10
|
||||||
|
# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES
|
||||||
|
export NODECOMM=10
|
||||||
|
##################################################################
|
||||||
|
# SMS SIM Card Phone Number
|
||||||
|
export MASTERPHONE="_MASTERPHONE"
|
||||||
|
export ADRESSE="_ADRESSE"
|
||||||
|
export G1DAB="NO"
|
||||||
|
##################################################################
|
||||||
|
# ADMIN COMMAND PHONE ORIGIN
|
||||||
|
export ADMINPHONE="_ADMINPHONE"
|
||||||
|
export ADMINPSEUDO="_ADMINPSEUDO"
|
||||||
|
##################################################################
|
||||||
|
# DUNITER/CESIUM+ DEFAULT SERVERS
|
||||||
|
export DUNITER="https://g1.duniter.org"
|
||||||
|
export CESIUM="https://g1.data.le-sou.org"
|
||||||
|
|
||||||
|
# TODO Use latest Silkaj from "sudo fredp3 install silkaj"
|
||||||
|
# export SILKAJ="/usr/local/bin/silkaj"
|
||||||
|
source $GPATH/shell/init_keys.sh
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forward-Proto http;
|
||||||
|
proxy_set_header X-Nginx-Proxy true;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
ssl_session_timeout 4h;
|
||||||
|
ssl_session_cache shared:SSL:50m;
|
||||||
|
|
||||||
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
|
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-CBC-SHA:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
add_header Strict-Transport-Security max-age=15768000;
|
||||||
|
|
||||||
|
ssl_stapling on;
|
||||||
|
ssl_stapling_verify on;
|
||||||
|
|
||||||
|
resolver 8.8.8.8 8.8.4.4 valid=86400;
|
||||||
|
resolver_timeout 10;
|
||||||
|
|
||||||
|
ssl_session_tickets on;
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
log="/var/log/ssl_renew.log"
|
||||||
|
date=$(date +%d-%m-%Y)
|
||||||
|
|
||||||
|
renew=$(certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start")
|
||||||
|
|
||||||
|
echo "####################################################################################" >> $log
|
||||||
|
echo "#################################### $date ####################################" >> $log
|
||||||
|
echo "####################################################################################" >> $log
|
||||||
|
|
||||||
|
echo "$renew" >> $log
|
||||||
|
|
||||||
|
if [[ $renew = *"No hooks were run"* ]]; then
|
||||||
|
echo "Rien n'a été fait" >> $log
|
||||||
|
else
|
||||||
|
sleep 5
|
||||||
|
sudo service nginx stop
|
||||||
|
sleep 1
|
||||||
|
killall nginx
|
||||||
|
sleep 3
|
||||||
|
sudo service nginx restart &>> $log
|
||||||
|
echo "Des certificats ont été renouvellés" >> $log
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
220
README.md
|
@ -1,5 +1,7 @@
|
||||||
# G1sms+
|
# G1sms+
|
||||||
|
|
||||||
|
### Lien du pad : https://pad.p2p.legal/G1sms-install
|
||||||
|
|
||||||
> LE DRAPEAU DE LA MONNAIE LIBRE EST PLANTE DANS LE SYSTEME DE FICHIER INTERPLANETAIRE!! :: [G1Forge / G1FabLab](https://www.g1sms.fr/fr/blog) ::
|
> LE DRAPEAU DE LA MONNAIE LIBRE EST PLANTE DANS LE SYSTEME DE FICHIER INTERPLANETAIRE!! :: [G1Forge / G1FabLab](https://www.g1sms.fr/fr/blog) ::
|
||||||
|
|
||||||
Il s'agit de la seconde version de G1sms. Cette mouture utilise une carte fille GSM (à la place d'un dongle USB) et ajoute une couche de communication inter noeuds grâce à l'utilisation de IPFS.
|
Il s'agit de la seconde version de G1sms. Cette mouture utilise une carte fille GSM (à la place d'un dongle USB) et ajoute une couche de communication inter noeuds grâce à l'utilisation de IPFS.
|
||||||
|
@ -25,19 +27,21 @@ https://www.youtube.com/watch?v=QDnG3Jni7sY
|
||||||
https://www.youtube.com/watch?v=LqV65iPTmnc
|
https://www.youtube.com/watch?v=LqV65iPTmnc
|
||||||
https://www.youtube.com/watch?v=_PVwf9nRAA0
|
https://www.youtube.com/watch?v=_PVwf9nRAA0
|
||||||
|
|
||||||
## Matériel
|
## I. Matériel
|
||||||
|
|
||||||
A découvrir sur la page [G1SMS:small_orange_diamond:](https://www.g1sms.fr/fr/blog/g1smsplus)
|
**A découvrir sur la page [G1SMS:small_orange_diamond:](https://www.g1sms.fr/fr/blog/g1smsplus)**
|
||||||
|
|
||||||
## **Installer Raspbian Stretch** :ice_cream:
|
## II. Préparation
|
||||||
|
|
||||||
* Téléchargez "[Raspbian Stretch Lite](https://www.raspberrypi.org/downloads/raspbian/)" et flashez l'image sur une carte microSD
|
### 1. Installer Raspbian Stretch ou Buster (9 ou 10) :ice_cream:
|
||||||
|
|
||||||
|
* Téléchargez "[Raspbian Buster Lite](https://www.raspberrypi.org/downloads/raspbian/)" et flashez l'image sur une carte microSD
|
||||||
* Installez Raspbian ([comment faire sur un RaspberryPi Zero sans écran?](https://projetsdiy.fr/comment-installer-raspbian-raspberry-pi-zero-sans-ecran-clavier/)).
|
* Installez Raspbian ([comment faire sur un RaspberryPi Zero sans écran?](https://projetsdiy.fr/comment-installer-raspbian-raspberry-pi-zero-sans-ecran-clavier/)).
|
||||||
|
|
||||||
Terminez cette phase par une mise à jour
|
Terminez cette phase par une mise à jour
|
||||||
> **sudo apt update; sudo apt upgrade -y**
|
> **sudo apt update; sudo apt upgrade -y**
|
||||||
|
|
||||||
### 1. Installation carte GSM (pour commandes par SMS)?
|
### 2. Installation carte GSM (pour commandes par SMS)?
|
||||||
|
|
||||||
L'interface de commande par SMS permet d'ouvrir l'usage de la monnaie libre à ceux qui ne possèdent pas de smartphone et n'ont aucun ordinateur connecté à disposition... Et permet l'utilisation du réseau 2G des opérateurs, peut encombré et presque gratuit (1€/ mois chez Free je crois)
|
L'interface de commande par SMS permet d'ouvrir l'usage de la monnaie libre à ceux qui ne possèdent pas de smartphone et n'ont aucun ordinateur connecté à disposition... Et permet l'utilisation du réseau 2G des opérateurs, peut encombré et presque gratuit (1€/ mois chez Free je crois)
|
||||||
|
|
||||||
|
@ -49,7 +53,7 @@ Elles ont besoin d'être testées et d'améliorer leur compatibilité CLI. En fo
|
||||||
|
|
||||||
Les scripts "./shell/cron" en cours d'écriture/test et sont à activer soi-même.
|
Les scripts "./shell/cron" en cours d'écriture/test et sont à activer soi-même.
|
||||||
|
|
||||||
### 2. **Activer le GSM pHAT**
|
### 3. **Activer le GSM pHAT**
|
||||||
|
|
||||||
La carte utilise une connexion UART sur l'interface GPIO du Rpi pour communiquer (en commandes AT). Placer le jumper dans la position B pour activer ce mode. On prendra soin de désactiver la console (tty) établie par le système sur le port série qui rentre en conflit autrement...
|
La carte utilise une connexion UART sur l'interface GPIO du Rpi pour communiquer (en commandes AT). Placer le jumper dans la position B pour activer ce mode. On prendra soin de désactiver la console (tty) établie par le système sur le port série qui rentre en conflit autrement...
|
||||||
|
|
||||||
|
@ -58,7 +62,7 @@ La carte utilise une connexion UART sur l'interface GPIO du Rpi pour communiquer
|
||||||
* Effacer **console=serial0,115200** de **/boot/cmdline.txt**
|
* Effacer **console=serial0,115200** de **/boot/cmdline.txt**
|
||||||
* Redémarrer...
|
* Redémarrer...
|
||||||
|
|
||||||
### 3. Démarrer la carte GSM !
|
### 4. Démarrer la carte GSM !
|
||||||
|
|
||||||
il faudra appuyer 3 secondes sur le bouton d'allumage. Nous allons le faire par un script qui manipule le GPIO.
|
il faudra appuyer 3 secondes sur le bouton d'allumage. Nous allons le faire par un script qui manipule le GPIO.
|
||||||
|
|
||||||
|
@ -80,157 +84,47 @@ il faudra appuyer 3 secondes sur le bouton d'allumage. Nous allons le faire par
|
||||||
Ajouter le lancement de ce script au démarrage (dans /etc/rc.local)
|
Ajouter le lancement de ce script au démarrage (dans /etc/rc.local)
|
||||||
|
|
||||||
|
|
||||||
### 4. Installer gammu et gammu-smsd
|
## III. Installation automatique de Ḡ1sms+ avec ses prérequis (Gammu, IPFS) et ses modules
|
||||||
|
*Pour une installation manuelle: https://pad.p2p.legal/G1sms-install*
|
||||||
|
|
||||||
Afin de dialoguer avec le réseau GSM, recevoir et envoyer des SMS. Nous utiliserons le serveur gammu. Suivre la procédure détaillée ici: https://tutoandco.colas-delmas.fr/software/envoyer-sms-gammu-deamon/
|
### Clonez le dépôt G1sms+
|
||||||
|
sudo apt update && sudo apt install git
|
||||||
|
git clone https://git.p2p.legal/axiom-team/G1sms
|
||||||
|
mv G1sms G1sms+
|
||||||
|
cd G1sms+
|
||||||
|
chmod u+x install.sh
|
||||||
|
|
||||||
sudo apt-get install ppp screen git python3-pip minicom gammu gammu-smsd
|
### Options
|
||||||
sudo usermod -aG gammu pi;
|
./install.sh : Cycle normale, va détecter si les éléments sont installés ne va pas les réinstaller. Demande confirmations, et propose d'installer les outils otionnels
|
||||||
|
./install.sh force : Réinstalle les éléments même si ils sont déjà installés
|
||||||
Vérifier que la carte GSM pHAT est démarrée, sinon lancer
|
./install.sh noask : Ne pose pas de questions de confirmation pendant l'install, il y va
|
||||||
|
./install.sh all : Install les outils optionnels sans poser de question
|
||||||
|
./install.sh noptions : N'installe pas les outils optionnels
|
||||||
|
|
||||||
sudo ./GSM_powerkey.sh
|
|
||||||
|
|
||||||
Identification de la carte
|
**VOILA! Le système peut maintenant dialoguer par SMS.**
|
||||||
|
|
||||||
sudo gammu --identify
|
## IV. Tests
|
||||||
|
|
||||||
> Device : /dev/ttyS0
|
|
||||||
> Manufacturer : SIMCOM_Ltd
|
|
||||||
> Model : unknown (SIMCOM_SIM868)
|
|
||||||
> Firmware : Revision:1418B03SIM868M32_BT
|
|
||||||
> IMEI : 868183033532677
|
|
||||||
|
|
||||||
Création du fichier de configuration gammurc à partir de ces infos...
|
### Envoyer un SMS
|
||||||
**sudo nano /etc/gammurc**
|
echo "Mon premier SMS envoyé !" | gammu-smsd-inject TEXT 06xxxxxxxx
|
||||||
|
|
||||||
[gammu]
|
**TODO :**
|
||||||
port = /dev/ttyS0
|
- Ajouter un test silkaj
|
||||||
model = SIMCOM_Ltd (SIMCOM_SIM868)
|
- Notif d'une alert admin par G1sms
|
||||||
connection = at19200
|
|
||||||
synchronizetime = yes
|
|
||||||
logfile = /tmp/smsd.log
|
|
||||||
logformat = nothing
|
|
||||||
|
|
||||||
TEST: Envoyer un SMS.
|
|
||||||
|
|
||||||
sudo gammu sendsms TEXT 06nnnnnnnn -text "NOUVEAU G1sms+"
|
---
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
Tout ce passe bien? Alors on installe le daemon gammu smsd
|
**La partie qui suis doit être mise à jours !**
|
||||||
|
|
||||||
sudo apt install gammu-smsd -y
|
|
||||||
|
|
||||||
Préparer le fichier de configuration ([DOC gammu...](https://wammu.eu/docs/manual/smsd/config.html))
|
|
||||||
Adaptez selon le code PIN de votre carte SIM.
|
|
||||||
|
|
||||||
**sudo nano /etc/gammu-smsdrc**
|
|
||||||
|
|
||||||
[gammu]
|
|
||||||
device = /dev/ttyS0
|
|
||||||
name = SIMCOM_Ltd (SIMCOM_SIM868)
|
|
||||||
connection = at19200
|
|
||||||
synchronizetime = yes
|
|
||||||
gammucoding = utf8
|
|
||||||
logformat = textall
|
|
||||||
|
|
||||||
[smsd]
|
|
||||||
service = files
|
|
||||||
Logfile = /tmp/smsd.log
|
|
||||||
DeliveryReport = log
|
|
||||||
debuglevel = 3
|
|
||||||
CommTimeout = 5
|
|
||||||
ReceiveFrequency = 5
|
|
||||||
CheckSecurity = 1
|
|
||||||
PIN = 0000
|
|
||||||
|
|
||||||
# Paths where messages are stored
|
|
||||||
inboxpath = /var/spool/gammu/inbox/
|
|
||||||
outboxpath = /var/spool/gammu/outbox/
|
|
||||||
sentsmspath = /var/spool/gammu/sent/
|
|
||||||
errorsmspath = /var/spool/gammu/error/
|
|
||||||
|
|
||||||
# Run G1SMS Script RunOnReceive
|
|
||||||
RunOnReceive = /home/pi/G1sms+/sms_received.sh
|
|
||||||
|
|
||||||
Le fichier de configuration maintenant prêt, on peut redémarrer le démon smsd
|
|
||||||
|
|
||||||
**sudo service gammu-smsd restart**
|
|
||||||
|
|
||||||
Vous voyez cette ligne dans vos processus? Tudo Bom :smiley: !
|
|
||||||
|
|
||||||
ps auxf
|
|
||||||
usr/bin/gammu-smsd --pid=/var/run/gammu-smsd.pid --daemon
|
|
||||||
|
|
||||||
VOILA! Le système peut maintenant dialoguer par SMS.
|
|
||||||
|
|
||||||
## Installer le coeur de G1sms+
|
|
||||||
:warning: Le code appelé par gammu s'exécute en tant qu'utilisateur root.
|
|
||||||
|
|
||||||
On pourra ajouter **umask 027** à **/root/.bashrc** pour isoler l'appartenance des fichiers de ce compte.
|
|
||||||
|
|
||||||
### 1. Installer Silkaj & Duniterpy
|
|
||||||
|
|
||||||
# Exécuter les commandes suivante en root
|
|
||||||
sudo -s
|
|
||||||
|
|
||||||
# Silkaj + Duniterpy
|
|
||||||
sudo apt install python3-pip
|
|
||||||
sudo apt install libsodium18
|
|
||||||
sudo pip3 install silkaj
|
|
||||||
|
|
||||||
Voila ces 2 super connecteurs python à Duniter installés :cool: Ils seront utilisés par G1sms+ pour gérer les wallets et leurs TX, récupérer le profil des membres dans Cesium+, etc...
|
|
||||||
|
|
||||||
En fait pour l'instant l'API CLI de silkaj n'étant pas encore disponible. C'est la version 0.50 patchée de G1sms qui continue à être utilisée (TODO !!!). Dans ce cas, il faudra peut-être installer les librairies pythons à la main...
|
|
||||||
|
|
||||||
cd ./silkaj
|
|
||||||
pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
Dans cette version. Le dialogue avec les serveurs Duniter a été améliorée par un "load-balacing" régulier sur le groupe de serveurs en plus grand consensus et ayant un timeout correct...
|
|
||||||
|
|
||||||
### 2. Installer IPFS
|
|
||||||
|
|
||||||
Installer ipfs par son programme de mise à niveau permettra de facilement suivre l'évolution de l'Univers Interplanétaire :crystal_ball:
|
|
||||||
|
|
||||||
sudo -s
|
|
||||||
cd /usr/src/
|
|
||||||
wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz
|
|
||||||
tar xvzf ipfs-update_v1.5.2_linux-arm.tar.gz
|
|
||||||
cd ipfs-update
|
|
||||||
./install.sh
|
|
||||||
ipfs-update install latest
|
|
||||||
|
|
||||||
|
|
||||||
Maintenant on peut choisir entre 3 façons de faire:
|
|
||||||
1. Opérer IPFS en Réseau Privé (swarm.key & Environment="LIBP2P_FORCE_PNET=1") et gérer ses serveurs de bootstrap. https://pad.p2p.legal/ipfs-onelove#Rejoindre-l%E2%80%99Essaim
|
|
||||||
2. Opérer sur IPFS Global en prenant soin de crypter les données échangées. https://medium.com/@mycoralhealth/learn-to-securely-share-files-on-the-blockchain-with-ipfs-219ee47df54c
|
|
||||||
~~3. Utiliser l'application ipfs-cluster: https://cluster.ipfs.io/documentation/quickstart/~~
|
|
||||||
|
|
||||||
C'est finalement l'option 2 qui a été choisie, en chiffrant les fichiers mis dans IPFS par la clef GPG du SWARM, du NODE, ou du TAG, la sécurité est assurée (regarder dans ./shell/init_keys.sh, [Generer une clef GPG pour le NODE](https://serverfault.com/a/960673), partager les clefs publiques des Nodes ./wallets/SWARM/IPFSID/gpgpubkey)
|
|
||||||
|
|
||||||
Ici, chaque noeud reste propritéaire des G1sms wallet qu'il a créé est reste le seul à pouvoir interagir avec.
|
|
||||||
|
|
||||||
Configurer le démon **ipfs** pour le user **pi**
|
|
||||||
|
|
||||||
|
|
||||||
Configurer et initialiser le démon avec des options p2p trop pratiques (communication, publication et surveillance de canal, forward de ports, reverse ssh, etc... on accède à tout par son hash, y compris un noeud...)
|
|
||||||
|
|
||||||
su pi
|
|
||||||
ipfs init -p lowpower
|
|
||||||
# Activate pubsub (mode gossip)
|
|
||||||
ipfs config Pubsub.Router gossipsub
|
|
||||||
# Define max storage
|
|
||||||
ipfs config Datastore.StorageMax 6GB
|
|
||||||
## Port Forwarding on P2P (SSH: ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22 )
|
|
||||||
ipfs config --json Experimental.Libp2pStreamMounting true
|
|
||||||
|
|
||||||
On ajoute au BOOTSTRAP le(s) noeud(s) leader (always on) du SWARM
|
|
||||||
|
|
||||||
######### UPDATE BOOTSTRAP LIST ###########
|
|
||||||
ipfs bootstrap rm --all
|
|
||||||
### fred@onelove.madeinzion.org ###
|
|
||||||
# ID: QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
ipfs bootstrap add /ip6/fe80::207:cbff:fe0b:75bb/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
ipfs bootstrap add /ip4/51.15.2.211/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
|
|
||||||
### 3. ACTIVER LE SUPPORT A DISTANCE
|
### 3. ACTIVER LE SUPPORT A DISTANCE
|
||||||
|
|
||||||
|
@ -258,43 +152,6 @@ FAIRE APPEL AU SUPPORT
|
||||||
ssh pi@localhost -p 2222
|
ssh pi@localhost -p 2222
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 4. Lancement de ipfs au démarrage du système
|
|
||||||
|
|
||||||
**sudo nano /etc/systemd/system/ipfs.service**
|
|
||||||
|
|
||||||
[Unit]
|
|
||||||
Description=IPFS daemon
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=pi
|
|
||||||
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient --enable-gc
|
|
||||||
Restart=on-failure
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
||||||
|
|
||||||
Activer et lancer le service ipfs
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable ipfs
|
|
||||||
sudo systemctl start ipfs
|
|
||||||
|
|
||||||
sudo systemctl status ipfs
|
|
||||||
|
|
||||||
|
|
||||||
### 5. Installer la Suite: logiciels et périphériques
|
|
||||||
|
|
||||||
On installe **gnupg** ntpdate pour synchroniser nos horloges plus de quoi manipuler les images, les qrcodes, les chiffres et le json (dialogue avec DUNITER et CESIUM)
|
|
||||||
|
|
||||||
sudo apt install gnupg ntpdate
|
|
||||||
sudo apt install ssmtp mpack
|
|
||||||
|
|
||||||
# Pour manipuler les images, les chiffres et le json
|
|
||||||
sudo apt install imagemagick qrencode bc jq libttspico-utils
|
|
||||||
|
|
||||||
- Configurer un serveur relai email
|
- Configurer un serveur relai email
|
||||||
:a: https://wiki.archlinux.org/index.php/SSMTP
|
:a: https://wiki.archlinux.org/index.php/SSMTP
|
||||||
:b: http://ozzmaker.com/send-email-from-the-raspberry-pi-or-linux-command-line-with-attachments/
|
:b: http://ozzmaker.com/send-email-from-the-raspberry-pi-or-linux-command-line-with-attachments/
|
||||||
|
@ -400,8 +257,3 @@ https://ethereum.stackexchange.com/questions/63109/ipfs-versioning-how-to-get-al
|
||||||
|
|
||||||
* What is InterPlanetary Naming System(IPNS)? https://hackernoon.com/understanding-ipfs-in-depth-3-6-what-is-interplanetary-naming-system-ipns-9aca71e4c13b
|
* What is InterPlanetary Naming System(IPNS)? https://hackernoon.com/understanding-ipfs-in-depth-3-6-what-is-interplanetary-naming-system-ipns-9aca71e4c13b
|
||||||
|
|
||||||
# INSTALL
|
|
||||||
|
|
||||||
A venir... préparer un script qui effectue ce qui est décrit dans ce document pour lancer des installations plus automatiques de NODE G1sms+
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
source $MY_PATH/../.install/.GPATH
|
||||||
|
|
||||||
# Clean /tmp/ytdl.list
|
# Clean /tmp/ytdl.list
|
||||||
#echo > /tmp/ytdl.list
|
#echo > /tmp/ytdl.list
|
||||||
|
|
||||||
|
@ -74,9 +78,9 @@ elif [[ "$radio" != "" && "$artist" == "" && "$song" == "" ]]; then
|
||||||
# EXTERNAL PARSER: ADD SCRAPERS IN ./libradio
|
# EXTERNAL PARSER: ADD SCRAPERS IN ./libradio
|
||||||
~/parle.sh "Recherche RADIO ${radio}"
|
~/parle.sh "Recherche RADIO ${radio}"
|
||||||
echo "External search: ${radio}" >> /tmp/youtube-dl.log 2>&1
|
echo "External search: ${radio}" >> /tmp/youtube-dl.log 2>&1
|
||||||
if [[ -f /home/pi/G1sms+/_CopyLaRadio/libradio/${radio}.php ]]; then
|
if [[ -f $GPATH/_CopyLaRadio/libradio/${radio}.php ]]; then
|
||||||
~/parle.sh "Module existant"
|
~/parle.sh "Module existant"
|
||||||
php "/home/pi/G1sms+/_CopyLaRadio/libradio/${radio}.php"
|
php "$GPATH/_CopyLaRadio/libradio/${radio}.php"
|
||||||
else
|
else
|
||||||
~/parle.sh "Aucun module de décodage pour cette radio."
|
~/parle.sh "Aucun module de décodage pour cette radio."
|
||||||
fi
|
fi
|
||||||
|
|
23
_comments
|
@ -162,3 +162,26 @@ OK
|
||||||
2019-11-25:
|
2019-11-25:
|
||||||
2019-11-26: clean
|
2019-11-26: clean
|
||||||
2019-11-27: sms
|
2019-11-27: sms
|
||||||
|
2019-12-10:
|
||||||
|
2019-12-10:
|
||||||
|
2019-12-10: fourletterphat
|
||||||
|
2019-12-11:
|
||||||
|
2019-12-14: G1 Tag READ WRITE
|
||||||
|
2019-12-14: Install backup change
|
||||||
|
2019-12-14: backup
|
||||||
|
2019-12-14: COMMENT
|
||||||
|
2019-12-14:
|
||||||
|
2019-12-14:
|
||||||
|
2019-12-17: Better G1Tx
|
||||||
|
2019-12-17: G1TAG REFRESH & more
|
||||||
|
2019-12-18: RAZ
|
||||||
|
2019-12-20: NOW
|
||||||
|
2019-12-21: Various
|
||||||
|
2019-12-24:
|
||||||
|
2020-01-02: Noel merge code
|
||||||
|
2020-01-02: g1sms.preoni
|
||||||
|
2020-01-04: BACKUP
|
||||||
|
2020-01-06: bugs
|
||||||
|
2020-01-06: silkaj TX init bad keys
|
||||||
|
2020-01-07:
|
||||||
|
2020-01-07: g1.presles.fr
|
||||||
|
|
BIN
_publishkey.gpg
43
config.sh
|
@ -1,43 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
################################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 0.1
|
|
||||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
||||||
################################################################################
|
|
||||||
now=$(date +%Y-%m-%d)
|
|
||||||
|
|
||||||
echo "Ce script configure votre noeud G1sms+ (effacez ./shell/init.sh avant de le lancer)"
|
|
||||||
IPFS=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1);
|
|
||||||
|
|
||||||
if [[ -f ./shell/init.sh.template && ! -f ./shell/init.sh ]]; then
|
|
||||||
echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?"
|
|
||||||
read YOU
|
|
||||||
if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi
|
|
||||||
|
|
||||||
echo "Votre PSEUDO? (celui de votre Compte membre Duniter)"
|
|
||||||
read ADMINPSEUDO
|
|
||||||
if [[ "$ADMINPSEUDO" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi
|
|
||||||
|
|
||||||
echo "Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)"
|
|
||||||
read ADMINPHONE
|
|
||||||
if [[ "$ADMINPHONE" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi
|
|
||||||
|
|
||||||
echo "Le numéro de la carte SIM, du module SMS? (ex +33611223344)"
|
|
||||||
read MASTERPHONE
|
|
||||||
|
|
||||||
echo "L'adresse où se trouve votre G1Node pour indiquer où venir chercher ses G1Tag (ex: au G1FabLab de Toulouse)"
|
|
||||||
read ADRESSE
|
|
||||||
|
|
||||||
sed -i s/pi/$YOU/g ./shell/init.sh.template
|
|
||||||
sed -i s/+33660780131/$MASTERPHONE/g ./shell/init.sh.template
|
|
||||||
sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g ./shell/init.sh.template
|
|
||||||
sed -i s/+33647683646/$ADMINPHONE/g ./shell/init.sh.template
|
|
||||||
sed -i s/Fred/$ADMINPSEUDO/g ./shell/init.sh.template
|
|
||||||
|
|
||||||
cat ./shell/init.sh.template
|
|
||||||
|
|
||||||
echo "LES PARAMETRES SONT BONS? Appliquer? ENTER ou CTRL-C ?"
|
|
||||||
read
|
|
||||||
cp ./shell/init.sh.template ./shell/init.sh
|
|
||||||
fi
|
|
||||||
|
|
|
@ -8,3 +8,4 @@ while True:
|
||||||
GPIO.output(7, GPIO.HIGH)
|
GPIO.output(7, GPIO.HIGH)
|
||||||
break
|
break
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`"
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`"
|
||||||
|
|
||||||
if [ ! -e /sys/class/gpio/gpio4 ]; then
|
if [ ! -e /sys/class/gpio/gpio4 ]; then
|
||||||
echo "File exists."
|
echo "File doesn't exists."
|
||||||
echo "4" > /sys/class/gpio/export
|
echo "4" > /sys/class/gpio/export
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "out" > /sys/class/gpio/gpio4/direction
|
echo "out" > /sys/class/gpio/gpio4/direction
|
||||||
echo "0" > /sys/class/gpio/gpio4/value
|
|
||||||
sleep 2
|
|
||||||
echo "1" > /sys/class/gpio/gpio4/value
|
echo "1" > /sys/class/gpio/gpio4/value
|
||||||
|
|
||||||
|
sleep 3 && $MY_PATH/gammu-restart.sh
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
usbserial=($(lsmod | grep -w usbserial | awk '{ print $4 }' | awk -F, '{ print $1 " " $2 }'))
|
||||||
|
|
||||||
|
|
||||||
|
sudo modprobe -r option
|
||||||
|
sudo modprobe -r usbserial
|
||||||
|
|
||||||
|
sudo modprobe option
|
||||||
|
sudo modprobe usbserial
|
||||||
|
|
||||||
|
#for i in "${usbserial[@]}"; do
|
||||||
|
#echo "tata: $i"
|
||||||
|
# sudo modprobe -r $i
|
||||||
|
# sudo modprobe $i
|
||||||
|
#done
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
[[ ! $1 ]] && echo "Veuillez choisir un niveau de log" && exit 1
|
||||||
|
|
||||||
|
sudo sed -i "/debuglevel/d" /etc/gammu-smsdrc
|
||||||
|
echo "debuglevel = $1" | sudo tee -a /etc/gammu-smsdrc
|
||||||
|
|
||||||
|
$MY_PATH/gammu-restart.sh
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PID=$(sudo ps auxf | grep "/usr/bin/gammu-smsd" | grep -v -E "color=auto|grep" | awk '{ print $2 }')
|
||||||
|
|
||||||
|
[[ $PID ]] && sudo kill -9 "$PID"
|
||||||
|
|
||||||
|
sudo service gammu-smsd restart
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,5 @@
|
||||||
|
+33695000695
|
||||||
|
+33695000647
|
||||||
|
+33695000646
|
||||||
|
+33695000643
|
||||||
|
+33695000636
|
163
install.sh
|
@ -4,80 +4,117 @@
|
||||||
# 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/)
|
||||||
################################################################################
|
################################################################################
|
||||||
# LE Freaking LOL Hackathon de Noël https://framadate.org/sviOUlP6JLyWq5D2XLEdcKY9/admin
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
#
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
now=$(date -u +%Y-%m-%d)
|
|
||||||
|
|
||||||
echo "Bonjour $USER, je vous souhaite bon jour ($now)"
|
echo "GPATH=$MY_PATH" > $MY_PATH/.install/.GPATH
|
||||||
echo "Ce script va installer / mettre à jour votre noeud G1sms dans /home/$USER/G1sms+"
|
source $MY_PATH/.install/.GPATH
|
||||||
echo "ATTENTION! Vous devez avoir installé la couche ipfs & mpd au préalable!!! ./install_ipfs_layer.sh"
|
|
||||||
IPFS=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1);
|
|
||||||
echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?"
|
|
||||||
read YOU
|
|
||||||
if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi
|
|
||||||
|
|
||||||
cd /home/$USER
|
init_loc="$MY_PATH/shell/init.sh"
|
||||||
echo "Déplacement dans /home/$USER/"
|
now=$(date +%Y-%m-%d)
|
||||||
echo "... Téléchargement de la dernière version du CODE G1sms+ (ipfs = $YOU)"
|
unset err
|
||||||
|
|
||||||
# CODE is there?? Get it from ipns
|
## Récupère les données du profile
|
||||||
ipfs get --output=./ /ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif
|
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
|
||||||
|
|
||||||
if [ ! -d ./G1sms+ ]; then
|
## Récupère les arguments
|
||||||
|
args="$@"
|
||||||
|
[[ $args =~ all ]] && repOption=o
|
||||||
|
[[ $args =~ noptions ]] && repOption=n
|
||||||
|
[[ $args =~ force ]] && force_req=o
|
||||||
|
[[ $args =~ noask ]] && noask=o
|
||||||
|
|
||||||
echo "RECHERCHE ET INSTALLATION DU CODE : G1sms+.latest.tgz "
|
## Vérifie le type de système
|
||||||
if [[ -f "./CODE/G1sms+.latest.tgz" ]]; then
|
[[ $(uname -a | grep arm) ]] && isARM=YES || unset isARM
|
||||||
tar xzf ./CODE/G1sms+.latest.tgz
|
if [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then OS=stretch;
|
||||||
fi
|
elif [[ $(grep buster /etc/os-release) ]]; then OS=buster;
|
||||||
|
else echo "${c_red}Votre OS n'est pas supporté$c_"; exit 1; fi
|
||||||
|
echo -e "$OS\n$isARM" > .install/.OS
|
||||||
|
|
||||||
echo "VOULEZ VOUS CONFIGURER VOTRE NODE G1sms+ ? ^C"
|
unset err
|
||||||
echo "Les paramètres se trouvent dans /home/$YOU/G1sms+/shell/init.sh"
|
|
||||||
read
|
|
||||||
|
|
||||||
echo "Votre PSEUDO? Celui de votre compte membre Duniter. (defaut: Fred)"
|
## Vérifie si le script est en lancé par root
|
||||||
read ADMINPSEUDO
|
if [ "$EUID" -eq 0 ]
|
||||||
if [[ "$ADMINPSEUDO" == "" ]]; then ADMINPSEUDO="Fred"; fi
|
then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Le Numéro de téléphone SMS Admin? Votre numéro de portable (defaut: +33647683646)"
|
## Update G1sms+ code
|
||||||
read ADMINPHONE
|
git pull || err+=1
|
||||||
if [[ "$ADMINPHONE" == "" ]]; then ADMINPHONE="+33647683646"; fi
|
|
||||||
|
|
||||||
echo "Le numéro de la carte SIM, du module SMS. AUCUNE liaison SMS? Laissez vide (défaut: +33611223344)"
|
chmod u+x $MY_PATH/.install/*.sh
|
||||||
read MASTERPHONE
|
|
||||||
if [[ "$MASTERPHONE" == "" ]]; then MASTERPHONE="+33611223344"; fi
|
|
||||||
|
|
||||||
# TODO ASK for GeoPoint
|
$MY_PATH/.install/export_colors.sh
|
||||||
echo "L'adresse où se trouve votre G1Node pour indiquer où venir chercher les G1Tag imprimés (ex: au G1FabLab de Toulouse)"
|
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
|
||||||
read ADRESSE
|
|
||||||
z
|
|
||||||
cp /home/$YOU/G1sms+/shell/init.sh.template /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
sed -i s/pi/$YOU/g /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
sed -i s/+33660780131/$MASTERPHONE/g /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
sed -i s/+33647683646/$ADMINPHONE/g /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
sed -i s/Fred/$ADMINPSEUDO/g /home/$YOU/G1sms+/shell/init.sh
|
|
||||||
|
|
||||||
echo "========================================="
|
## Vérifie si IPFS est installé
|
||||||
echo "VERIFIEZ QUE LES PARAMETRES SONT BONS... "
|
if [[ $force_req == "o" || -z $(which ipfs) || -z $(which gammu) ]];then
|
||||||
echo "========================================="
|
echo -e "${c_yellow}IPFS ou gammu n'ont pas été détectés sur votre machine, nous allons installer tous les prérequis...$c_"
|
||||||
cat /home/$YOU/G1sms+/shell/init.sh
|
$MY_PATH/.install/1-install_requirements.sh silkaj ipfs gammu || err+=1
|
||||||
echo "========================================="
|
$MY_PATH/.install/2a-configure_ipfs_layer.sh || err+=1
|
||||||
echo "CONFIG: vi /home/$YOU/G1sms+/shell/init.sh "
|
else
|
||||||
echo "========================================="
|
echo -e "${c_green}IPFS et gammu sont déjà installé !$c_"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${c_yellow}Ce script va désormais configurer votre noeud G1sms+$c_"
|
||||||
|
|
||||||
|
if [[ -f $MY_PATH/.install/templates/init.sh ]]; then
|
||||||
|
[[ ! $ADMINPSEUDO ]] && echo -e "${c_light}Votre PSEUDO? (celui de votre Compte membre Duniter)$c_" && read ADMINPSEUDO
|
||||||
|
[[ "$ADMINPSEUDO" == "" ]] && echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_" && exit 1
|
||||||
|
|
||||||
|
[[ ! $ADMINPHONE ]] && echo -e "${c_light}Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)$c_" && read ADMINPHONE
|
||||||
|
[[ "$ADMINPHONE" == "" ]] && echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_" && exit 1
|
||||||
|
|
||||||
|
[[ ! $MASTERPHONE ]] && echo -e "${c_light}Le numéro de la carte SIM, du module SMS. AUCUNE liaison SMS? Laissez vide (défaut: +33600000000)$c_" && read MASTERPHONE
|
||||||
|
[[ "$MASTERPHONE" == "" ]] && MASTERPHONE="+33600000000"
|
||||||
|
|
||||||
|
[[ ! $ADRESSE ]] && echo -e "${c_light}L'adresse où se trouve votre G1Node pour indiquer où venir chercher ses G1Tag (ex: au G1FabLab de Toulouse)$c_" && read ADRESSE
|
||||||
|
|
||||||
|
[[ ! $PIN ]] && echo -e "${c_light}Le code PIN de votre carte SIM ? (ex: 1234)$c_" && read PIN
|
||||||
|
[[ "$PIN" == "" ]] && PIN="1234"
|
||||||
|
|
||||||
|
echo -e "ADMINPSEUDO: $ADMINPSEUDO\nADMINPHONE: $ADMINPHONE\nMASTERPHONE: $MASTERPHONE\nADRESSE: $ADRESSE\nPIN: $PIN"
|
||||||
|
[[ $noask != "o" ]] && echo -e "${c_light}${c_blue}LES PARAMETRES SONT BONS? Appliquer? ENTER ou CTRL-C ? (Editez le fichier .profile si incorrect)$c_" && read
|
||||||
|
|
||||||
|
[[ -f shell/init.sh ]] && mv shell/init.sh shell/init.sh.old
|
||||||
|
cp $MY_PATH/.install/templates/init.sh shell/init.sh || err+=1
|
||||||
|
|
||||||
|
sed -i s/_MASTERPHONE/$MASTERPHONE/g $init_loc
|
||||||
|
sed -i s/_ADRESSE/$ADRESSE/g $init_loc
|
||||||
|
sed -i s/_ADMINPHONE/$ADMINPHONE/g $init_loc
|
||||||
|
sed -i s/_ADMINPSEUDO/$ADMINPSEUDO/g $init_loc
|
||||||
|
|
||||||
|
if [[ ! -f $MY_PATH/.profile ]]; then
|
||||||
|
cp $MY_PATH/.install/templates/.profile $MY_PATH/
|
||||||
|
sed -i s/_MASTERPHONE/$MASTERPHONE/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/_ADMINPSEUDO/$ADMINPSEUDO/g $MY_PATH/.profile
|
||||||
|
sed -i s/_PIN/$PIN/g $MY_PATH/.profile
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "VOUS AVEZ UNE VERSION de G1sms+ DEJA INSTALLEE. MISE A JOUR..."
|
echo -e "${c_red}init.sh introuvable...$c_"
|
||||||
tar xzf CODE/G1sms+.latest.tgz
|
err+=1
|
||||||
|
exit 1
|
||||||
cd G1sms+
|
|
||||||
# TODO
|
|
||||||
# sudo chown -R $YOU ./TAG
|
|
||||||
# sudo chown -R $YOU ./wallets
|
|
||||||
echo "PREPARE rompr access from nginx"
|
|
||||||
mkdir -p ./www/rompr/prefs
|
|
||||||
mkdir -p ./www/rompr/albumarts
|
|
||||||
chmod 777 ./www/rompr/prefs
|
|
||||||
chmod 777 ./www/rompr/albumarts
|
|
||||||
|
|
||||||
echo "Version installée ($now):: IPFS chain :: $(cat ./_chain)"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Configuration de gammu
|
||||||
|
$MY_PATH/.install/2b-configure_gammu.sh || err=1
|
||||||
|
|
||||||
|
## Installations optionnels
|
||||||
|
|
||||||
|
repOld=$repOption
|
||||||
|
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer les modules complémentaires de copylaradio ? (o/n)$c_" && read repOption
|
||||||
|
if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/3-install_copylaradio.sh || err+=1; fi; repOption=$repOld
|
||||||
|
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer l'interface web Kalkun ? (o/n)$c_" && read repOption
|
||||||
|
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
|
||||||
|
if [[ $repOption =~ ^(o|1|yes|options|a|all)$ ]]; then $MY_PATH/.install/4b-install_playsms.sh || err+=1; fi; repOption=$repOld
|
||||||
|
|
||||||
|
if [[ $err ]]; then
|
||||||
|
echo -e "---\n${c_red}L'installation générale n'est mal déroulé =($c_"
|
||||||
|
else
|
||||||
|
echo -e "---\n${c_green}Félécitation ! L'installation de votre noeud G1SMS s'est terminé avec succès !\nBienvenue à bord =)$c_"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,179 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
################################################################################
|
|
||||||
# Author: Fred (support@qo-op.com)
|
|
||||||
# Version: 0.1
|
|
||||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
||||||
###########################################################################################
|
|
||||||
#######################################
|
|
||||||
# INSTALL IPFS on G1sms+ Pi NODES
|
|
||||||
#######################################
|
|
||||||
echo "DEFAULT INSTALL SCRIPT. VALIDATED ON RASPBERRYPI, SHOULD BE ADAPTED IF NOT ARM ARCH SYSTEM.
|
|
||||||
You are going to download and install ipfs daemon environement for running G1sms+ NODE.
|
|
||||||
TODO: TEST TEST TEST TEST + MANAGE DIFFERENT ARCH
|
|
||||||
Ready?"
|
|
||||||
read
|
|
||||||
|
|
||||||
if [[ "$USER" == "root" ]]; then echo "Better run by 'pi', please create non-root user and become that user before launching ipfs install..."; exit;
|
|
||||||
else echo "$USER, let's go!";
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "GET ipfs-update"
|
|
||||||
cd /usr/src/
|
|
||||||
sudo wget https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz
|
|
||||||
|
|
||||||
echo "INSTALL ipfs-update"
|
|
||||||
sudo tar xvzf ipfs-update_v1.5.2_linux-arm.tar.gz
|
|
||||||
cd ipfs-update
|
|
||||||
sudo ./install.sh
|
|
||||||
|
|
||||||
echo "INSTALL latest ipfs"
|
|
||||||
sudo ipfs-update install latest
|
|
||||||
|
|
||||||
echo "CREATE SYSTEMD ipfs SERVICE"
|
|
||||||
sudo cat > /etc/systemd/system/ipfs.service << EOF
|
|
||||||
[Unit]
|
|
||||||
Description=IPFS daemon
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=$USER
|
|
||||||
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
|
|
||||||
Restart=on-failure
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable ipfs
|
|
||||||
|
|
||||||
################
|
|
||||||
# BECOME $USER
|
|
||||||
# INIT ipfs
|
|
||||||
ipfs init -p lowpower
|
|
||||||
|
|
||||||
# ACTIVATE CONFIG OPTIONS
|
|
||||||
# PUBSUB
|
|
||||||
ipfs config Pubsub.Router gossipsub
|
|
||||||
# MAXSTORAGE
|
|
||||||
ipfs config Datastore.StorageMax 12GB
|
|
||||||
## PORT FORWARD (SSH)
|
|
||||||
ipfs config --json Experimental.Libp2pStreamMounting true
|
|
||||||
|
|
||||||
######### UPDATE BOOTSTRAP LIST ###########
|
|
||||||
ipfs bootstrap rm --all
|
|
||||||
### fred@onelove.madeinzion.org ###
|
|
||||||
# ID: QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
ipfs bootstrap add /ip6/fe80::207:cbff:fe0b:75bb/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
ipfs bootstrap add /ip4/51.15.2.211/tcp/4001/ipfs/QmSX7gFRPHui5A2DWFk2VmBvq6hynj2hubhJLQAwPWe4Lh
|
|
||||||
### ADD NEW SWARM LEADERS SERVER HERE ###
|
|
||||||
|
|
||||||
# ALLOW REMOTE SSH CONNECTION FROM rec OR onelove (For swarm.key & keystore exchange )
|
|
||||||
# ADD SSH ADMIN/SUPPORT USERS $(cat .ssh/id_rsa.pub)
|
|
||||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs6oXRmPukaX7u2tDcFF1cecsDSEA30YyUqDaXSrw+yWQ8G79ktZ7BN0bPYBgfxO59FU8l5Jg1SPPG9kj81jfoCwGJpYdbczmMuP/iqw3aNoGv66swxwxzrqzbHrFFCXgn+6B2spDjn87tFB8JvQQTb2Kc4/sAZ9E6eY61pFiNpqbQehXdqSV5UemV9dkSQrnmJTl1PjUQ474AKQwFPzpdKHD/3VvqQS4i7ZLVeXS65euOP/YY8Bx9HvhsmhJ3h78OOK+D6GFfyv010xXBoG6kCSYR8LYMCEexpPGYV+Mduf/tUHjHP4GuWZAhd+wLRl0uPy6Tv7wHFfLyN01m/9vl fred@rec" >> ~/.ssh/authorized_keys
|
|
||||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFthQ3FggJlz/+ZglZJjVJzYs6ehx/iB7f89KY396K+7ai4ETqFhq6ANVp9xeQ4dLU26w0bFBELcnh9rn5QDSrXjsIptoWXErkSdZOeXqofnLtJEOhZO/I328y0C1vQRwtMMXKLLnqPe14h+zJenc7KJbL5cvB3Hd7nfQ+Q0uEnIsKb0f5wcKagySHIFdmY/FqaGz5g4MXGq7nlX/31hvfTFhF0g+k3mhvTTVQ368Op9qZZIozYhBoojWWvK5mwAovxdS9QT1hKrFXHfjov/aKQxLAy0a0oxFvHKoYN/l4ffGibFMAmedljTxf1VSDBv/k/RN53UU6RufW3qqBjY0b fred@onelove" >> ~/.ssh/authorized_keys
|
|
||||||
|
|
||||||
# START ipfs
|
|
||||||
sudo systemctl start ipfs
|
|
||||||
|
|
||||||
##################################
|
|
||||||
## INSTALL TOOLS
|
|
||||||
######## YOUTUBE-DL ##########
|
|
||||||
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
|
|
||||||
sudo chmod a+rx /usr/local/bin/youtube-dl
|
|
||||||
sudo apt install libid3-tools mpd mpc lame -y
|
|
||||||
|
|
||||||
## CONFIG MPD
|
|
||||||
sudo cat > /etc/mpd.conf << EOF
|
|
||||||
music_directory "/home/$USER/music"
|
|
||||||
playlist_directory "/home/$USER/playlists"
|
|
||||||
user "$USER"
|
|
||||||
bind_to_address "any"
|
|
||||||
auto_update "yes"
|
|
||||||
zeroconf_enabled "yes"
|
|
||||||
zeroconf_name "CopyLaRadio Music Recorder"
|
|
||||||
|
|
||||||
filesystem_charset "UTF-8"
|
|
||||||
id3v1_encoding "UTF-8"
|
|
||||||
###############################
|
|
||||||
|
|
||||||
audio_output {
|
|
||||||
type "pulse"
|
|
||||||
name "My Pulse Output"
|
|
||||||
server "127.0.0.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
audio_output {
|
|
||||||
type "httpd"
|
|
||||||
name "CopyLaRadio HTTP Stream"
|
|
||||||
encoder "lame"
|
|
||||||
port "8000"
|
|
||||||
quality "5.0"
|
|
||||||
# bitrate "128"
|
|
||||||
format "44100:16:1"
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
|
||||||
sudo service mpd restart
|
|
||||||
|
|
||||||
sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y
|
|
||||||
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet libav-tools imagemagick curl -y
|
|
||||||
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse libttspico-utils atomicparsley -y
|
|
||||||
|
|
||||||
# CONFIG NGINX
|
|
||||||
sudo cat > /etc/nginx/sites-available/default << EOF
|
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
listen [::]:80 default_server;
|
|
||||||
|
|
||||||
root /home/$USER/G1sms+/www/rompr;
|
|
||||||
index index.html index.htm index.nginx-debian.html;
|
|
||||||
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
location /g1tag {
|
|
||||||
proxy_pass http://127.0.0.1:81;
|
|
||||||
proxy_set_header Host \$host;
|
|
||||||
proxy_set_header X-Forwarded-For \$remote_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /code/ {
|
|
||||||
proxy_pass http://127.0.0.1:8080/ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif/;
|
|
||||||
proxy_set_header Host \$host;
|
|
||||||
proxy_set_header X-Real-IP \$remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /ipfs {
|
|
||||||
proxy_pass http://127.0.0.1:8080;
|
|
||||||
proxy_set_header Host \$host;
|
|
||||||
proxy_set_header X-Forwarded-For \$remote_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /ipns {
|
|
||||||
proxy_pass http://127.0.0.1:8080;
|
|
||||||
proxy_set_header Host \$host;
|
|
||||||
proxy_set_header X-Forwarded-For \$remote_addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
sudo systemctl restart nginx
|
|
||||||
|
|
||||||
#################################
|
|
||||||
## Get _CopyLaRadio distrib
|
|
||||||
# ipfs get Qm.... > /tmp/copylaradio.zip
|
|
||||||
|
|
||||||
# Add CopyLaRadio to system PATH
|
|
||||||
#export PATH=$PATH:/home/$USER/_CopyLaRadio
|
|
||||||
# etc....
|
|
||||||
|
|
||||||
# INSTALL ROMPR WebSite LINKs
|
|
||||||
#sudo ln -s /home/$USER/_CopyLaRadio/www/rompr /var/www/rompr
|
|
||||||
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/albumart
|
|
||||||
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/prefs
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
45
rc.local.sh
|
@ -1,17 +1,28 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
######################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
# This script modify rc.local to start G1sms+ G1Tag, G1Tx and _CopyLaRadio scripts
|
# This script modify rc.local to start G1sms+ G1Tag, G1Tx and _CopyLaRadio scripts
|
||||||
######################################################################
|
######################################################################
|
||||||
# INJECT it self
|
# INJECT it self into /etc/rc.local
|
||||||
|
######################################################################
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#################### INCEPTION / INSERTION ###########################
|
||||||
######################################################################
|
######################################################################
|
||||||
inserted=$(grep -Rw "rc.local.sh" /etc/rc.local)
|
inserted=$(grep -Rw "rc.local.sh" /etc/rc.local)
|
||||||
if [[ ! $inserted ]]; then
|
if [[ ! $inserted ]]; then
|
||||||
sed -i s/exit\ 0//g /etc/rc.local
|
sudo sed -i s/exit\ 0//g /etc/rc.local
|
||||||
echo "include /home/pi/G1sms+/rc.local.sh" >> /etc/rc.local
|
sudo echo "include $MY_PATH/rc.local.sh" >> /etc/rc.local
|
||||||
echo "exit 0" >> /etc/rc.local
|
sudo echo "exit 0" >> /etc/rc.local
|
||||||
fi
|
fi
|
||||||
######################################################################
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
#### WRITE SYSTEM STARTUP COMMANDS HERE........
|
||||||
|
######################################################################
|
||||||
# mpd Runs like pi and some rights are bad!!
|
# mpd Runs like pi and some rights are bad!!
|
||||||
chown -R pi /var/run/mpd
|
chown -R pi /var/run/mpd
|
||||||
chown -R pi /run/mpd
|
chown -R pi /run/mpd
|
||||||
|
@ -28,33 +39,33 @@ chmod 664 /tmp/youtube-dl.log
|
||||||
chown pi:www-data /tmp/youtube-dl.log
|
chown pi:www-data /tmp/youtube-dl.log
|
||||||
|
|
||||||
# LAUNCH BUTTONS WATCH
|
# LAUNCH BUTTONS WATCH
|
||||||
su pi -c "/home/pi/G1sms+/_CopyLaRadio/watch.sh &"
|
su pi -c "$MY_PATH/_CopyLaRadio/watch.sh &"
|
||||||
# LAUNCH COPY SCRIPT
|
# LAUNCH COPY SCRIPT
|
||||||
su pi -c "/home/pi/G1sms+/_CopyLaRadio/copy.sh &"
|
su pi -c "$MY_PATH/_CopyLaRadio/copy.sh &"
|
||||||
|
|
||||||
# Print the IP address
|
# Print the IP address
|
||||||
_IP=$(hostname -I | cut -d " " -f 1) || true
|
_IP=$(hostname -I | cut -d " " -f 1) || true
|
||||||
if [ "$_IP" ]; then
|
if [ "$_IP" ]; then
|
||||||
printf "IP address is %s\n" "$_IP"
|
printf "IP address is %s\n" "$_IP"
|
||||||
/home/pi/G1sms+/shell/parle.sh "Adresse IP: $_IP"
|
$MY_PATH/shell/parle.sh "Adresse IP: $_IP"
|
||||||
youtube-dl -U
|
youtube-dl -U
|
||||||
/home/pi/G1sms+/shell/parle.sh "Mise à jour de Youtube DL. Terminé!"
|
$MY_PATH/shell/parle.sh "Mise à jour de Youtube DL. Terminé!"
|
||||||
#IPFS
|
#IPFS
|
||||||
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 [[ "$YOU" != "" && "$YOU" != "root" ]]; then
|
if [[ "$YOU" != "" && "$YOU" != "root" ]]; then
|
||||||
/home/pi/G1sms+/shell/parle.sh "IPFS OK. Système de fichier interplanétaire activé."
|
$MY_PATH/shell/parle.sh "IPFS OK. Système de fichier interplanétaire activé."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
/home/pi/G1sms+/shell/parle.sh "Connexion Internet Impossible!"
|
$MY_PATH/shell/parle.sh "Connexion Internet Impossible!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# LANCEMENT G1Tag READ
|
# LANCEMENT G1Tag READ
|
||||||
if [[ -e "/dev/ttyACM0" ]]; then
|
if [[ -e "/dev/ttyACM0" ]]; then
|
||||||
cd /home/pi/G1sms+ && ./shell/tag_READ.sh &
|
cd $MY_PATH && ./shell/tag_READ.sh &
|
||||||
/home/pi/G1sms+/shell/parle.sh "Lecteur G1 tag"
|
$MY_PATH/shell/parle.sh "Lecteur G1 tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "/home/pi/G1sms+/www/rompr" ]]; then
|
if [[ -d "$MY_PATH/www/rompr" ]]; then
|
||||||
/home/pi/G1sms+/shell/parle.sh "Jukebox interplanétaire accessible"
|
$MY_PATH/shell/parle.sh "Jukebox interplanétaire accessible"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
4
search
|
@ -2,7 +2,7 @@
|
||||||
clear
|
clear
|
||||||
echo "------------------------------------------------------------------------------"
|
echo "------------------------------------------------------------------------------"
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo " Nothing to search for!"
|
echo " Nothing to search for!"
|
||||||
else
|
else
|
||||||
echo " Searching for "$1" recursively. Please Wait..."
|
echo " Searching for "$1" recursively. Please Wait..."
|
||||||
echo "------------------------------------------------------------------------------"
|
echo "------------------------------------------------------------------------------"
|
||||||
|
@ -10,7 +10,7 @@ else
|
||||||
fi
|
fi
|
||||||
echo "------------------------------------------------------------------------------"
|
echo "------------------------------------------------------------------------------"
|
||||||
if [ "$2" != "" ]; then
|
if [ "$2" != "" ]; then
|
||||||
echo " To replace \"$1\" whith \"$2\", please run"
|
echo " To replace \"$1\" whith \"$2\", please run"
|
||||||
echo " grep -rl '$1' ./ | xargs sed -i 's/$1/$2/g'"
|
echo " grep -rl '$1' ./ | xargs sed -i 's/$1/$2/g'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 77 KiB |
BIN
shell/G1sms.png
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 253 KiB |
|
@ -1 +0,0 @@
|
||||||
duniter.moul.re:443
|
|
|
@ -5,7 +5,7 @@
|
||||||
# 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/)
|
||||||
################################################################################
|
################################################################################
|
||||||
# Checks the current block number of nodes.txt (is run in parallel) and output random (from last synchronized) node
|
# Checks the current block number of nodes.txt (is run in parallel) and output random (from last synchronized) node
|
||||||
# pip3 install duniterpy
|
# pip3 install duniterpy
|
||||||
# pip3 install silkaj --user
|
# pip3 install silkaj --user
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ BAN=$1
|
||||||
if [[ "$BAN" == "BAN" ]]; then
|
if [[ "$BAN" == "BAN" ]]; then
|
||||||
# Get actual Duniter node used by silkaj
|
# Get actual Duniter node used by silkaj
|
||||||
SERVER=$(cat ./silkaj/src/constants.py | grep G1_DEFAULT_ENDPOINT | awk '{print $3}' | sed s/\"\,//g | sed s/\"//g)
|
SERVER=$(cat ./silkaj/src/constants.py | grep G1_DEFAULT_ENDPOINT | awk '{print $3}' | sed s/\"\,//g | sed s/\"//g)
|
||||||
echo $SERVER:443 >> ./shell/bad.nodes.txt
|
[[ ! $(grep $SERVER:443 shell/bad.nodes.txt) ]] && echo $SERVER:443 >> shell/bad.nodes.txt
|
||||||
|
sed -i "/$SERVER:443/d" ./shell/good.nodes.txt
|
||||||
echo "$SERVER:443 IS NOW in ./shell/bad.nodes.txt"
|
echo "$SERVER:443 IS NOW in ./shell/bad.nodes.txt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ done
|
||||||
silkaj=$(echo $DUNITER | cut -d ":" -f 1)
|
silkaj=$(echo $DUNITER | cut -d ":" -f 1)
|
||||||
if [[ "$silkaj" != "" && "$silkaj" != "https" ]]; then
|
if [[ "$silkaj" != "" && "$silkaj" != "https" ]]; then
|
||||||
#echo "PUT $silkaj SILKAJ PARAM"
|
#echo "PUT $silkaj SILKAJ PARAM"
|
||||||
cat ./silkaj/src/constants.default.py | sed s/duniter.moul.re/$silkaj/g > ./silkaj/src/constants.py
|
cat ./silkaj/src/constants.default.py | sed s/duniter-g1.p2p.legal/$silkaj/g > ./silkaj/src/constants.py
|
||||||
else
|
else
|
||||||
echo "RESTORE DEFAULT SILKAJ PARAM"
|
echo "RESTORE DEFAULT SILKAJ PARAM"
|
||||||
cp -f ./silkaj/src/constants.default.py ./silkaj/src/constants.py
|
cp -f ./silkaj/src/constants.default.py ./silkaj/src/constants.py
|
||||||
|
|
|
@ -3,12 +3,15 @@
|
||||||
# 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 MASTERKEYFILE encryption to IPFS
|
# BACKUP G1sms+ current Devlt code and push it with SWARM_CODE_MASTER to IPFS
|
||||||
################################################################################
|
################################################################################
|
||||||
source ./shell/init.sh
|
source ./init.sh
|
||||||
source ./shell/functions.sh
|
source ./functions.sh
|
||||||
now=$(date +%Y-%m-%d)
|
now=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
echo "COMMENTAIRES?"
|
echo "COMMENTAIRES?"
|
||||||
read COMMENT
|
read COMMENT
|
||||||
|
|
||||||
|
@ -34,10 +37,11 @@ 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.... INITIALIZING G1 Object ipfs chain files:"
|
echo "PLEASE WAIT...."
|
||||||
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); curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq '.dividend' > "./$dir/_DU";
|
LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1);
|
||||||
|
[[ $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
|
||||||
|
|
||||||
|
@ -49,12 +53,10 @@ echo $(date +%s%N) > "./$dir/_nanodate"
|
||||||
|
|
||||||
echo "$now: $COMMENT" >> "./$dir/_comments"
|
echo "$now: $COMMENT" >> "./$dir/_comments"
|
||||||
|
|
||||||
# TAR ALL ARCHIVE FILES
|
# TAR G1sms+ FILES (WITH EXCLUSIONS!!)
|
||||||
tar -cvzf G1sms+_backup_$now.tar.gz --exclude 'init.sh' --exclude 'constants.py' --exclude 'TAG' --exclude 'history*' --exclude 'trash' --exclude 'print' --exclude 'wallets' --exclude 'wallets_swarm' --exclude 'g1sms.priv.key' ./$dir
|
tar -cvzf ~/G1sms+_backup_$now.tar.gz --exclude 'g1sms.preoni.*' --exclude 'authfile' --exclude 'init.sh' --exclude '.git' --exclude 'billets' --exclude 'constants.py' --exclude 'TAG' --exclude 'history*' --exclude 'trash' --exclude 'print' --exclude 'wallets' --exclude 'wallets_swarm' --exclude 'g1sms.priv.key' ./$dir
|
||||||
|
|
||||||
mkdir -p /tmp/CODE/
|
mkdir -p /tmp/CODE/ && tar xzf ~/G1sms+_backup_$now.tar.gz -C /tmp/CODE/ && rm -f ~/G1sms+_backup_$now.tar.gz
|
||||||
mv G1sms+_backup_$now.tar.gz /tmp/CODE/G1sms+.latest.tgz
|
|
||||||
cp ./$dir/install*.sh /tmp/CODE/
|
|
||||||
|
|
||||||
# PUBLISH IT
|
# PUBLISH IT
|
||||||
hash=$(su $YOU -c "ipfs add -rq /tmp/CODE/ -w | tail -n 1")
|
hash=$(su $YOU -c "ipfs add -rq /tmp/CODE/ -w | tail -n 1")
|
||||||
|
@ -67,5 +69,3 @@ rm -Rf /tmp/CODE
|
||||||
|
|
||||||
echo "_CHAIN: NEW /ipfs/$hash // $hop PUBLISHED with \"SWARM_CODE_MASTER\" key
|
echo "_CHAIN: NEW /ipfs/$hash // $hop PUBLISHED with \"SWARM_CODE_MASTER\" key
|
||||||
ipfs get --output=./ /ipns/$publish"
|
ipfs get --output=./ /ipns/$publish"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# 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 MASTERKEYFILE encryption to IPFS
|
# BACKUP G1sms+ current Devlt code and push it with NODE_G1AUTHFILE encryption to IPFS
|
||||||
################################################################################
|
################################################################################
|
||||||
## GET LATEST DEV $ROOT
|
## GET LATEST DEV $ROOT
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
###########################################################################################
|
||||||
|
# cron_G1TAG_REFRESH.sh
|
||||||
|
# Scan all TAG created by current $IPFSNODEID
|
||||||
|
# Update local and Publish it
|
||||||
|
# Remove too old or empty ones
|
||||||
|
##################################################################
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
NANODATE=$(date -u +%s%N) #1569692075385428020
|
||||||
|
|
||||||
|
# PROTECT from null HASH
|
||||||
|
for tag in ./wallets/.$IPFSNODEID/TAG/*; do
|
||||||
|
function rmtag () {
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: rm -Rf ./wallets/.$IPFSNODEID/TAG/${tagj}"
|
||||||
|
rm -Rf ./TAG/${tagj}
|
||||||
|
rm -f ./wallets/.$IPFSNODEID/TAG/${tagj}
|
||||||
|
rm -f ./wallets_swarm/.$IPFSNODEID/TAG/${tagj}
|
||||||
|
rm -f /home/$YOU/.ipfs/keystore/${tagj}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Refresh G1Tag created by this NODE
|
||||||
|
tagj=$(echo $tag | cut -d '/' -f 5)
|
||||||
|
if [[ "${tagj}" == "" ]]; then echo "__SUB:cron_G1TAG_REFRESH.sh: EMPTY"; continue; fi
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: WORKING ON ${tagj}"
|
||||||
|
RR=$($YOU -c "ipfs cat /ipns/${tagj}/TAG_id | sed s/\ //g");
|
||||||
|
if [[ "$RR" == "" ]]; then
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag Destroyed !!!??";
|
||||||
|
|
||||||
|
rmtag
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# RE-SYNC LOCAL & SWARM G1TAG - TODO Check for G1Tag chain corruption
|
||||||
|
mv ./TAG/${RR} ./TAG/${RR}.old
|
||||||
|
mkdir -p ./TAG/${RR}
|
||||||
|
chown -R $YOU ./TAG/${RR}
|
||||||
|
su $YOU -c "ipfs get --output=./TAG/${RR} /ipns/${tagj}"
|
||||||
|
oldtagval=$(cat ./TAG/${RR}.old/TAG_amount)
|
||||||
|
curtagval=$(cat ./TAG/${RR}/TAG_amount)
|
||||||
|
oldtagn=$(cat ./TAG/${RR}.old/TAG_n)
|
||||||
|
curtagn=$(cat ./TAG/${RR}/TAG_n)
|
||||||
|
oldtagchain=$(cat ./TAG/${RR}.old/TAG_chain)
|
||||||
|
curtagchain=$(cat ./TAG/${RR}/TAG_chain)
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: ./TAG/$RR VALUE: ($oldtagn) $oldtagval ZEN -> ($curtagn) $curtagval ZEN"
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: $oldtagchain -> $curtagchain"
|
||||||
|
|
||||||
|
rm -Rf ./TAG/${RR}.old
|
||||||
|
if [[ $curtagval -eq 0 || "$curtagval" == "" ]]; then rmtag; continue; fi
|
||||||
|
|
||||||
|
# SHOULD PUBLISH ONLY MORE THAN 6h NO USE G1TAG
|
||||||
|
last=$(cat ./TAG/${RR}/TAG_nanodate)
|
||||||
|
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
|
||||||
|
# G1TAG TIME SYNC 21600 milliards de nanosecondes = 6h
|
||||||
|
if [[ $timediff -gt 21600000000000 ]]; then
|
||||||
|
|
||||||
|
# GET PUBLISHKEY for that G1TAG
|
||||||
|
if [[ ! -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: GET PUBLISHKEY for that G1TAG";
|
||||||
|
su $YOU -c "ipfs get -o /home/$YOU/.ipfs/keystore/${RR}.crypt /ipns/$tagj/TAG_publishkey.MASTER.crypt"
|
||||||
|
if [[ ! -f /home/$YOU/.ipfs/keystore/${RR}.crypt ]]; then log "__SUB:cron_MINUTE.sh: error getting publishkey"; continue; fi
|
||||||
|
./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i /home/$YOU/.ipfs/keystore/${RR}.crypt -o /home/$YOU/.ipfs/keystore/$RR
|
||||||
|
rm /home/$YOU/.ipfs/keystore/${RR}.crypt
|
||||||
|
fi
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag PUBLISHKEY OK : /home/$YOU/.ipfs/keystore/${RR}"
|
||||||
|
echo ${NANODATE} > ./TAG/${RR}/TAG_nanodate
|
||||||
|
# PUBLISH VERIFIED G1Tag VERSION
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# RECORD TAG_chain And HASH again
|
||||||
|
echo "$I" > "./TAG/${JDESTRR}/TAG_chain"
|
||||||
|
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
||||||
|
# IPNS $JDESTRR PUBLISH
|
||||||
|
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
|
||||||
|
echo "__SUB:cron_G1TAG_REFRESH.sh: G1Tag IPNS PUBLISH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
done
|
||||||
|
##################################################################
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Activate SUPPORT MODE: open ssh over IPFS
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
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/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
|
||||||
|
|
||||||
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
||||||
|
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
|
||||||
|
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||||
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
|
cd $GPATH
|
||||||
|
|
||||||
|
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/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 ls"
|
|
@ -7,103 +7,102 @@
|
||||||
# CE FICHIER cron_MINUTE.sh EST EXECUTE TOUTES LES MINUTES
|
# CE FICHIER cron_MINUTE.sh EST EXECUTE TOUTES LES MINUTES
|
||||||
# IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME
|
# IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
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/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; 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 [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
||||||
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
CHEMIN="/home/$YOU/G1sms+"
|
cd $GPATH
|
||||||
cd $CHEMIN
|
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
|
|
||||||
timebar=$(date +%H%M)
|
timebar=$(date +%H:%M)
|
||||||
|
|
||||||
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system. sudo -s ?"; exit; fi
|
|
||||||
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
|
|
||||||
|
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# Refresh All peers SWARM Wallets.
|
if [[ "$1" == "" ]]; then
|
||||||
##################################################################
|
|
||||||
ipfs_swarm_wallets_refresh "SIMPLE"
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# PRINT G1Tag
|
|
||||||
# CREATE and REMOVE rr.bin -> done.rr
|
|
||||||
if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then
|
|
||||||
log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID"
|
|
||||||
mkdir -p ./wallets/.$IPFSNODEID/PRINT/
|
|
||||||
|
|
||||||
for qrrtag in ./wallets_swarm/.$IPFSNODEID/PRINT/*.bin; do
|
|
||||||
rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1)
|
|
||||||
if [[ ! -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" ]]; then
|
|
||||||
log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)"
|
|
||||||
./shell/natools.py decrypt -k "$MASTERKEYFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png"
|
|
||||||
log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)"
|
|
||||||
brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin"
|
|
||||||
log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)"
|
|
||||||
brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0
|
|
||||||
log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)"
|
|
||||||
# INFORM PRINT DONE
|
|
||||||
echo "OK" > ./wallets/.$IPFSNODEID/PRINT/done.$rr
|
|
||||||
I=$(ipfs_node_wallets_add)
|
|
||||||
else
|
|
||||||
lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g )
|
|
||||||
log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
|
||||||
rm -f "./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
|
||||||
rm -f "${lqrrtag}"
|
|
||||||
I=$(ipfs_node_wallets_add)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE"
|
|
||||||
for scan in ./wallets_swarm/.Qm*/PRINT/done.*; do
|
|
||||||
lscan=$(echo $scan | sed s/_swarm//g )
|
|
||||||
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
|
||||||
lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
|
||||||
log "__SUB:cron_MINUTE.sh: REMOVE ./wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)"
|
|
||||||
rm -f ./wallets/.$lid/PRINT/$lrr.bin
|
|
||||||
rm -f "${lscan}"
|
|
||||||
I=$(ipfs_node_wallets_add)
|
|
||||||
done
|
|
||||||
|
|
||||||
rm "/tmp/G1Tag.bin"
|
|
||||||
rm "/tmp/G1Tag.png"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##################################################################
|
|
||||||
if [[ "$timebar" == "0300" ]]; then
|
|
||||||
##################################################################
|
|
||||||
##################################################################
|
|
||||||
# Refresh G1Tag created by this NODE
|
|
||||||
# PROTECT from null HASH
|
|
||||||
for tag in ./wallets/.$IPFSNODEID/TAG/*; do
|
|
||||||
tagj=$(echo $tag | cut -d '/' -f 5)
|
|
||||||
log "__SUB:cron_MINUTE.sh: WORKING ON ${tagj}"
|
|
||||||
RR=$(su $YOU -c "ipfs cat /ipns/${tagj}/TAG_id | sed s/\ //g");
|
|
||||||
if [[ ! $RR && "${tagj}" != "" ]]; then echo "G1 Tag Destroyed"; echo "TODO: rm -Rf ./wallets/.$IPFSNODEID/TAG/${tagj} ???"; continue; fi
|
|
||||||
|
|
||||||
# GET PUBLISHKEY for that G1TAG
|
|
||||||
su $YOU -c "ipfs get -o /home/$YOU/.ipfs/keystore/${RR}.crypt /ipns/$tagj/TAG_publishkey.MASTER.crypt"
|
|
||||||
if [[ ! -f /home/$YOU/.ipfs/keystore/${RR}.crypt ]]; then log "__SUB:cron_MINUTE.sh: error getting publishkey"; continue; fi
|
|
||||||
./shell/natools.py decrypt -k "$MASTERKEYFILE" -i /home/$YOU/.ipfs/keystore/${RR}.crypt -o /home/$YOU/.ipfs/keystore/$RR
|
|
||||||
|
|
||||||
log "__SUB:cron_MINUTE.sh: G1Tag PUBLISHKEY decrypted and loaded in /home/$YOU/.ipfs/keystore/${RR}"
|
|
||||||
|
|
||||||
# RE-SYNC LOCAL & SWARM G1TAG (TODO Check G1Tag chain validity)
|
|
||||||
rm -f ./TAG/${RR}/*
|
|
||||||
su $YOU -c "ipfs get --output=./TAG/${RR} /ipns/${tagj}"
|
|
||||||
|
|
||||||
# PUBLISH VERIFIED G1Tag VERSION
|
|
||||||
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
|
||||||
# RECORD TAG_chain And HASH again
|
|
||||||
echo "$I" > "./TAG/${JDESTRR}/TAG_chain"
|
|
||||||
I=$(su $YOU -c "ipfs add -qr ./TAG/${RR} | tail -n 1")
|
|
||||||
# IPNS $JDESTRR PUBLISH
|
|
||||||
J=$(su $YOU -c "ipfs name publish -k ${RR} --quieter /ipfs/${I}")
|
|
||||||
|
|
||||||
done
|
|
||||||
##################################################################
|
##################################################################
|
||||||
|
echo "It is $timebar in the morning, or in the night? It depends on your day..."
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
if [[ "$1" == "PRINT" ]]; then
|
||||||
|
##################################################################
|
||||||
|
##################################################################
|
||||||
|
# Refresh All peers SWARM Wallets.
|
||||||
|
##################################################################
|
||||||
|
ipfs_swarm_wallets_refresh "SIMPLE"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# PRINT G1Tag PRINTED FROM ANOTHER NODE (TODO: Correct BAD Cypher KEY + BUG why last image png layers are not printed???)
|
||||||
|
# CREATE and REMOVE rr.bin -> done.rr
|
||||||
|
if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then
|
||||||
|
log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID"
|
||||||
|
mkdir -p ./wallets/.$IPFSNODEID/PRINT/
|
||||||
|
|
||||||
|
for qrrtag in ./wallets_swarm/.$IPFSNODEID/PRINT/*.bin; do
|
||||||
|
rr=$(echo $qrrtag | cut -d '/' -f 5 | cut -d '.' -f 1)
|
||||||
|
if [[ ! -f "./wallets/.$IPFSNODEID/PRINT/done.$rr" ]]; then
|
||||||
|
log "__SUB:cron_MINUTE.sh: PRINT G1Tag $rr - START: $(date)"
|
||||||
|
./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "${qrrtag}" -o "/tmp/G1Tag.png"
|
||||||
|
log "__SUB:cron_MINUTE.sh: natools.py decrypt - $(date)"
|
||||||
|
brother_ql_create --model QL-700 "/tmp/G1Tag.png" --label-size 62 > "/tmp/G1Tag.bin"
|
||||||
|
log "__SUB:cron_MINUTE.sh: brother_ql_create - $(date)"
|
||||||
|
brother_ql_print "/tmp/G1Tag.bin" /dev/usb/lp0
|
||||||
|
log "__SUB:cron_MINUTE.sh: brother_ql_print - $(date)"
|
||||||
|
# INFORM PRINT DONE
|
||||||
|
echo "OK" > ./wallets/.$IPFSNODEID/PRINT/done.$rr
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
else
|
||||||
|
lqrrtag=$(echo "${qrrtag}" | sed s/_swarm//g )
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE OLD DONE PRINT ${lqrrtag} + ./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
||||||
|
rm -f "./wallets/.$IPFSNODEID/PRINT/done.$rr"
|
||||||
|
rm -f "${lqrrtag}"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE OLD PRINT MARKED AS DONE"
|
||||||
|
for scan in ./wallets_swarm/.Qm*/PRINT/done.*; do
|
||||||
|
lscan=$(echo $scan | sed s/_swarm//g )
|
||||||
|
lid=$(echo $scan | cut -d '/' -f 3 | cut -d '.' -f 2 )
|
||||||
|
lrr=$(echo $scan | cut -d '/' -f 5 | cut -d '.' -f 2 )
|
||||||
|
log "__SUB:cron_MINUTE.sh: REMOVE ./wallets/.$lid/PRINT/$lrr.bin OLD PRINT ${lscan} SENT to $lid ($lrr.bin)"
|
||||||
|
rm -f ./wallets/.$lid/PRINT/$lrr.bin
|
||||||
|
rm -f "${lscan}"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
done
|
||||||
|
|
||||||
|
rm "/tmp/G1Tag.bin"
|
||||||
|
rm "/tmp/G1Tag.png"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
if [[ "$1" == "KALKUN" ]]; then
|
||||||
|
##################################################################
|
||||||
|
for number in ./wallets/*; do
|
||||||
|
member=""
|
||||||
|
phone=$(echo $number | cut -d '/' -f 3);
|
||||||
|
if [[ -f $number/$phone.uidname ]]; then member=$(cat $number/$phone.uidname); fi
|
||||||
|
if [[ ! $member ]]; then member=$phone; fi
|
||||||
|
if [[ $phone && $member ]]; then add_contact $phone $member; log "__SUB:cron_MINUTE.sh: KALKUN add_contact $phone $member"; fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
if [[ "$1" == "TAG" ]]; then
|
||||||
|
##################################################################
|
||||||
|
for tag in ./TAG/*; do
|
||||||
|
echo $tag
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
##################################################################
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
###################################################################################################################################
|
###################################################################################################################################
|
||||||
|
|
||||||
###################################################################################################################################
|
###################################################################################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
|
||||||
|
## Récupère les données du profile
|
||||||
|
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
|
||||||
|
|
||||||
function sms_SEND () {
|
function sms_SEND () {
|
||||||
# sms_SEND ($1=phone, $2=message)
|
# sms_SEND ($1=phone, $2=message)
|
||||||
local dest="$1"
|
local dest="$1"
|
||||||
|
@ -14,7 +21,7 @@ function sms_SEND () {
|
||||||
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
|
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
|
||||||
if [[ -d ./wallets/$dest ]]; then
|
if [[ -d ./wallets/$dest ]]; then
|
||||||
# TEST IF $dest IS ON CURRENT NODE
|
# TEST IF $dest IS ON CURRENT NODE
|
||||||
gammu-smsd-inject -l TEXT "$dest" -text "$mess" 1>&2
|
gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
|
||||||
else
|
else
|
||||||
# Send SMS through $dest NODE (TODO: send it like PRINT, TASK, ...)
|
# Send SMS through $dest NODE (TODO: send it like PRINT, TASK, ...)
|
||||||
DESTNODEID=$(cat ./wallets_swarm/$dest/MASTERPHONE.ipfsid)
|
DESTNODEID=$(cat ./wallets_swarm/$dest/MASTERPHONE.ipfsid)
|
||||||
|
@ -115,14 +122,15 @@ if [[ $PHONE ]]; then rm -Rf ./wallets_swarm/$PHONE; fi
|
||||||
#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
|
||||||
#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
|
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
|
||||||
for id in ./wallets_swarm/.Qm*/;
|
#for id in ./wallets/.Qm*/;
|
||||||
|
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: ipfs get --output=./wallets_swarm/ /ipns/$id"
|
||||||
rm -Rf ./wallets_swarm/.$id
|
rm -Rf ./wallets_swarm/.$id
|
||||||
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
|
./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
|
||||||
done
|
done
|
||||||
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"
|
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"
|
||||||
|
|
||||||
|
@ -242,7 +250,7 @@ function sms_uid2key (){
|
||||||
|
|
||||||
# Search fo duplicate
|
# Search fo duplicate
|
||||||
DUP=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidname | cut -f 3 -d '/')
|
DUP=$(grep -Rwl "$ASKWALLET" ./wallets/*/*.uidname | cut -f 3 -d '/')
|
||||||
if [[ "$DUP" != "" ]]; then
|
if [[ "$DUP" != "" && "$DUP" != "$PHONE" ]]; then
|
||||||
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE prend le même $ASKWALLET, que $DUP"
|
sms_SEND "$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" "Vous devez savoir que $ASKWALLET est associé à un autre téléphone que le votre également!"
|
||||||
fi
|
fi
|
||||||
|
@ -305,7 +313,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
SMSNODE="./wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
|
SMSNODE="./wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
|
||||||
PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password
|
PINFILE="./wallets/$PHONE/$PHONE.pin" # Contains phone wallet diceware password
|
||||||
GPGPINFILE="./wallets/$PHONE/$PHONE.pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
|
GPGPINFILE="./wallets/$PHONE/$PHONE.pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
|
||||||
AUTHCRYPTFILE="./wallets/$PHONE/$PHONE.authfile.crypt" # TEST!!! crypt with $PHONE wallet keypair
|
AUTHCRYPTFILE="./wallets/$PHONE/$PHONE.authfile.crypt" # Crypt with $NODE_G1PUBKEY
|
||||||
PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" # Contains phone wallet public key (RIB)
|
PUBKEYFILE="./wallets/$PHONE/$PHONE.pub" # Contains phone wallet public key (RIB)
|
||||||
UNITFILE="./wallets/$PHONE/$PHONE.unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
|
UNITFILE="./wallets/$PHONE/$PHONE.unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
|
||||||
|
|
||||||
|
@ -324,6 +332,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
DABUIDF="./wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
|
DABUIDF="./wallets/$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/$IPFSNODEID.uidna")
|
||||||
|
[[ $NODEUIDNA == "" ]] && NODEUIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
|
||||||
######################################################################
|
######################################################################
|
||||||
# (NO PIN) = FIRST ACCOUNT: Create wallet
|
# (NO PIN) = FIRST ACCOUNT: Create wallet
|
||||||
if [ ! -f "$PINFILE" ]; then
|
if [ ! -f "$PINFILE" ]; then
|
||||||
|
@ -339,7 +348,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
|
|
||||||
# BACKUP authfile available to authfile or PIN owner (DOUBLON AVEC PIN) TEST
|
# 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"""
|
log "__SUB:sms_INIT_ACCOUNT: ./shell/natools.py encrypt -p $PUBKEY -i ""./authfile"" -o ""$AUTHCRYPTFILE"""
|
||||||
./shell/natools.py encrypt -p $PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "$AUTHCRYPTFILE"
|
||||||
rm -f ./authfile
|
rm -f ./authfile
|
||||||
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE $PIN : $PUBKEY"
|
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE $PIN : $PUBKEY"
|
||||||
|
|
||||||
|
@ -357,11 +366,11 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
#######################
|
#######################
|
||||||
# ACTIVATE G1SMS WALLET
|
# ACTIVATE G1SMS WALLET
|
||||||
#######################
|
#######################
|
||||||
# log "$MASTERKEYFILE $PUBKEY THIRD_PARTY_MANAGER:$MASTERPUB"
|
# log "$NODE_G1AUTHFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY"
|
||||||
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=3.15 --output=$PUBKEY --comment="[G1sms+] $UIDNA$TAIL 3RD:$MASTERPUB " -y)
|
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$NODE_G1AUTHFILE" --amount=3.24 --output=$PUBKEY --comment="[G1sms+] $UIDNA$TAIL 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=$MASTERPUB --comment="[G1sms+] $UIDNA$TAIL 3RD:$MASTERPUB:ACK" -y)
|
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)
|
||||||
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
|
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -370,7 +379,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
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)
|
PIN=$(cat "$PINFILE" | xargs)
|
||||||
echo "" > "$PINFILE"
|
# [[ "$PIN" != "" ]] && echo "" > "$PINFILE" || log "SYSTEM ERROR :: PIN EMPTY !!! GPG???"
|
||||||
|
|
||||||
echo "114" > "$G1COUNTFILE"
|
echo "114" > "$G1COUNTFILE"
|
||||||
echo "$PUBKEY" > "$PUBKEYFILE"
|
echo "$PUBKEY" > "$PUBKEYFILE"
|
||||||
|
@ -405,6 +414,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
PIN=$(cat "$PINFILE" | xargs)
|
PIN=$(cat "$PINFILE" | xargs)
|
||||||
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!"
|
log "__SUB:sms_INIT_ACCOUNT: Old G1sms wallet ;) SECURITY HOLE... Chiffrage PGP du PIN !!!"
|
||||||
echo "${GPGPASS}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE";
|
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
|
else
|
||||||
# ------------>8------------------
|
# ------------>8------------------
|
||||||
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
|
log "__SUB:sms_INIT_ACCOUNT: Déchiffrage PGP PIN..."
|
||||||
|
@ -412,13 +422,14 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
# TODO make decypher less stress on filesystem, use /tmp and ramdisk
|
# 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"
|
echo "${GPGPASS}" | gpg -d -q --output "$PINFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGPINFILE"
|
||||||
PIN=$(cat "$PINFILE" | xargs)
|
PIN=$(cat "$PINFILE" | xargs)
|
||||||
echo "" > "$PINFILE";
|
[[ "$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
|
fi
|
||||||
|
|
||||||
# CYPHER EMAIL FILE
|
# CYPHER EMAIL FILE
|
||||||
if [[ ! -f "$GPGMAILFILE" ]]; then
|
if [[ ! -f "$GPGMAILFILE" ]]; then
|
||||||
# ------------8<------------------
|
# ------------8<------------------
|
||||||
# NO .gpg file, CREATING it (OLD G1sms accounts)
|
log "__SUB:sms_INIT_ACCOUNT: NO EMAIL .gpg file, CREATING it"
|
||||||
if [ -f "$MAILFILE" ]; then
|
if [ -f "$MAILFILE" ]; then
|
||||||
MAIL=$(cat "$MAILFILE");
|
MAIL=$(cat "$MAILFILE");
|
||||||
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
|
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
|
||||||
|
@ -427,10 +438,12 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
fi
|
fi
|
||||||
# ------------>8------------------
|
# ------------>8------------------
|
||||||
else
|
else
|
||||||
# Already existing gpg DECODING IT
|
log "__SUB:sms_INIT_ACCOUNT: DECODING EMAIL .gpg... "
|
||||||
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
|
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
|
||||||
MAIL=$(cat "$MAILFILE");
|
MAIL=$(cat "$MAILFILE");
|
||||||
echo "" > "$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
|
fi
|
||||||
|
|
||||||
# ------------8<------------------
|
# ------------8<------------------
|
||||||
|
@ -486,8 +499,8 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
||||||
|
|
||||||
#################################################################################################################################
|
#################################################################################################################################
|
||||||
function check_account (){
|
function check_account (){
|
||||||
log "__SUB:check_account: SILKAJ...... max 15 sec....."
|
log "__SUB:check_account: SILKAJ...... max 30 sec....."
|
||||||
AMOUNTG1=$(./shell/timeout.sh -t 15 ./silkaj/silkaj amount "$PUBKEY")
|
AMOUNTG1=$(./shell/timeout.sh -t 30 ./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")
|
||||||
|
|
||||||
|
@ -550,8 +563,7 @@ esac
|
||||||
# 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"
|
log "__SUB:make_accounting: LOCAL $VIR amount for $PHONE : $PUBKEY"
|
||||||
# Try to ask silkaj. If timeout, use SWARM 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")
|
||||||
if [[ ! $AMOUNTG1 ]]; then AMOUNTG1=$(bc -l <<< "scale=2; $(cat ./wallets_swarm/$PHONE/$PHONE.g1cents) / 100"); fi
|
|
||||||
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi
|
if [[ "$AMOUNTG1" == "" ]]; then AMOUNTG1=0; fi
|
||||||
# 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")
|
||||||
|
@ -599,11 +611,11 @@ function move_g1cents (){
|
||||||
# MUST ASK MANAGER NODE TO CORRECT g1cents FOR $winnerphone WALLET
|
# MUST ASK MANAGER NODE TO CORRECT g1cents FOR $winnerphone WALLET
|
||||||
# WRITE TASK TO .$NODEID CHANNEL
|
# WRITE TASK TO .$NODEID CHANNEL
|
||||||
mkdir -p ./wallets/.$NODEID/TASK/
|
mkdir -p ./wallets/.$NODEID/TASK/
|
||||||
# USE natools with NODEG1PUB 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
|
||||||
NODEG1PUB=$(cat ./wallets_swarm/.$NODEID/$NODEID.pub)
|
NODEPUB=$(cat ./wallets_swarm/.$NODEID/$NODEID.pub)
|
||||||
./shell/natools.py encrypt -p $NODEG1PUB -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
|
||||||
|
@ -613,3 +625,48 @@ function move_g1cents (){
|
||||||
# UPDATE MY new ./wallet STATUS to SWARM
|
# UPDATE MY new ./wallet STATUS to SWARM
|
||||||
I=$(ipfs_node_wallets_add)
|
I=$(ipfs_node_wallets_add)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#################################################################################################################################
|
||||||
|
# Contact database management
|
||||||
|
function add_contact(){
|
||||||
|
userDB="gammu"
|
||||||
|
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
|
||||||
|
local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
|
||||||
|
|
||||||
|
local PHONE=$1
|
||||||
|
local MEMBERUID=$2
|
||||||
|
|
||||||
|
[[ -z $MEMBERUID ]] && MEMBERUID=$PHONE
|
||||||
|
|
||||||
|
[[ -z $($sql "SELECT * FROM pbk_groups WHERE ID='1'") ]] && $sql "INSERT INTO pbk_groups (ID, Name, id_user, is_public) VALUES ('1', '$(grep "ADRESSE" $MY_PATH/../.profile | awk -F= '{ print $2 }' | tr -d '"')', '1', 'false')"
|
||||||
|
|
||||||
|
if [[ -z $($sql "SELECT * FROM pbk WHERE Number=$PHONE") ]]; then
|
||||||
|
$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)
|
||||||
|
$sql "INSERT INTO user_group (id_group, id_pbk, id_pbk_groups, id_user) VALUES ('$id_user', '$id_user', '1', '1')" || exit 1
|
||||||
|
else
|
||||||
|
log "${red}Contact already exist$c_"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function rm_contact(){
|
||||||
|
userDB="gammu"
|
||||||
|
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
|
||||||
|
local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
|
||||||
|
|
||||||
|
local PHONE=$1
|
||||||
|
local MEMBERUID=$2
|
||||||
|
|
||||||
|
[[ -z $MEMBERUID ]] && MEMBERUID=$PHONE
|
||||||
|
|
||||||
|
if [[ ! -z $($sql "SELECT * FROM pbk WHERE Number=$PHONE") ]]; then
|
||||||
|
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 user_group WHERE id_group='$id_user'" || exit 1
|
||||||
|
else
|
||||||
|
log "${red}Contact doesn't exist$c_"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
After Width: | Height: | Size: 23 KiB |
BIN
shell/g1tag.png
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 32 KiB |
|
@ -1,5 +1,6 @@
|
||||||
duniter.moul.re:443
|
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.monnaielibreoccitanie.org:443
|
g1.monnaielibreoccitanie.org:443
|
||||||
g1.presles.fr:443
|
g1.presles.fr:443
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
# Version: 0.1
|
# Version: 0.1
|
||||||
# License: GPL (http://www.google.com/search?q=GPL)
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
source $MY_PATH/.install/.GPATH
|
||||||
|
|
||||||
# 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)
|
||||||
|
@ -30,9 +35,8 @@ export G1SMS="YES"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
export YOU=$(ps aux --sort=+utime | grep ipfs | 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);
|
||||||
export CHEMIN="/home/$YOU/G1sms+"
|
cd $GPATH
|
||||||
cd $CHEMIN
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# Activate logging to /tmp/g1sms.log (YES/NO)
|
# Activate logging to /tmp/g1sms.log (YES/NO)
|
||||||
export DOLOG="YES"
|
export DOLOG="YES"
|
||||||
|
@ -48,10 +52,10 @@ fi
|
||||||
# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents)
|
# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents)
|
||||||
export COIN="G1"
|
export COIN="G1"
|
||||||
##################################################################
|
##################################################################
|
||||||
# Limit and commission values
|
# Limit and commission values
|
||||||
export LIMIT=2 # Solde minimum = 2 G1
|
export LIMIT=2 # Solde minimum = 2 G1
|
||||||
# FIXED COMMISSION SYSTEM
|
# FIXED COMMISSION SYSTEM
|
||||||
export COMMISSION=1 # transaction commission amount (G1)
|
export COMMISSION=1 # transaction commission amount (G1)
|
||||||
export BILLCOM=20
|
export BILLCOM=20
|
||||||
##################################################################
|
##################################################################
|
||||||
# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK
|
# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK
|
||||||
|
@ -60,9 +64,9 @@ fi
|
||||||
# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES
|
# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES
|
||||||
export NODECOMM=10
|
export NODECOMM=10
|
||||||
##################################################################
|
##################################################################
|
||||||
# SMS SIM Card Phone Number
|
# SMS SIM Card Phone Number
|
||||||
export MASTERPHONE="+33660780131"
|
export MASTERPHONE="+33651136520"
|
||||||
export ADRESSE="au G1FabLab de Toulouse"
|
export ADRESSE="G1_Fablab_Toulouse"
|
||||||
export G1DAB="NO"
|
export G1DAB="NO"
|
||||||
##################################################################
|
##################################################################
|
||||||
# ADMIN COMMAND PHONE ORIGIN
|
# ADMIN COMMAND PHONE ORIGIN
|
||||||
|
@ -73,7 +77,7 @@ fi
|
||||||
export DUNITER="https://g1.duniter.org"
|
export DUNITER="https://g1.duniter.org"
|
||||||
export CESIUM="https://g1.data.le-sou.org"
|
export CESIUM="https://g1.data.le-sou.org"
|
||||||
|
|
||||||
# TODO Use latest Silkaj from "sudo pip3 install silkaj"
|
# TODO Use latest Silkaj from "sudo fredp3 install silkaj"
|
||||||
# export SILKAJ="/usr/local/bin/silkaj"
|
# export SILKAJ="/usr/local/bin/silkaj"
|
||||||
source $CHEMIN/shell/init_keys.sh
|
source $GPATH/shell/init_keys.sh
|
||||||
|
|
|
@ -1,129 +1,148 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
##################################################################
|
##################################################################
|
||||||
# Author: Fred (support@qo-op.com)
|
# Author: Fred (support@qo-op.com)
|
||||||
# Version: 0.1
|
# Version: 0.2
|
||||||
# License: GPL (http://www.google.com/search?q=GPL)
|
# License: GPL (http://www.google.com/search?q=GPL)
|
||||||
##################################################################
|
##################################################################
|
||||||
# CHECK & WARN | CREATE Keys (gpg encrypt, G1wallet, IPNS publish)
|
# CHECK & WARN | CREATE Keys (gpg encrypt, G1wallet, IPNS publish)
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
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/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; 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)
|
||||||
# TODO Make it directory independant. (for now it is tested for pi running ipfs and code in $HOME/G1sms+
|
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
||||||
CHEMIN="/home/$YOU/G1sms+"
|
NANODATE=$(date -u +%s%N) #1569692075385428020
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
|
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
|
||||||
##################################################################
|
##################################################################
|
||||||
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g)
|
export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/\"//g) #"
|
||||||
|
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
|
||||||
|
|
||||||
|
# GET SWARM KEY G1sms+ .ipfs/swarm.key
|
||||||
|
# export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
|
||||||
|
# if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# G1sms+ Swarm KEYS
|
# G1sms+ Swarm KEYS
|
||||||
##################################################################
|
##################################################################
|
||||||
# G1sms Service - G1Wallet
|
# G1sms Service - G1Wallet
|
||||||
if [[ -f "${CHEMIN}/g1sms.pub.key" && -f "${CHEMIN}/g1sms.priv.key" ]]; then
|
#
|
||||||
chown root:root ${CHEMIN}/g1sms.priv.key
|
# CLEF G1 DU SWARM
|
||||||
chmod 600 ${CHEMIN}/g1sms.priv.key
|
SWARM_G1PUBKEY=$(cat "${GPATH}/g1sms.pub.key")
|
||||||
export MASTERPUB=$(cat "${CHEMIN}/g1sms.pub.key")
|
SWARM_G1AUTHFILE="${GPATH}/g1sms.priv.key"
|
||||||
export MASTERKEYFILE="${CHEMIN}/g1sms.priv.key"
|
|
||||||
else
|
# CLEF G1 NODE = CLEF G1 SWARM !!
|
||||||
echo "ATTENTION!! Vous devez posséder la clef du G1 Wallet utilisé par le SWARM G1sms!!"
|
if [[ ! -e "./g1sms.preoni.pub.key" && -f "./g1sms.priv.key" ]]; then
|
||||||
./shell/parle.sh "Les clefs du portefeuille essaim G1 SMS sont absente. Au revoir."
|
log "__SUB:initkeys.sh: Linking preoni Keys to SWARM G1 Keys"
|
||||||
echo "Fichiers manquants:"
|
ln -s ./g1sms.priv.key ./g1sms.preoni.priv.key
|
||||||
echo "${CHEMIN}/g1sms.pub.key"
|
ln -s ./g1sms.pub.key ./g1sms.preoni.pub.key
|
||||||
echo "${CHEMIN}/g1sms.priv.key"
|
elif [[ ! -f ./g1sms.preoni.priv.key ]]; then
|
||||||
echo "Contactez nous sur https://g1sms.fr"
|
# CREATE NODE G1 KEYS AND FILES
|
||||||
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "Clef de G1Wallet du SWARM g1sms.priv.key manquante! contactez-nous pour la recevoir https://g1sms.fr" 1>&2
|
mkdir -p ./wallets/.$IPFSNODEID/TASK
|
||||||
exit
|
################################################
|
||||||
|
# GIVE NAME TO NODE G1 WALLET: "0000diceware"
|
||||||
|
# CREATE "preoni" KeyS & ./wallets/.Qm***/_files
|
||||||
|
################################################
|
||||||
|
# 4 derniers chiffres du MASTERPHONE + diceware
|
||||||
|
PRE=${MASTERPHONE:8:4}
|
||||||
|
ZUID=$(./shell/diceware.sh 1 | xargs)
|
||||||
|
# Check if already existing among all swarm wallets
|
||||||
|
while [[ $(grep -Rwl "$PRE$ZUID" ./wallets_swarm/.*/_uidna) ]]; do ZUID=$(./shell/diceware.sh 1 | xargs); done
|
||||||
|
NODE_UIDNA="$PRE$ZUID"
|
||||||
|
NODE_PIN=$(./shell/diceware.sh | xargs)
|
||||||
|
|
||||||
|
NODE_G1PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NODE_UIDNA" -password="$NODE_PIN")
|
||||||
|
if [[ ! $NODE_G1PUBKEY ]]; then log "PROBLEME CREATION DU WALLET G1 POUR $NODE_UIDNA = $IPFSNODEID"; exit; fi
|
||||||
|
log "__SUB:initkeys.sh: NODE G1WALLET CESIUM: $NODE_UIDNA / $NODE_PIN CREATED..."
|
||||||
|
|
||||||
|
# WRITE NODE_UIDNA
|
||||||
|
echo "$NODE_UIDNA" > "./wallets/.$IPFSNODEID/_uidna" ################# _uidna
|
||||||
|
|
||||||
|
############ SYSTEM MODIFY hosts & hostname ################
|
||||||
|
# WRITE NODE uidna NAME TO /etc/hosts & .Qm*/_uidna file
|
||||||
|
echo "127.0.0.101 $NODE_UIDNA" >> "/etc/hosts"
|
||||||
|
echo $NODE_UIDNA > "/etc/hostname"
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# BACKUP AUTHFILE FOR FOR SWARM USE (TODO: Refine Swarm, Node access): GIVES SMARM WITHDRAW ACTION
|
||||||
|
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "./authfile" -o "./wallets/.$IPFSNODEID/_authfile.swarm.crypt"
|
||||||
|
|
||||||
|
echo $NODE_G1PUBKEY > "./wallets/.$IPFSNODEID/_pub" ################# _pub
|
||||||
|
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/_ipfsid" ################# _ipfsid
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: _pub = $NODE_G1PUBKEY "
|
||||||
|
|
||||||
|
# BACKUP $IPFSNODEID config ################# _ipfsconfig.swarm.crypt : GIVES SMARM NODE RESTORE ACTION
|
||||||
|
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] BACKUP IPFS NODE CONFIG to ./wallets/.$IPFSNODEID/_ipfsconfig.swarm.crypt"
|
||||||
|
|
||||||
|
# Cyper & Empty PIN
|
||||||
|
echo "${NODE_PIN}" > "./wallets/.$IPFSNODEID/_pin" ################# _pin / _pin.node.crypt / _pin.gpg
|
||||||
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./wallets/.$IPFSNODEID/_pin" -o "./wallets/.$IPFSNODEID/_pin.node.crypt"
|
||||||
|
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/_pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/_pin"
|
||||||
|
echo "" > "./wallets/.$IPFSNODEID/_pin"
|
||||||
|
|
||||||
|
echo "314" > "./wallets/.$IPFSNODEID/_g1cents" ################# _g1cents
|
||||||
|
echo $NANODATE > "./wallets/.$IPFSNODEID/_nanodate" ################# _nanodate
|
||||||
|
|
||||||
|
# SILKAJ INIT G1 NODE WALLET
|
||||||
|
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=3.24 --output=$NODE_G1PUBKEY --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $NODE_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)
|
||||||
|
|
||||||
|
log "__SUB:initkeys.sh: [ADMIN] NODE G1sms+ $NODE_UIDNA : ls ./wallets/.$IPFSNODEID"
|
||||||
|
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ NODE $NODE_UIDNA ($IPFSNODEID)" 1>&2
|
||||||
|
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODE_G1PUBKEY" 1>&2
|
||||||
|
|
||||||
|
# CREATE preoni FILES
|
||||||
|
mv ./authfile ./g1sms.preoni.priv.key
|
||||||
|
echo $NODE_G1PUBKEY > ./g1sms.preoni.pub.key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################################################
|
NODE_UIDNA=$(cat "./wallets/.$IPFSNODEID/_uidna")
|
||||||
# NODE KEYS (SCRIPT CALLED BY ROOT !!! gammu is root)
|
## INIT NODE G1 PUB & PRIV KEY
|
||||||
##################################################################
|
NODE_G1PUBKEY=$(cat "${GPATH}/g1sms.preoni.pub.key")
|
||||||
export IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
|
NODE_G1AUTHFILE="${GPATH}/g1sms.preoni.priv.key"
|
||||||
export NANODATE=$(date -u +%s%N) #1569692075385428020
|
|
||||||
|
|
||||||
# CHECK LAST TIME NODE HAD ACTION
|
##########################################################
|
||||||
if [[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate ]]; then
|
# MEMORIZE NODE NANODATE EXECUTION TIME (for ntpdate regular sync)
|
||||||
last=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate)
|
if [[ -f ./wallets/.$IPFSNODEID/_nanodate ]]; then
|
||||||
|
last=$(cat ./wallets/.$IPFSNODEID/_nanodate)
|
||||||
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
|
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
|
||||||
# Get median nanodate before
|
# NODE TIME SYNC 600 milliards de nanosecondes = 600 s = 10 mn
|
||||||
# NODE TIME SYNC 120 milliards de nanosecondes
|
if [[ $timediff -gt 600000000000 ]]; then
|
||||||
if [[ $timediff -gt 120000000000 ]]; then
|
# RUN & LOG ntpdate
|
||||||
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
|
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
|
||||||
export NANODATE=$(date -u +%s%N)
|
export NANODATE=$(date -u +%s%N)
|
||||||
fi
|
fi
|
||||||
fi
|
echo $NANODATE > ./wallets/.$IPFSNODEID/_nanodate
|
||||||
|
|
||||||
echo $NANODATE > ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
# CREATE NODE .$IPFSNODEID SPACE (G1Wallet + TASK + NODE DETAILS)
|
|
||||||
#################################################################
|
|
||||||
# Create G1sms Wallet with that NODE G1 wallet as member reference
|
|
||||||
if [[ ! -f "./wallets/.$IPFSNODEID/$IPFSNODEID.pub" ]]; then
|
|
||||||
mkdir -p ./wallets/.$IPFSNODEID/TASK
|
|
||||||
NODEG1WALLET=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS")
|
|
||||||
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
|
|
||||||
./shell/natools.py encrypt -p $NODEG1WALLET -i "./authfile" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.authfile.crypt"
|
|
||||||
rm -f ./authfile
|
|
||||||
|
|
||||||
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
|
|
||||||
echo $IPFSNODEID > "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsid"
|
|
||||||
log "__SUB:initkeys.sh: [ADMIN] G1sms+ CREATE G1WALLET FOR: $IPFSNODEID: pub = $NODEG1WALLET "
|
|
||||||
|
|
||||||
# BACKUP $IPFSNODEID config
|
|
||||||
./shell/natools.py encrypt -p $MASTERPUB -i "/home/$YOU/.ipfs/config" -o "./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt"
|
|
||||||
log "__SUB:initkeys.sh: [ADMIN] BACKUP $IPFSNODEID NODE CONFIG to ./wallets/.$IPFSNODEID/$IPFSNODEID.ipfsconfig.crypt "
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# GIVE NAME TO WALLET
|
|
||||||
#######################
|
|
||||||
# 4 derniers chiffres du numéro de téléphone
|
|
||||||
TAIL=${MASTERPHONE:8:4}
|
|
||||||
# No UIDNA yet. Create new
|
|
||||||
UIDNA=$(./shell/diceware.sh 1 | xargs)
|
|
||||||
# Check if already existing among all swarm wallets
|
|
||||||
while [[ $(grep -Rwl "$UIDNA$TAIL" ./wallets_swarm/*/*.uidna) ]]; do UIDNA=$(./shell/diceware.sh 1 | xargs); done
|
|
||||||
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
|
|
||||||
|
|
||||||
# CREATE NODE WALLET LIKE A PHONE (Stored in wallets/.$IPFSNODEID)
|
|
||||||
echo "${GPGPASS}" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
|
||||||
echo "${GPGPASS}" | gpg -q --output "./wallets/.$IPFSNODEID/$IPFSNODEID.pin.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
|
||||||
echo "" > "./wallets/.$IPFSNODEID/$IPFSNODEID.pin"
|
|
||||||
echo "$UIDNA$TAIL" > "./wallets/.$IPFSNODEID/$IPFSNODEID.uidna"
|
|
||||||
echo "314" > "./wallets/.$IPFSNODEID/$IPFSNODEID.g1cents"
|
|
||||||
echo $NODEG1WALLET > "./wallets/.$IPFSNODEID/$IPFSNODEID.pub"
|
|
||||||
|
|
||||||
# SILKAJ INIT G1 NODE WALLET
|
|
||||||
TX_IN=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=3.15 --output=$NODEG1WALLET --comment="[G1sms+] G1NODE ($ADMINPSEUDO) $UIDNA$TAIL $IPFSNODEID" -y)
|
|
||||||
TX_OUT=$(./silkaj/silkaj transaction --auth-scrypt -salt="$IPFSNODEID" -password="$GPGPASS" --amount=0.1 --output=$MASTERPUB --comment="[G1sms+] G1NODE $IPFSNODEID:ACK" -y)
|
|
||||||
log "__SUB:initkeys.sh: [ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallet/.$IPFSNODEID"
|
|
||||||
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "[ADMIN] G1sms+ $ADMINPSEUDO-$UIDNA$TAIL OUVERT POUR NODE: ls ./wallets/.$IPFSNODEID" 1>&2
|
|
||||||
gammu-smsd-inject -l TEXT "$ADMINPHONE" -text "$NODEG1WALLET" 1>&2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
#INFORM ABOUT NODE CAPACITIES
|
#INFORM ABOUT NODE CAPACITIES
|
||||||
export NODEG1PUB=$(cat "./wallets/.$IPFSNODEID/$IPFSNODEID.pub")
|
export NODEPUB=$(cat "./wallets/.$IPFSNODEID/_pub")
|
||||||
|
|
||||||
## IS IT A SMS NODE (gammu-smsd is installed)??
|
## IS IT A SMS NODE (gammu-smsd is installed)??
|
||||||
if [[ $G1SMS ]]; then
|
if [[ $G1SMS ]]; then
|
||||||
echo $MASTERPHONE > "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"
|
echo $MASTERPHONE > "./wallets/.$IPFSNODEID/_sms"
|
||||||
else
|
else
|
||||||
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.sms"; fi
|
if [ -f "./wallets/.$IPFSNODEID/_sms" ]; then rm -f "./wallets/.$IPFSNODEID/_sms"; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## IS THERE USB PRINTER CONNECTED?
|
## IS THERE USB PRINTER CONNECTED?
|
||||||
if [[ -e "/dev/usb/lp0" ]]; then
|
if [[ -e "/dev/usb/lp0" ]]; then
|
||||||
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
|
log "G1CORE: IMPRESSION G1Tag ACTIF .............."
|
||||||
echo $ADRESSE > "./wallets/.$IPFSNODEID/$IPFSNODEID.where"
|
echo $ADRESSE > "./wallets/.$IPFSNODEID/_where"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## IS THERE SERIAL QR CODE READER CONNECTED?
|
## IS THERE SERIAL QR CODE READER CONNECTED?
|
||||||
if [[ -e "/dev/ttyACM0" ]]; then
|
if [[ -e "/dev/ttyACM0" ]]; then
|
||||||
log "G1CORE: SCAN G1Tag ACTIF .............."
|
log "G1CORE: SCAN G1Tag ACTIF .............."
|
||||||
export G1TX="YES"
|
export G1TX="YES"
|
||||||
echo "/dev/ttyACM0" > "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"
|
echo "/dev/ttyACM0" > "./wallets/.$IPFSNODEID/_scan"
|
||||||
else
|
else
|
||||||
if [ -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan" ]; then rm -f "./wallets/.$IPFSNODEID/$IPFSNODEID.scan"; fi
|
if [ -f "./wallets/.$IPFSNODEID/_scan" ]; then rm -f "./wallets/.$IPFSNODEID/_scan"; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.1
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# TODO: Before June 2020: Get "./billets/$bpath/note.authfile.GPGPASS.gpg" for automatic Payback
|
||||||
|
# Search for old G1Billets for final CHK : Forget & Transfer G1 ?
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
|
||||||
|
# Existence days number can be $1
|
||||||
|
if [[ "$1" ]]; then vieux="$1"; else vieux=210; fi
|
||||||
|
if [[ "$2" ]]; then dest="$2"; else dest=$NODE_G1PUBKEY; fi
|
||||||
|
|
||||||
|
echo "Recherche de G1Billets plus vieux que $vieux jours."
|
||||||
|
Nbillets=$(find billets/ -daystart -mtime +$vieux -type f -name "*.pubkey" | wc -l)
|
||||||
|
echo "$Nbillets G1Billets trouvés..."
|
||||||
|
|
||||||
|
for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do
|
||||||
|
billetname=$(echo $result | cut -d '/' -f 2)
|
||||||
|
if [[ $billetname && "$billetname" != "MEMBERS" ]]; then
|
||||||
|
((Nbillets --))
|
||||||
|
numero=$(echo $billetname | sed s/_/\ /g )
|
||||||
|
creator=$(cat "$result/note.creator")
|
||||||
|
value=$(cat "$result/note.value")
|
||||||
|
unit=$(cat "$result/note.unit")
|
||||||
|
pubkey=$(cat "$result/note.pubkey")
|
||||||
|
salt=$(cat "$result/note.salt")
|
||||||
|
secret=$(cat "$result/note.secret")
|
||||||
|
|
||||||
|
solde=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 balance $pubkey | grep Quantitative | cut -d '=' -f 2 | cut -d ' ' -f 2)
|
||||||
|
|
||||||
|
# GET creator member wallet ($dest) and refund if still at initial G1 value (lost or unused BILL).
|
||||||
|
virement=$solde
|
||||||
|
[[ -f "$result/note.g1" ]] && initialvalue=$(cat "$result/note.g1") && if [[ $solde -eq $initialvalue ]]; then virement=$solde; else virement=1; fi
|
||||||
|
[[ -f "$result/note.memrib" ]] && dest=$(cat "$result/memrib")
|
||||||
|
|
||||||
|
echo ">>> $billetname $pubkey créé par $creator, valeur initiale $virement G1 (initialement $initialvalue G1)."
|
||||||
|
echo ">>> Virer à $dest $virement G1 du G1billet !! ID / Pass:"
|
||||||
|
echo $numero
|
||||||
|
echo $secret $salt
|
||||||
|
echo "/usr/local/bin/silkaj tx --amount=\"$virement\" --output=\"$dest\""
|
||||||
|
|
||||||
|
if [[ "$virement" == "0.0" ]]; then
|
||||||
|
echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result;
|
||||||
|
else
|
||||||
|
PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y)
|
||||||
|
if [[ ! $(echo $PAY | grep "successfully sent") ]]; then
|
||||||
|
echo "!!!! ERREUR: $virement Something Wrong happened with $result. Moving to /tmp/ERROR_BILL_$billetname (please check or remove)"
|
||||||
|
mkdir -p /tmp/ERROR_BILL_$billetname
|
||||||
|
mv $result/* /tmp/ERROR_BILL_$billetname
|
||||||
|
else
|
||||||
|
echo $PAY
|
||||||
|
echo "OK! On supprime $result et continue avec le billet $Nbillets"
|
||||||
|
echo
|
||||||
|
rm -Rf $result
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "MEMBER:" $result
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
g1.le-sou.org:443
|
|
||||||
follow.the.white-rabbit.net:443
|
|
||||||
duniter.moul.re:443
|
duniter.moul.re:443
|
||||||
g1.monnaielibreoccitanie.org:443
|
duniter.dethegeek.eu.org:443
|
||||||
g1.duniter.inso.ovh:443
|
|
||||||
g1.duniter.fr:443
|
|
||||||
g1.presles.fr:443
|
g1.presles.fr:443
|
||||||
g1.duniter.org:443
|
g1.duniter.fr:443
|
||||||
monit.g1.nordstrom.duniter.org:443
|
monit.g1.nordstrom.duniter.org:443
|
||||||
|
g1.le-sou.org:443
|
||||||
|
g1.duniter.org:443
|
||||||
|
g1.monnaielibreoccitanie.org:443
|
||||||
|
follow.the.white-rabbit.net:443
|
||||||
|
g1.acostey.fr:443
|
||||||
|
duniter.acostey.fr:443
|
||||||
|
|
|
@ -11,12 +11,24 @@
|
||||||
# TODO: Create information Channels and moderate OPT IN/OUT
|
# TODO: Create information Channels and moderate OPT IN/OUT
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
log "__SUB:sms_ABO.sh: START ($1=SERVICE, $2=YESNO)"
|
log "__SUB:sms_ABO.sh: START ($1=PHONE, $2=SERVICE)"
|
||||||
SERVICE=$1
|
PHONE=$1
|
||||||
YESNO=$2
|
SERVICE=$2
|
||||||
PARAMS=$3
|
|
||||||
|
sms_INIT_ACCOUNT "$PHONE"
|
||||||
|
|
||||||
case "$SERVICE" in
|
case "$SERVICE" in
|
||||||
|
ON)
|
||||||
|
log "Abonnement Kalkun"
|
||||||
|
add_contact $PHONE $MEMBER && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_";
|
||||||
|
sms_SEND "$PHONE" "$MEMBER votre inscription annuaire est active"
|
||||||
|
;;
|
||||||
|
OFF)
|
||||||
|
log "Retrait Kalkun"
|
||||||
|
rm_contact $PHONE $MEMBER && log "${c_green}Contact has been deleted from database$c_" || log "${c_red}Contact can't be deleted database$c_";
|
||||||
|
sms_SEND "$PHONE" "$MEMBER retrait annuaire prise en compte..."
|
||||||
|
;;
|
||||||
|
|
||||||
MARCHE)
|
MARCHE)
|
||||||
log "Avertissement G1 marchés"
|
log "Avertissement G1 marchés"
|
||||||
# PARAMS could be "$distance" to Member GeoPoint...
|
# PARAMS could be "$distance" to Member GeoPoint...
|
||||||
|
|
|
@ -11,23 +11,20 @@ log "X sms_AIDE.sh ($1=phone)"
|
||||||
sms_INIT_ACCOUNT "$1" "NOSMS"
|
sms_INIT_ACCOUNT "$1" "NOSMS"
|
||||||
|
|
||||||
MESS="[Aide]
|
MESS="[Aide]
|
||||||
N Id-M (Relier au portefeuille Id-M)
|
N Pseudo (membre ou nom de portefeuille) : Création portefeuille
|
||||||
U G1/DU/LOVE (UNIT)
|
U G1/DU/LOVE : Unité
|
||||||
S (Solde)
|
S : Solde
|
||||||
P 06nnnnnnnn 300 (Envoyer 300 UNIT à 06nnnnnnnn)"
|
P 06nnnnnnnn 300 : Payer 300 à 06nnnnnnnn"
|
||||||
# Send response SMS
|
# Send response SMS
|
||||||
sms_SEND "$1" "$MESS"
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
MESS="EMAIL moi@email.tld (Recevoir vos commandes par email)
|
MESS="EMAIL moi@email : Indiquer son email
|
||||||
TAG 10 5 (Créer 5 G1Tag de 10 G1)
|
VIR 50 Pseudo : Virer 50 à Pseudo (membre ou Portefeuille SMS)"
|
||||||
VIR 50 Idw (Virer 50 UNIT vers Idw)"
|
|
||||||
sms_SEND "$1" "$MESS"
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
MESS="REC (Pour un payement récurrent)
|
MESS="REC 50 Dest S 4 : Virer 50 à Dest pendant 4 Semaines (J/S/M/A)
|
||||||
D (Détail de votre compte)
|
BILL n : Recevoir 6 G1Billets remplis de n LOVE par email!
|
||||||
A votre service.
|
https://g1sms.fr - $ADMINPSEUDO ($ADMINPHONE)"
|
||||||
$ADMINPSEUDO / G1sms+ / $ADMINPHONE
|
|
||||||
https://g1sms.fr"
|
|
||||||
sms_SEND "$1" "$MESS"
|
sms_SEND "$1" "$MESS"
|
||||||
|
|
||||||
log "END sms_AIDE.sh"
|
log "END sms_AIDE.sh"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# Create and print 6 G1Billets de nn LOVE
|
# Create and print 6 G1Billets de nn LOVE
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
log "X sms_BILLET.sh ($1=phone, $2=VALbillet)"
|
log "__SUB:sms_BILLET.sh: ($1=phone, $2=VALbillet)"
|
||||||
|
|
||||||
phone="$1"
|
phone="$1"
|
||||||
VALbillet="$2"
|
VALbillet="$2"
|
||||||
|
@ -20,7 +20,7 @@ sms_INIT_ACCOUNT "$phone" "NOSMS"
|
||||||
# FIXED LOVE UNIT (6 month maximum validity)
|
# FIXED LOVE UNIT (6 month maximum validity)
|
||||||
UNIT="LOVE"
|
UNIT="LOVE"
|
||||||
|
|
||||||
log "MEMBER? $PHONE => $MEMBER"
|
log "__SUB:sms_BILLET.sh: MEMBER? $PHONE => $MEMBER"
|
||||||
|
|
||||||
if [[ $UNKNOWN == "unknown" || "$MEMBER" == "" ]]; then
|
if [[ $UNKNOWN == "unknown" || "$MEMBER" == "" ]]; then
|
||||||
sms_ERROR "$phone" "Porte-monnaie non identifié.
|
sms_ERROR "$phone" "Porte-monnaie non identifié.
|
||||||
|
@ -54,90 +54,113 @@ 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 - 21")
|
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT - $BILLCOM")
|
||||||
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
|
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
|
||||||
log "TEST : $VIR < $MIN ? $testmin"
|
log "__SUB:sms_BILLET.sh: TEST : $VIR < $MIN ? $testmin"
|
||||||
|
|
||||||
# silkaj NODE CHANGE !!!
|
# silkaj NODE CHANGE !!!
|
||||||
SILKAJNODE=$(./shell/checknodes.sh)
|
#SILKAJNODE=$(./shell/checknodes.sh)
|
||||||
log "NEW SILKAJ NODE: $SILKAJNODE"
|
#log "NEW SILKAJ NODE: $SILKAJNODE"
|
||||||
|
|
||||||
if [[ "$testmin" -eq "1" ]]
|
if [[ "$testmin" -eq "1" ]]
|
||||||
then
|
then
|
||||||
|
# Clean MEMBER directory
|
||||||
|
rm -f ./billets/MEMBERS/$MEMBER/*.jpg
|
||||||
boucle=0;
|
boucle=0;
|
||||||
while [ $boucle -lt $NBbillets ]
|
while [ $boucle -lt $NBbillets ]
|
||||||
do
|
do
|
||||||
# Creation du numéro de billet
|
# Creation du numéro de billet
|
||||||
NUMBER=$(./shell/diceware.sh 4 | xargs)
|
NUMBER=$(./shell/diceware.sh 2 | xargs)
|
||||||
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
||||||
|
|
||||||
# Cas d'un billet existant
|
# Cas d'un billet existant
|
||||||
while [ -d "./billets/$bpath" ]
|
while [ -d "./billets/$bpath" ]
|
||||||
do
|
do
|
||||||
NUMBER=$(./shell/diceware.sh 4 | xargs)
|
NUMBER=$(./shell/diceware.sh 2 | xargs)
|
||||||
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
||||||
done
|
done
|
||||||
|
|
||||||
SECRET=$(./shell/diceware.sh 3 | xargs)
|
SECRET=$(./shell/diceware.sh 4 | xargs)
|
||||||
SALT=$(./shell/diceware.sh 3 | xargs)
|
|
||||||
|
|
||||||
boucle=$(bc -l <<< "$boucle + 1")
|
boucle=$(bc -l <<< "$boucle + 1")
|
||||||
|
|
||||||
log "->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT"
|
log "__SUB:sms_BILLET.sh: ->BILLET:$PHONE:$NUMBER:$VALbillet:$UNIT"
|
||||||
# CREATE "NUMBER SECRET SALT" ACCOUNT for G1 transfert
|
# CREATE "NUMBER SECRET" ACCOUNT for G1 transfert
|
||||||
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
|
TRANSAC=$(bc -l <<< "scale=2; $VIR / $NBbillets")
|
||||||
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET $SALT")
|
BILLETPUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$NUMBER" -password="$SECRET")
|
||||||
log_history $PHONE "BILLET, $TRANSAC, $BILLETPUBKEY"
|
# COPY authfile for Usage in 6 month...
|
||||||
|
log "__SUB:sms_BILLET.sh: authfile KEY : ./billets/$bpath/note.authfile.GPGPASS.gpg"
|
||||||
|
mkdir -p "./billets/$bpath"
|
||||||
|
echo "${GPGPASS}" | gpg -q --output "./billets/$bpath/note.authfile.GPGPASS.gpg" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "./authfile"
|
||||||
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./authfile" -o "./billets/$bpath/note.authfile.$NODE_UIDNA.crypt"
|
||||||
|
rm -f "./authfile"
|
||||||
|
|
||||||
|
log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY"
|
||||||
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="THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:BILLET" -y)
|
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -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
|
||||||
mkdir -p "./billets/$bpath"
|
|
||||||
# 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 "$MEMBER" > "./billets/$bpath/note.creator"
|
echo "$MEMBER" > "./billets/$bpath/note.creator"
|
||||||
|
echo "$MEMRIB" > "./billets/$bpath/note.memrib"
|
||||||
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.value"
|
echo "$TRANSAC" > "./billets/$bpath/note.g1"
|
||||||
echo "$UNIT" > "./billets/$bpath/note.unit"
|
|
||||||
echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey"
|
echo "$BILLETPUBKEY" > "./billets/$bpath/note.pubkey"
|
||||||
log "Remplissage: $TRANSAC G1... $BILLETPUBKEY = $PAY"
|
log "Remplissage: $TRANSAC G1... $BILLETPUBKEY = $PAY"
|
||||||
|
|
||||||
# CREATION FICHIER IMAGE BILLET
|
# CREATION FICHIER IMAGE BILLET
|
||||||
$(./shell/sms_BILLET_MAKE.sh "$NUMBER" "$SECRET" "$VALbillet" "$UNIT" "$DUFACTOR" "$BILLETPUBKEY" "$MEMBER" "$TRANSAC")
|
$(./shell/sms_BILLET_MAKE.sh "$NUMBER" "$SECRET" "$VALbillet" "$UNIT" "$TRANSAC" "$BILLETPUBKEY" "$MEMBER" "$TRANSAC" "$PHONE")
|
||||||
log "./shell/sms_BILLET_MAKE.sh \"$NUMBER\" \"$SECRET\" \"$VALbillet\" \"$UNIT\" \"$DUFACTOR\" \"$BILLETPUBKEY\" \"$MEMBER\" \"$TRANSAC\""
|
log "./shell/sms_BILLET_MAKE.sh \"$NUMBER\" \"$SECRET\" \"$VALbillet\" \"$UNIT\" \"$TRANSAC\" \"$BILLETPUBKEY\" \"$MEMBER\" \"$TRANSAC\" \"$PHONE\""
|
||||||
|
|
||||||
# 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 $SALT" --amount="0.05" --output="$MEMRIB" --comment="THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:BILLET:$VALbillet:$UNIT:$NUMBER" -y)
|
# PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$NUMBER" -password="$SECRET" --amount="0.05" --output="$MEMRIB" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:BILLET:$VALbillet:$UNIT:$NUMBER" -y)
|
||||||
else
|
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
|
||||||
|
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....."
|
||||||
|
|
||||||
|
log "__SUB:sms_BILLET.sh: ERROR SILKAJ $(cat ./silkaj/src/constants.py)"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# + G1SMS Commission
|
# + G1SMS Commission
|
||||||
sleep 2
|
sleep 2
|
||||||
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$MASTERPUB" --comment="[G1SMS] G1billet Commission" -y)
|
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y)
|
||||||
|
|
||||||
# IMPRIMER LES BILLETS! Brancher votre imprimante et configurer cups avant ;)
|
# POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;)
|
||||||
num=$(date +%Y%m%d)
|
num=$(date +%Y%m%d)
|
||||||
log "PRINT $num $MEMBER"
|
log "__SUB:sms_BILLET.sh: PRINT $num $MEMBER"
|
||||||
montage ./billets/MEMBERS/$MEMBER/*.jpg -tile 2x3 -geometry 964x459 /tmp/$PHONE_Bills_$bpath.pdf
|
montage ./billets/MEMBERS/$MEMBER/*.jpg -tile 2x3 -geometry 964x459 /tmp/$PHONE_Bills_$bpath.pdf && rm -f ./billets/MEMBERS/$MEMBER/*.jpg && log "__SUB:sms_BILLET.sh: PDF made /tmp/$PHONE_Bills_$bpath.pdf"
|
||||||
# lp /tmp/$PHONE_Bills_$bpath.pdf
|
cd /tmp && zip $PHONE_Bills_$bpath.zip $PHONE_Bills_$bpath.pdf && log "__SUB:sms_BILLET.sh: Zip DONE :: /tmp$PHONE_Bills_$bpath.zip !!" && cd -
|
||||||
cp /tmp/$PHONE_Bills_$bpath.pdf ./billets/MEMBERS/$MEMBER/
|
# rm -f /tmp/$PHONE_Bills_$bpath.pdf
|
||||||
zip ./_Bill_$MEMBER_$num.zip ./billets/MEMBERS/$MEMBER/*.jpg && rm -f ./billets/MEMBERS/$MEMBER/*.jpg
|
|
||||||
|
|
||||||
# SEND EMAIL
|
# SEND EMAIL ZIP attached
|
||||||
# Détruit ce mail et le pdf après impression et fabrication des billets au code caché.
|
echo "Commande #$NANODATE/$bpath
|
||||||
# Créer la monnaie implique une grande responsabilité!
|
>> Planche de 6 G1Billets : $VALbillet LOVE <<
|
||||||
|
Envoyez-nous vos remarques...
|
||||||
|
|
||||||
|
https://g1sms.fr" > /tmp/message_body.txt
|
||||||
|
|
||||||
|
mpack -s "[G1sms+]_G1Billets ($bpath) A IMPRIMER et détruire cet email..." -d /tmp/message_body.txt /tmp/$PHONE_Bills_$bpath.zip $MAIL && log "__SUB:sms_BILLET.sh: EMAIL sent....."
|
||||||
|
|
||||||
|
log "__SUB:sms_BILLET.sh: G1Billets $PHONE_Bills_$bpath.pdf envoyé par email à $MEMBER : $MAIL "
|
||||||
mess="[G1SMS]
|
mess="[G1SMS]
|
||||||
$NBbillets billet(s) de $VALbillet $UNIT ($TRANSAC G1) créé(s).
|
$NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) créé(s).
|
||||||
Contactez $ADMINPSEUDO au $ADMINPHONE pour les recevoir...
|
Envoyés vers $MAIL, vérifiez vos SPAM...
|
||||||
http://g1sms.fr/g1sms/aide"
|
Support: $ADMINPSEUDO ($ADMINPHONE)
|
||||||
|
"
|
||||||
|
|
||||||
sms_SEND "$phone" "$mess"
|
sms_SEND "$phone" "$mess"
|
||||||
|
# ADMIN ALERT SMS + TODO Add ADMINEMAIL parameter in "install.sh"
|
||||||
|
sms_SEND "$ADMINPHONE" "$MEMBER vient de créer $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1): $MAIL"
|
||||||
|
cat ./email.txt | sed s/EMAIL/frenault@linkeo.com/g | sed s/SUBJECT/Creation_G1Billets/g | sed s/MESSAGE/"$MEMBER ($PHONE) vient de creer $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) vers $MAIL"/g | ssmtp "frenault@linkeo.com"
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Amount too High, solde insuffisant
|
# Amount too High, solde insuffisant
|
||||||
|
@ -151,7 +174,7 @@ Insuffisant pour créer $NBbillets billet(s) de $VALbillet $UNIT
|
||||||
https://g1.duniter.fr/api/#/v1/payment/$PUBKEY?amount=$VIR"
|
https://g1.duniter.fr/api/#/v1/payment/$PUBKEY?amount=$VIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "END sms_BILLET.sh"
|
log "__SUB:sms_BILLET.sh: END sms_BILLET.sh"
|
||||||
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -7,8 +7,8 @@ source ./shell/functions.sh
|
||||||
log "X sms_BILLETCHK.sh $0"
|
log "X sms_BILLETCHK.sh $0"
|
||||||
|
|
||||||
PHONE="$1"
|
PHONE="$1"
|
||||||
CODE="$2 $3 $4 $5"
|
CODE="$2 $3"
|
||||||
SEC="$6 $7 $8"
|
SEC="$4 $5 $6 $7"
|
||||||
|
|
||||||
# Construct billet path
|
# Construct billet path
|
||||||
bpath=$(echo "$CODE" | sed 's/ /_/g')
|
bpath=$(echo "$CODE" | sed 's/ /_/g')
|
||||||
|
@ -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 amount "$BILLETPUBKEY")
|
AMOUNTG1=$(./silkaj/silkaj -p g1.presles.fr:443 amount "$BILLETPUBKEY")
|
||||||
log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY"
|
log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY"
|
||||||
|
|
||||||
# NO GOOD SECRET
|
# NO GOOD SECRET
|
||||||
|
@ -41,24 +41,22 @@ https://www.g1sms.fr/contact"
|
||||||
# Account creation
|
# Account creation
|
||||||
sms_INIT_ACCOUNT "$PHONE"
|
sms_INIT_ACCOUNT "$PHONE"
|
||||||
fi
|
fi
|
||||||
log "./silkaj/silkaj transaction --auth-scrypt -salt=\"$CODE\" -password=\"$SEC $SALT\" --amount=\"$AMOUNTG1\" --output=\"$PUBKEY\" --comment=\"THIRD_PARTY_MANAGER:$MASTERPUB:G1SMS:ENCAISSEMENT:$CODE\" -y"
|
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"
|
||||||
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC $SALT" --amount="$AMOUNTG1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$MASTERPUB: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)
|
||||||
|
|
||||||
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
|
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
|
||||||
# DESTROY BILLET
|
# DESTROY BILLET
|
||||||
rm -f ./billets/$bpath/note.*
|
rm -Rf ./billets/$bpath
|
||||||
rmdir ./billets/$bpath
|
|
||||||
# DESTROY PUBLIC CACHE in /tmp
|
# DESTROY PUBLIC CACHE in /tmp
|
||||||
if [ -d "/tmp/billets_valides/$bpath" ]; then
|
if [ -d "/tmp/billets_valides/$bpath" ]; then
|
||||||
rm -f /tmp/billets_valides/$bpath/*
|
rm -Rf /tmp/billets_valides/$bpath
|
||||||
rmdir /tmp/billets_valides/$bpath
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SOLDE=$(./silkaj/silkaj amount "$PUBKEY")
|
SOLDE=$(./silkaj/silkaj amount "$PUBKEY")
|
||||||
|
|
||||||
mess="[G1SMS]
|
mess="[G1SMS]
|
||||||
ENCAISSEMENT de $VALbillet $UNIT ($AMOUNTG1 G1)
|
ENCAISSEMENT de $VALbillet $UNIT ($AMOUNTG1 G1)
|
||||||
ds le porte-monnaie $PHONE ($PUBKEY)
|
dans portefeuille $UIDNA ($PHONE)
|
||||||
OK!
|
OK!
|
||||||
Solde: $SOLDE G1"
|
Solde: $SOLDE G1"
|
||||||
sms_SEND "$PHONE" "$mess"
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
@ -66,7 +64,7 @@ Solde: $SOLDE G1"
|
||||||
log "=> $PUBKEY"
|
log "=> $PUBKEY"
|
||||||
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath, $PUBKEY"
|
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath, $PUBKEY"
|
||||||
else
|
else
|
||||||
sms_ERROR "$PHONE" "Erreur! Transaction Impossible... Réessayez plus tard ou contactez $ADMINPSEUDO : $ADMINPHONE"
|
sms_ERROR "$PHONE" "Erreur! Transaction Impossible! Valeur du G1Billet $AMOUNTG1 G1. Contactez $ADMINPSEUDO : $ADMINPHONE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
@ -17,11 +17,12 @@ NUMERO="$1"
|
||||||
SECRET="$2"
|
SECRET="$2"
|
||||||
MONTANT="$3"
|
MONTANT="$3"
|
||||||
UNIT="$4"
|
UNIT="$4"
|
||||||
DUFACTOR="$5"
|
JUNE="$5"
|
||||||
NOTERIB="$6"
|
NOTERIB="$6"
|
||||||
MEMBER="$7"
|
MEMBER="$7"
|
||||||
TRANSAC="$8"
|
TRANSAC="$8"
|
||||||
log "X ./shell/sms_BILLET_MAKE.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$8\""
|
PHONE="$9"
|
||||||
|
log "X sudo ./shell/sms_BILLET_MAKE.sh \"$1\" \"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$8\""
|
||||||
|
|
||||||
if [[ "$NOTERIB" == "" || "$MEMBER" == "" ]]
|
if [[ "$NOTERIB" == "" || "$MEMBER" == "" ]]
|
||||||
then
|
then
|
||||||
|
@ -43,17 +44,24 @@ fi
|
||||||
valid="0${valid:0:2}"
|
valid="0${valid:0:2}"
|
||||||
# ADD VALIDITY to convert: -pointsize 20 -draw 'text 380,410 "'"A encaisser avant le 01/$valid/$year"'"' \
|
# ADD VALIDITY to convert: -pointsize 20 -draw 'text 380,410 "'"A encaisser avant le 01/$valid/$year"'"' \
|
||||||
|
|
||||||
# Add G1sms logo (250px)
|
# ADD Avatar on G1 Logo SouthEast
|
||||||
composite -compose Over -gravity SouthWest -geometry +50+50 "./shell/G1sms.png" "./shell/Oeuro.jpg" "/tmp/$NUMERO.jpg"
|
if [[ $(file "./wallets/$PHONE/$PHONE.avatar.png" | grep 'PNG') ]]; then
|
||||||
|
composite -compose Over -gravity East -geometry +15+0 -dissolve 33% "./wallets/$PHONE/$PHONE.avatar.png" "./shell/Oeuro.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
composite -compose Over -gravity West -geometry +15+0 -dissolve 33% "./wallets/$PHONE/$PHONE.avatar.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
else
|
||||||
|
composite -compose Over -gravity East -geometry +15+0 -dissolve 33% "./shell/G1Anar.png" "./shell/Oeuro.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
composite -compose Over -gravity West -geometry +15+0 -dissolve 33% "./shell/G1Anar.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add G1Billet_LOVE.png logo (250px)
|
||||||
|
composite -compose Over -gravity SouthWest -geometry +50+50 -dissolve 70% "./shell/G1Billet_LOVE.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
# Prepare BILLET qrcode verification URL
|
# Prepare BILLET qrcode verification URL
|
||||||
#qrencode "$NOTERIB" -o "/tmp/$NUMERO_NOTERIB.png"
|
qrencode -s 3 -o "/tmp/$NUMERO_NOTERIB.png" "$NOTERIB"
|
||||||
REQ=$(echo $NUMERO | sed 's/ /_/g')
|
|
||||||
qrencode "https://www.g1sms.fr/$ADMINPSEUDO/check.php?code=$REQ" -o "/tmp/$NUMERO_NOTERIB.png"
|
|
||||||
|
|
||||||
# BILL PUBKEY => Someone can Add amount to it !!!
|
# BILL PUBKEY means Someone can Add amount to it !!!
|
||||||
# Add verification QRCode
|
# Add verification QRCode
|
||||||
composite -compose Over -gravity NorthEast -geometry +40+40 "/tmp/$NUMERO_NOTERIB.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
composite -compose Over -gravity NorthEast -geometry +50+25 "/tmp/$NUMERO_NOTERIB.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
# Add June logo
|
# Add June logo
|
||||||
case "$MONTANT" in
|
case "$MONTANT" in
|
||||||
|
@ -82,7 +90,7 @@ case "$MONTANT" in
|
||||||
cp "./shell/g1.png" "/tmp/g1.png"
|
cp "./shell/g1.png" "/tmp/g1.png"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
composite -compose Over -gravity SouthEast -geometry +20+20 "/tmp/g1.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
composite -compose Over -gravity SouthEast -geometry +20+20 -dissolve 90% "/tmp/g1.png" "/tmp/$NUMERO.jpg" "/tmp/$NUMERO.jpg"
|
||||||
|
|
||||||
DUPART=$(bc -l <<< "scale=2; $MONTANT / 100")
|
DUPART=$(bc -l <<< "scale=2; $MONTANT / 100")
|
||||||
# ADD 0 to <1 DUPART
|
# ADD 0 to <1 DUPART
|
||||||
|
@ -90,16 +98,17 @@ testdu=$( echo "${DUPART} < 1" | bc -l )
|
||||||
if [[ "$testdu" -eq "1" ]]; then
|
if [[ "$testdu" -eq "1" ]]; then
|
||||||
DUPART="0${DUPART}"
|
DUPART="0${DUPART}"
|
||||||
fi
|
fi
|
||||||
#SECRET=$(echo $SECRET | sed 's/ /\n/g')
|
|
||||||
|
SIMPLEPHONE=$(echo $MASTERPHONE | sed 's/\+33/0/g')
|
||||||
|
|
||||||
convert -font 'Liberation-Sans' \
|
convert -font 'Liberation-Sans' \
|
||||||
-pointsize 120 -fill black -draw 'text 200,220 "'"$DUPART DU"'"' \
|
-pointsize 120 -fill black -draw 'text 200,220 "'"$DUPART DU"'"' \
|
||||||
-pointsize 45 -draw 'text 550,270 "'"$MONTANT $UNIT"'"' \
|
-pointsize 45 -draw 'text 550,270 "'"$MONTANT $UNIT"'"' \
|
||||||
-pointsize 35 -draw 'text 50,60 "'"[G1sms] 06 66 80 57 20"'"' \
|
-pointsize 35 -draw 'text 50,60 "'"https://g1sms.fr _ G1Billet _ $JUNE G1"'"' \
|
||||||
-pointsize 30 -draw 'text 60,100 "'"CHK $NUMERO"'"' \
|
-pointsize 30 -draw 'text 60,100 "'"Identifiant: $NUMERO"'"' \
|
||||||
-pointsize 22 -fill black -draw 'text 520,340 "'"$SECRET"'"' \
|
-pointsize 22 -fill black -draw 'text 380,340 "'"Code Secret: $SECRET"'"' \
|
||||||
-pointsize 22 -fill black -draw 'text 400,410 "'"Encaisser avant le 01/$valid/$year"'"' \
|
-pointsize 22 -fill black -draw 'text 260,408 "'"Porte Monnaie Libre!! A utiliser avant le 01/$valid/$year"'"' \
|
||||||
-pointsize 20 -draw 'text 50,444 "'"Envoyer par sms, CHK $NUMERO + les mots découverts sous la zone à gratter"'"' \
|
-pointsize 20 -draw 'text 15,442 "'"Utilisation: CHK $NUMERO (+ code secret) par SMS au $SIMPLEPHONE ou https://cesium.app"'"' \
|
||||||
"/tmp/$NUMERO.jpg" "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg"
|
"/tmp/$NUMERO.jpg" "/tmp/BILL.$year.$valid.$NUMERO.$MONTANT.$UNIT.jpg"
|
||||||
|
|
||||||
# Payable par SMS en envoyant les codes grattant la case comportant le SECRET
|
# Payable par SMS en envoyant les codes grattant la case comportant le SECRET
|
||||||
|
|
|
@ -47,10 +47,11 @@ log "Solde = $AMOUNTG1 ($UNIT)"
|
||||||
if [ "$2" != "NOSMS" ]; then
|
if [ "$2" != "NOSMS" ]; then
|
||||||
if [[ "$AMOUNT" != "" ]]; then
|
if [[ "$AMOUNT" != "" ]]; then
|
||||||
mess="[G1sms+]
|
mess="[G1sms+]
|
||||||
ID: $UIDNA <=> $MEMBER
|
ID: $UIDNA
|
||||||
$AMOUNT $UNIT ($AMOUNTG1 G1)
|
$AMOUNT $UNIT ($AMOUNTG1 G1)
|
||||||
|
=> $MEMBER
|
||||||
Recharger avec https://cesium.app"
|
$MEMRIB
|
||||||
|
https://cesium.app"
|
||||||
# Send response SMS
|
# Send response SMS
|
||||||
sms_SEND "$PHONE" "$mess"
|
sms_SEND "$PHONE" "$mess"
|
||||||
sms_SEND "$PHONE" "$PUBKEY"
|
sms_SEND "$PHONE" "$PUBKEY"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
log "__SUB:sms_DESTROY.sh: START ($1=phone, $2=uid)"
|
log "${c_yellow}__SUB:sms_DESTROY.sh: START ($1=phone, $2=uid)$c_"
|
||||||
|
|
||||||
PHONE="$1"
|
PHONE="$1"
|
||||||
MEMBERUID="$2"
|
MEMBERUID="$2"
|
||||||
|
@ -22,7 +22,7 @@ if [[ -f "./wallets/$PHONE/VIREMENTS" ]]; then
|
||||||
sms_ERROR "$PHONE" "Votre portefeuille comporte des virements non réglés... FERMETURE IMPOSSIBLE!"
|
sms_ERROR "$PHONE" "Votre portefeuille comporte des virements non réglés... FERMETURE IMPOSSIBLE!"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
log "__SUB:sms_DESTROY.sh: VIREMENT $next OK "
|
log "__SUB:sms_DESTROY.sh: VIREMENT $next ${c_green}OK$c_"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -31,35 +31,19 @@ fi
|
||||||
sms_INIT_ACCOUNT "$PHONE"
|
sms_INIT_ACCOUNT "$PHONE"
|
||||||
if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]]; then
|
if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]]; then
|
||||||
# OK THAT GUYS KNOWS something (TODO Secure better with double authentification, with email or second phone number...)
|
# OK THAT GUYS KNOWS something (TODO Secure better with double authentification, with email or second phone number...)
|
||||||
# IF no Dest PubKey (no member) or DON, then MASTERPUB is collecting LOVE money.
|
# IF no Dest PubKey (no member) or DON, then NODE_G1PUBKEY is collecting LOVE money.
|
||||||
if [[ $MEMRIB == "" || "$MEMBERUID" == "DON" ]]; then MEMBER=$ADMINPSEUDO; MEMRIB=$MASTERPUB; fi
|
if [[ $MEMRIB == "" || "$MEMBERUID" == "DON" ]]; then MEMBER=$ADMINPSEUDO; MEMRIB=$NODE_G1PUBKEY; fi
|
||||||
|
|
||||||
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="$PHONE" -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="$NODEG1PUB" --comment="[G1sms+] Wallet DESTROY Send $LIMIT To NODE" -y)
|
back=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -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
|
||||||
if [[ "$PHONE" != "" ]]; then
|
if [[ "$PHONE" != "" ]]; then
|
||||||
rm -Rf ./wallets/$PHONE;
|
# SEND SMS BEFORE DELETE FOLDER
|
||||||
rm -Rf ./wallets_swarm/$PHONE;
|
|
||||||
cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1)
|
|
||||||
move_g1cents "$PHONE" "$MEMRIB" "$cents"
|
|
||||||
cents=$(echo $(bc -l <<< "scale=0; $LIMIT * 100") | cut -d '.' -f 1)
|
|
||||||
move_g1cents "$PHONE" "$NODEG1PUB" "$cents"
|
|
||||||
I=$(ipfs_node_wallets_add)
|
|
||||||
log "__SUB:sms_DESTROY.sh: WALLET DESTROYED : $PHONE / $UIDNA / $MEMBER : OK"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
new=$(./shell/checknodes.sh "BAN")
|
|
||||||
sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
|
|
||||||
log "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
mess="[G1sms+] $PAY
|
mess="[G1sms+] $PAY
|
||||||
Portefeuille détruit!
|
Portefeuille détruit!
|
||||||
Viré vers $MEMBER
|
Viré vers $MEMBER
|
||||||
|
@ -68,8 +52,27 @@ $MEMRIB
|
||||||
Merci, à bientôt.
|
Merci, à bientôt.
|
||||||
$ADMINPSEUDO @ $NODEUIDNA
|
$ADMINPSEUDO @ $NODEUIDNA
|
||||||
$back"
|
$back"
|
||||||
|
|
||||||
sms_SEND "$PHONE" "$mess"
|
sms_SEND "$PHONE" "$mess"
|
||||||
|
|
||||||
log "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
rm -Rf ./wallets/$PHONE;
|
||||||
|
rm -Rf ./wallets_swarm/$PHONE;
|
||||||
|
cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1)
|
||||||
|
move_g1cents "$PHONE" "$MEMRIB" "$cents"
|
||||||
|
cents=$(echo $(bc -l <<< "scale=0; $LIMIT * 100") | cut -d '.' -f 1)
|
||||||
|
move_g1cents "$PHONE" "$NODEPUB" "$cents"
|
||||||
|
I=$(ipfs_node_wallets_add)
|
||||||
|
log "__SUB:sms_DESTROY.sh: WALLET DESTROYED : $PHONE / $UIDNA / $MEMBER : ${c_green}OK$c_"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
new=$(./shell/checknodes.sh "BAN")
|
||||||
|
sms_ERROR "$PHONE" "Problème de payement avec silkaj (changement de serveur $new): $PAY";
|
||||||
|
log "${c_red}__SUB:sms_DESTROY.sh: END WITH ERRORS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~$c_"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove contact from database
|
||||||
|
rm_contact $PHONE $MEMBERUID && log "${c_green}Contact has been deleted from database$c_" || log "${c_red}Contact can't be deleted database$c_"
|
||||||
|
|
||||||
|
log "${c_yellow}__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~$c_"
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -4,8 +4,13 @@
|
||||||
# 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/)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
# sudo apt install ssmtp mpack
|
||||||
|
# Configure in /etc/ssmtp
|
||||||
|
# Send email with file attachement: mpack -s "Logo G1Tag" /home/pi/G1sms+/G1Tag.png dest@email.ext
|
||||||
|
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
|
|
||||||
log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
|
log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
|
||||||
|
|
||||||
phone="$1"
|
phone="$1"
|
||||||
|
@ -23,6 +28,8 @@ fi
|
||||||
|
|
||||||
if [[ "$mail" != "" ]]; then
|
if [[ "$mail" != "" ]]; then
|
||||||
echo "$mail" > "$MAILFILE"
|
echo "$mail" > "$MAILFILE"
|
||||||
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt"
|
||||||
|
echo "" > "$MAILFILE"
|
||||||
log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
|
log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
|
||||||
ipfs_node_wallets_add
|
ipfs_node_wallets_add
|
||||||
else
|
else
|
||||||
|
@ -30,16 +37,18 @@ 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\nLe detenteur du porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nVous y recevrez nos prochains envois ...\n\n\nA bientot <3\n$ADMINPSEUDO - ($MASTERPHONE) Partenaire G1sms+"
|
MESSAGE="Bonjour $MEMBER\n\nVotre porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nPour commander vos G1Billets, envoyez par SMS à $MASTERPHONE :\nBILL 10/20/50/100/200/500/1000\n\n\nA bientot <3\n$ADMINPSEUDO ($ADMINPHONE)"
|
||||||
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
|
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"
|
||||||
|
|
||||||
mess="[G1sms+]
|
mess="[G1sms+]
|
||||||
$MEMBER
|
$MEMBER
|
||||||
Votre email est : $mail
|
Votre email est : $mail
|
||||||
Mettez le à jour, quand cela est nécessaire..."
|
Mettez le à jour, si cela est nécessaire..."
|
||||||
|
|
||||||
sms_SEND "$phone" "$mess"
|
sms_SEND "$phone" "$mess"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
################################################################################
|
################################################################################
|
||||||
# Author: Fred (support@qo-op.com)
|
# Author: Fred (support@qo-op.com)
|
||||||
# Version: 0.1
|
# Version: 0.2020
|
||||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
# == G1tag ==
|
# == G1tag ==
|
||||||
|
@ -10,9 +10,12 @@
|
||||||
# BJ: WRITE G1Tag
|
# BJ: WRITE G1Tag
|
||||||
# WRITE ACCESS ONLY for B possessor and NODE G1Tag Creator
|
# WRITE ACCESS ONLY for B possessor and NODE G1Tag Creator
|
||||||
# TODO: MAKE http API for G1Tag accessible through local ipfs gateway !!!!
|
# TODO: MAKE http API for G1Tag accessible through local ipfs gateway !!!!
|
||||||
|
# https://github.com/typicode/lowdb USE json and ipfs DAG??!
|
||||||
|
#
|
||||||
# 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
|
||||||
|
@ -46,19 +49,12 @@ 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 # AMOUNT was changed by sms_INIT_ACCOUNT call !!
|
AMOUNT=$2 # BE CAREFULL AMOUNT was changed by 1st sms_INIT_ACCOUNT!!
|
||||||
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
|
if [[ "$AMOUNT" == "" ]]; then AMOUNT=0; fi
|
||||||
if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then
|
if [[ ! $PASSENGER && "$NUMBER" != "" ]]; then
|
||||||
# MULTI TAG NUMBER ($NUMBER = How many tags to print (with different R but same B)
|
# MULTI TAG NUMBER ($NUMBER = How many tags to print)
|
||||||
AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER")
|
AMOUNT=$(bc -l <<< "$AMOUNT * $NUMBER")
|
||||||
else
|
else
|
||||||
NUMBER=1
|
NUMBER=1
|
||||||
|
@ -71,7 +67,7 @@ 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} G1! Rechargez avec https://cesium.app "
|
sms_SEND "$PHONE" "Le solde de votre Porte-monnaie est insuffisant. Minimum requis = ${CHARGE} + ${PERCENT} (+ ${LIMIT}) G1! Rechargez avec https://cesium.app"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -80,7 +76,7 @@ if [[ ! $PASSENGER && ! $G1DAB ]]; then
|
||||||
if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then
|
if [[ -f ./wallets/$PHONE/ipfsid.G1TAGNODE ]]; then
|
||||||
DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE)
|
DABnode=$(cat ./wallets/$PHONE/ipfsid.G1TAGNODE)
|
||||||
if [[ "$DABnode" == "$IPFSNODEID" ]]; then
|
if [[ "$DABnode" == "$IPFSNODEID" ]]; then
|
||||||
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag non détectée!! Choisissez un autre NODE G1Dab... $spot"
|
sms_ERROR "$PHONE" "IMPRIMANTE G1Tag sur $DABnode non détectée!! Choisissez un autre G1Dab..."
|
||||||
log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!"
|
log "__SUB:sms_G1TAG.sh: IMPRIMANTE G1Tag non détectée!!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -98,64 +94,72 @@ 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 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$ML" --output="$MASTERPUB" --comment="[G1sms+] ACHAT $3 G1Tag(s) - $2 $UNIT" -y)
|
PAY=$(./shell/timeout.sh -t 29 ./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$ML" --output="$NODE_G1PUBKEY" --comment="[G1sms+] ACHAT $3 G1Tag(s) - $2 $UNIT" -y)
|
||||||
if [[ "$PAY" == "" || "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
|
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
|
||||||
cents=$(echo $(bc -l <<< "scale=0; $ML * 100") | cut -d '.' -f 1)
|
cents=$(echo $(bc -l <<< "scale=0; $ML * 100") | cut -d '.' -f 1)
|
||||||
move_g1cents "$PHONE" "$MASTERPUB" "$cents"
|
move_g1cents "$PHONE" "$NODE_G1PUBKEY" "$cents"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
log "__SUB:sms_G1TAG.sh: CREATE $NUMBER x $2 $UNIT G1Tag(s) for $MEMBER ($PHONE) : PAYEMENT $ML G1 to $MASTERPUB: $PAY"
|
log "__SUB:sms_G1TAG.sh: CREATE $NUMBER x $2 $UNIT G1Tag(s) for $MEMBER ($PHONE) : PAYEMENT $ML G1 to $NODE_G1PUBKEY: $PAY"
|
||||||
c=0
|
c=0
|
||||||
while [[ $c -lt $NUMBER ]]; do
|
while [[ $c -lt $NUMBER ]]; do
|
||||||
((c++))
|
((c++))
|
||||||
# Create Unique SWARM G1tag!
|
# Nom du G1Tag imprimé du le QRCode RJ
|
||||||
AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g );
|
AA=$(./shell/diceware.sh 6 | xargs); # Nom = Diceware de 6 mots
|
||||||
while [ -d "./wallets_swarm/TAG/${RR}" ]; do
|
RR=$(echo ${AA} | sed s/\ //g ); # Nom concaténé
|
||||||
AA=$(./shell/diceware.sh 6 | xargs);
|
PR=$(echo ${AA} | cut -d ' ' -f 1 ); # Prénom du G1Tag
|
||||||
RR=$(echo ${AA} | sed s/\ //g );
|
# Create Unique G1tag in all SWARM!
|
||||||
|
while [[ $(ls ./wallets_swarm/.Qm*/TAG/${RR}) ]]; do
|
||||||
|
AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g ); PR=$(echo ${AA} | cut -d ' ' -f 1 );
|
||||||
done
|
done
|
||||||
|
# Clef de chiffrage PGP imprimée sur le QRCode BJ
|
||||||
BB=$(date +%N | sha256sum | base64 | head -c 32) #YjY4MDc3OTVjNmUxN2JhYWVjYmU3MDcy
|
BB=$(date +%N | sha256sum | base64 | head -c 32) #YjY4MDc3OTVjNmUxN2JhYWVjYmU3MDcy
|
||||||
# BB=$(openssl rand -base64 32 | base64) #Yk8yMnVtdzZmendJbHNoK2Q0b0liakRpNHNJUk9UQW5Dd042cFdDODlJTT0K
|
# BB=$(openssl rand -base64 32 | base64) #Yk8yMnVtdzZmendJbHNoK2Q0b0liakRpNHNJUk9UQW5Dd042cFdDODlJTT0K
|
||||||
|
|
||||||
# G1Tag init
|
# 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
|
||||||
TAGNID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
|
TAGNODEID="./TAG/${RR}/TAG_nodeid" # G1sms+ NODE IPFS ID managing that G1Tag
|
||||||
TAGID="./TAG/${RR}/TAG_id" #Nom du TAG
|
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}" ...
|
||||||
TAGBKEY="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B cyphered
|
TAGPUBLISH_B_GPG="./TAG/${RR}/TAG_publishkey.B.gpg" # ipns publish key B PGP cyphered
|
||||||
TAGG1smsWKEY="./TAG/${RR}/TAG_publishkey.$PHONE.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
|
TAGPUBLISH_PHONE_CRYPT="./TAG/${RR}/TAG_publishkey.phone.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
|
||||||
TAGSWARMKEY="./TAG/${RR}/TAG_publishkey.MASTER.crypt" # natools.py crypt with creator G1sms Wallet PUBKEY
|
TAGPUBLISH_NODE_CRYPT="./TAG/${RR}/TAG_publishkey.$NODE_UIDNA.crypt" # natools.py crypt with NODE G1sms Wallet PUBKEY
|
||||||
|
TAGPUBLISH_SWARM_CRYPT="./TAG/${RR}/TAG_publishkey.swarm.crypt" # natools.py crypt with SWARM G1sms Wallet PUBKEY
|
||||||
|
TAGN="./TAG/${RR}/TAG_n" # Tag modification number (0 first)
|
||||||
TAGIPNS="./TAG/${RR}/TAG_ipns" # /ipns/Qm... link to last G1Tag version
|
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"
|
||||||
####################
|
####################
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# IPFS files are created and calculated immutable I
|
# IPFS files are created and calculated immutable I
|
||||||
####################################################
|
####################################################
|
||||||
# A or R is the Human readable G1tag ID (kind of TAG pubkey)
|
# A or R is Human readable G1tag Name
|
||||||
echo "${AA}" > "$TAGID"
|
echo "${AA}" > "$TAGID"
|
||||||
echo "0" > "$TAGN"
|
echo "0" > "$TAGN"
|
||||||
echo "${NANODATE}" > "$TAGDATE"
|
echo "${NANODATE}" > "$TAGDATE"
|
||||||
echo "${IPFSNODEID}" > "$TAGNID"
|
echo "${IPFSNODEID}" > "$TAGNODEID"
|
||||||
echo "${TYPE}" > "$TAGTYPE"
|
echo "${TYPE}" > "$TAGTYPE"
|
||||||
|
|
||||||
echo "ZEN" > "$TAGCURRENCY"
|
echo "ZEN" > "$TAGCURRENCY"
|
||||||
|
@ -167,15 +171,19 @@ 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 "$TAGBKEY" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "/home/$YOU/.ipfs/keystore/${RR}"
|
echo "${BB}" | gpg -q --output "$TAGPUBLISH_B_GPG" --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 "$TAGG1smsWKEY"
|
./shell/natools.py encrypt -p $PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_PHONE_CRYPT"
|
||||||
|
|
||||||
|
# GIVE NODE_UIDNA ACCESS TO ZEN TAG
|
||||||
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_NODE_CRYPT"
|
||||||
|
|
||||||
# GIVE SWARM ACCESS TO ZEN TAG
|
# GIVE SWARM ACCESS TO ZEN TAG
|
||||||
./shell/natools.py encrypt -p $MASTERPUB -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGSWARMKEY"
|
./shell/natools.py encrypt -p $SWARM_G1PUBKEY -i "/home/$YOU/.ipfs/keystore/${RR}" -o "$TAGPUBLISH_SWARM_CRYPT"
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING
|
# TAG IPFS STORAGE & G1Tag IPNS PUBLISHING
|
||||||
|
@ -192,13 +200,15 @@ 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
|
||||||
echo "$PASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
|
HPASSENGER=$(echo -n $PASSENGER | sha256sum | cut -d ' ' -f 1)
|
||||||
|
echo "$HPASSENGER" > "./wallets/.$IPFSNODEID/TAG/${J}";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
log "__SUB:sms_G1TAG.sh: TAG: ipfs ls /ipns/$(cat $TAGIPNS)"
|
log "__SUB:sms_G1TAG.sh: TAG: ipfs ls /ipns/${J}"
|
||||||
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}"
|
||||||
|
@ -210,22 +220,27 @@ 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
|
|
||||||
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"
|
|
||||||
else
|
|
||||||
composite -compose Over -resize 100% -gravity Center "./shell/Portefeuille.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# WRITE G1Tag G1 amount
|
# ADD Avatar in the Center
|
||||||
convert -pointsize 150 -fill black -gravity Center -draw 'text 240,-140 "'"$2"'"' "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
# 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"
|
||||||
|
# else
|
||||||
|
# composite -compose Over -resize 100% -gravity Center "./shell/G1Anar.png" "./TAG/${RR}/${RR}.png" "./TAG/${RR}/${RR}.png"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
|
convert -pointsize 60 -fill black -gravity Center -draw 'text 0,-100 "'"$2"'"' "./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 0,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"
|
||||||
|
|
||||||
# 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/ipfsid.G1TAGNODE" ]]; then
|
if [[ -f "./wallets/$PHONE/ipfsid.G1TAGNODE" ]]; then
|
||||||
destnode=$(cat "./wallets/$PHONE/ipfsid.G1TAGNODE")
|
destnode=$(cat "./wallets/$PHONE/ipfsid.G1TAGNODE")
|
||||||
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
|
if [[ "$destnode" == "" || "$destnode" == "$IPFSNODEID" ]]; then
|
||||||
|
@ -233,10 +248,11 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
|
||||||
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 MASTERPUB ?
|
# PRINT ON ANOTHER G1Dab. Send files to G1Tag Printer TODO: Could use DESTNODEPUB instead of NODE_G1PUBKEY ?
|
||||||
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin "
|
log "__SUB:sms_G1TAG.sh: Remote PRINT :: ./wallets/.$destnode/PRINT/${RR}.bin "
|
||||||
mkdir -p "./wallets/.$destnode/PRINT/"
|
mkdir -p "./wallets/.$destnode/PRINT/"
|
||||||
./shell/natools.py encrypt -p $MASTERPUB -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin"
|
# TODO: USE $DEST_G1PUBKEY is better
|
||||||
|
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "./TAG/${RR}/${RR}.png" -o "./wallets/.$destnode/PRINT/${RR}.bin"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
|
@ -249,16 +265,24 @@ 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
|
||||||
# PRINT $PHONE WALLET PUBKEY
|
|
||||||
qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)"
|
qrencode -s 5 -o "/tmp/G1PubQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.pub)"
|
||||||
composite -compose Over -resize 133% -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 -resize 150% -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
|
||||||
convert -pointsize 60 -fill black -gravity Center -draw 'text 320,-160 "'"$MEMBER"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
if [[ -f ./wallets/$PHONE/$PHONE.uidrib ]]; then
|
||||||
convert -pointsize 70 -fill black -gravity Center -draw 'text 345, 0 "'"$UIDNA"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
qrencode -s 6 -o "/tmp/G1MemQR.$PHONE.png" "$(cat ./wallets/$PHONE/$PHONE.uidrib)";
|
||||||
convert -pointsize 60 -fill black -gravity Center -draw 'text 330,160 "'"$PHONE"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$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
|
||||||
|
|
||||||
|
convert -pointsize 40 -fill black -gravity NorthEast -draw 'text 100,0 "'"G1 $MEMBER"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
convert -pointsize 40 -fill black -gravity SouthWest -draw 'text 10,0 "'"$UIDNA"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
|
#convert -pointsize 60 -fill black -gravity Center -draw 'text 350,80 "'"$PHONE"'"' "/tmp/G1PubQR.$PHONE.png" "/tmp/G1PubQR.$PHONE.png"
|
||||||
brother_ql_create --model QL-700 "/tmp/G1PubQR.$PHONE.png" --label-size 62 > "/tmp/G1PubQR.$PHONE.bin"
|
brother_ql_create --model QL-700 "/tmp/G1PubQR.$PHONE.png" --label-size 62 > "/tmp/G1PubQR.$PHONE.bin"
|
||||||
brother_ql_print "/tmp/G1PubQR.$PHONE.bin" /dev/usb/lp0
|
brother_ql_print "/tmp/G1PubQR.$PHONE.bin" /dev/usb/lp0
|
||||||
rm -f /tmp/G1PubQR.*
|
rm -f /tmp/G1PubQR.*
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
source ./shell/init.sh
|
source ./shell/init.sh
|
||||||
source ./shell/functions.sh
|
source ./shell/functions.sh
|
||||||
log "X sms_NEW.sh ($1=phone, $2=uid)"
|
log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_"
|
||||||
|
|
||||||
PHONE="$1"
|
PHONE="$1"
|
||||||
MEMBERUID="$2"
|
MEMBERUID="$2"
|
||||||
|
@ -15,9 +15,9 @@ MEMBERUID="$2"
|
||||||
sms_INIT_ACCOUNT "$PHONE"
|
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")
|
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN")
|
||||||
if [[ $MEMRIB == "" ]]; then exit; fi
|
if [[ $MEMRIB == "" ]]; then exit; fi
|
||||||
MEMBER="$MEMBERUID"
|
MEMBER="$MEMBERUID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -48,11 +48,13 @@ sms_SEND "$PHONE" "* Clef Publique (RIB) ="
|
||||||
sleep 2
|
sleep 2
|
||||||
sms_SEND "$PHONE" "$PUBKEY"
|
sms_SEND "$PHONE" "$PUBKEY"
|
||||||
sleep 2
|
sleep 2
|
||||||
sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
|
[[ $MEMRIB != "" ]] && sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
|
||||||
$MEMRIB"
|
$MEMRIB"
|
||||||
|
|
||||||
|
# Add contact to database
|
||||||
|
add_contact $PHONE $MEMBERUID && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_"
|
||||||
|
|
||||||
|
log "${c_yellow}END sms_NEW.sh$c_"
|
||||||
log "END sms_NEW.sh"
|
|
||||||
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
exit
|
exit
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,9 @@ 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: $((VIR+PERCENT+LIMIT)) G1! Rechargez avec https://Cesium.app"
|
sms_ERROR "$phone" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum: $CHARGE G1! Rechargez avec https://Cesium.app"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -49,9 +50,8 @@ 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 $AMOUNT $UNIT" -y)
|
PAY=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$VIR" --output="$PUBKEYDEST" --comment="[G1sms+] PAY" -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")
|
|
||||||
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";
|
||||||
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $PAY"
|
log "__SUB:sms_PAY.sh: Problème de payement avec silkaj $new : $PAY"
|
||||||
exit
|
exit
|
||||||
|
@ -64,7 +64,7 @@ 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="$MASTERPUB" --comment="[G1sms+] Commission" -y)
|
COM=$(./shell/timeout.sh -t 20 ./silkaj/silkaj transaction --auth-scrypt -salt="$phone" -password="$pin" --amount="$PERCENT" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Commission" -y)
|
||||||
if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
|
if [[ "$(echo $COM | 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): $COM";
|
sms_ERROR "$phone" "Problème de payement avec silkaj (changement de serveur $new): $COM";
|
||||||
|
@ -73,7 +73,7 @@ if [[ "$(echo $COM | cut -d '|' -f 1)" == "KO" || "$PAY" == "" ]]; then
|
||||||
else
|
else
|
||||||
# OK: Sync g1cents
|
# OK: Sync g1cents
|
||||||
cents=$(echo $(bc -l <<< "scale=0; $PERCENT * 100") | cut -d '.' -f 1)
|
cents=$(echo $(bc -l <<< "scale=0; $PERCENT * 100") | cut -d '.' -f 1)
|
||||||
move_g1cents "$phone" "$MASTERPUB" "$cents"
|
move_g1cents "$phone" "$NODE_G1PUBKEY" "$cents"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# LOG ACCOUNT HISTORY EVENTS
|
# LOG ACCOUNT HISTORY EVENTS
|
||||||
|
|
|
@ -79,20 +79,22 @@ 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/*/*.uidna | tail -n 1 | cut -f 3 -d '/')
|
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi
|
||||||
if [[ "$LOCAL" != "" ]]; then
|
if [[ "$LOCAL" != "" ]]; then
|
||||||
# LOCAL G1sms account
|
# LOCAL G1sms account
|
||||||
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
||||||
DESTPHONE=$LOCAL
|
DESTPHONE=$LOCAL
|
||||||
log "__SUB:sms_REC.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
log "__SUB:sms_REC.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
||||||
else
|
else
|
||||||
# SEARCH IN WALLETS SWARM
|
# SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA)
|
||||||
SWARMNB=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/')
|
INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/')
|
||||||
if [[ "$LOCAL" != "" ]]; then
|
if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi
|
||||||
REMOTENODE=$(cat ./wallets_swarm/$SWARMNB/MASTERPHONE.sms)
|
if [[ "$INSWARM" != "" ]]; then
|
||||||
DESTRIB=$(cat ./wallets_swarm/$SWARMNB/$SWARMNB.pub)
|
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms)
|
||||||
DESTPHONE=$SWARMNB
|
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub)
|
||||||
log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($SWARMNB)"
|
DESTPHONE=$INSWARM
|
||||||
|
log "__SUB:sms_REC.sh: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)"
|
||||||
else
|
else
|
||||||
# SEARCH WITH SILKAJ
|
# SEARCH WITH SILKAJ
|
||||||
DESTRIB=$(./silkaj/silkaj id "$DESTMEM" | grep -w "$DESTMEM" | awk '{print $2}')
|
DESTRIB=$(./silkaj/silkaj id "$DESTMEM" | grep -w "$DESTMEM" | awk '{print $2}')
|
||||||
|
@ -155,7 +157,7 @@ $DESTRIB"
|
||||||
log_history "$PHONE" "REC, $VIR, $DESTRIB, $DESTMEM, $PERIOD, $TIME"
|
log_history "$PHONE" "REC, $VIR, $DESTRIB, $DESTMEM, $PERIOD, $TIME"
|
||||||
# Send DESTPHONE sms
|
# Send DESTPHONE sms
|
||||||
if [[ "$DESTPHONE" != "" ]]; then
|
if [[ "$DESTPHONE" != "" ]]; then
|
||||||
sms_SEND "$DESTPHONE" "[G1sms+] Bonjour $DESTMEM. Vous recev(r)ez un payement de $VIR G1 (pendant $TIME $PERIOD) de la part du portefeuille: $MEMBER."
|
sms_SEND "$DESTPHONE" "[G1sms+] Bonjour $DESTMEM. Vous recev(r)ez un payement de $VIR G1 (pendant $TIME $PERIOD) de la part du portefeuille: $MEMBER $UIDNA."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -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 $charge G1! Rechargez par Cesium."
|
sms_ERROR "$PHONE" "Solde de votre Porte-monnaie G1sms insuffisant. Minimum $VIR + $LIMIT G1! Rechargez par Cesium."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -48,15 +48,17 @@ else
|
||||||
log "__SUB:sms_VIR.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB "
|
log "__SUB:sms_VIR.sh: SEARCH $VIRDEST related wallet!!! $DESTRIB "
|
||||||
DESTMEM="$VIRDEST"
|
DESTMEM="$VIRDEST"
|
||||||
# SEARCH IN WALLETS
|
# SEARCH IN WALLETS
|
||||||
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/')
|
LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidname | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$LOCAL" == "" ]]; then LOCAL=$(grep -Rwl "$DESTMEM" ./wallets/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi
|
||||||
if [[ "$LOCAL" != "" ]]; then
|
if [[ "$LOCAL" != "" ]]; then
|
||||||
# LOCAL G1sms account
|
# LOCAL G1sms account
|
||||||
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
DESTRIB=$(cat ./wallets/$LOCAL/$LOCAL.pub)
|
||||||
DESTPHONE=$LOCAL
|
DESTPHONE=$LOCAL
|
||||||
log "__SUB:sms_VIR.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
log "__SUB:sms_VIR.sh: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
||||||
else
|
else
|
||||||
# SEARCH IN WALLETS SWARM
|
# SEARCH IN WALLETS SWARM (MEMBER THEN UIDNA)
|
||||||
INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/')
|
INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidname | tail -n 1 | cut -f 3 -d '/')
|
||||||
|
if [[ "$INSWARM" == "" ]]; then INSWARM=$(grep -Rwl "$DESTMEM" ./wallets_swarm/*/*.uidna | tail -n 1 | cut -f 3 -d '/'); fi
|
||||||
if [[ "$INSWARM" != "" ]]; then
|
if [[ "$INSWARM" != "" ]]; then
|
||||||
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms)
|
REMOTENODE=$(cat ./wallets_swarm/$INSWARM/MASTERPHONE.sms)
|
||||||
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub)
|
DESTRIB=$(cat ./wallets_swarm/$INSWARM/$INSWARM.pub)
|
||||||
|
@ -71,7 +73,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$DESTRIB" != "" ]]; then
|
if [[ "$DESTRIB" != "" ]]; then
|
||||||
PAY=$(./shell/timeout.sh -t 20 ./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="$PHONE" -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
|
||||||
|
@ -83,7 +85,7 @@ $PAY"
|
||||||
log_history "$PHONE" "VIR, $VIR, $DESTRIB, $DESTMEM"
|
log_history "$PHONE" "VIR, $VIR, $DESTRIB, $DESTMEM"
|
||||||
# Send DESTPHONE sms
|
# Send DESTPHONE sms
|
||||||
if [[ "$DESTPHONE" != "" ]]; then
|
if [[ "$DESTPHONE" != "" ]]; then
|
||||||
sms_SEND "$DESTPHONE" "Bonjour $DESTMEM. Vous venez de recevoir un virement de $AMOUNT $UNIT ($VIR G1) de la part de $member portefeuille $UIDNA ($phone)"
|
sms_SEND "$DESTPHONE" "Bonjour $DESTMEM. Vous venez de recevoir un virement de $AMOUNT $UNIT ($VIR G1) de la part de $member portefeuille $UIDNA"
|
||||||
fi
|
fi
|
||||||
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
|
cents=$(echo $(bc -l <<< "scale=0; $VIR * 100") | cut -d '.' -f 1)
|
||||||
move_g1cents "$PHONE" "$DESTRIB" "$cents"
|
move_g1cents "$PHONE" "$DESTRIB" "$cents"
|
||||||
|
|
|
@ -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.MASTER.crypt
|
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.swarm.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.MASTER.crypt"
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.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)
|
||||||
|
@ -125,8 +125,8 @@ IFILE=$(su $YOU -c "ipfs add \"${MUSICFILE}\" | tail -n 1")
|
||||||
if [[ ! $IFILE ]]; then exit; fi
|
if [[ ! $IFILE ]]; then exit; fi
|
||||||
echo "$IFILE" > $TAGPASSENGER
|
echo "$IFILE" > $TAGPASSENGER
|
||||||
# ONLY SWARM KEY CAN DECRYPT IPFS LINK TO FILE (TODO: Glue better)
|
# ONLY SWARM KEY CAN DECRYPT IPFS LINK TO FILE (TODO: Glue better)
|
||||||
MASTERPUB=$(cat "./g1sms.pub.key")
|
NODE_G1PUBKEY=$(cat "./g1sms.pub.key")
|
||||||
./shell/natools.py encrypt -p "$MASTERPUB" -i "$TAGPASSENGER" -o "$TAGPASSENGERCRYPT"
|
./shell/natools.py encrypt -p "$NODE_G1PUBKEY" -i "$TAGPASSENGER" -o "$TAGPASSENGERCRYPT"
|
||||||
echo "LOADED" > $TAGPASSENGER
|
echo "LOADED" > $TAGPASSENGER
|
||||||
|
|
||||||
echo "$DEB" > $TAGPASSENGERDEBIT
|
echo "$DEB" > $TAGPASSENGERDEBIT
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
################################################################################
|
################################################################################
|
||||||
# Author: Fred (support@qo-op.com)
|
# Author: Fred (support@qo-op.com)
|
||||||
# Version: 0.1
|
# Version: 0.2020
|
||||||
# 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.MASTER.crypt
|
# QmXaMzRqhEs4cQMRN18FWaCeqGmrDBfV8hTkbfQuBCXnnA 1243 TAG_publishkey.swarm.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.MASTER.crypt"
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.crypt"
|
||||||
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount);
|
JSOURCEVALUE=$(cat ./TAG/${JSOURCERR}/TAG_amount);
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
|
@ -69,7 +69,9 @@ if [[ $FINALSOURCE -lt 0 ]]; then echo "__SUB:tag_OP.sh: KO. La valeur de ce G1T
|
||||||
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
|
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JSOURCERR" ]]; then
|
||||||
./shell/natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
|
./shell/natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
|
||||||
else
|
else
|
||||||
echo "__SUB:tag_OP.sh: KO. La clef $KEYFILE fournie pour ce G1Tag $JSOURCERR est inexistante. Contact: https://g1sms.fr"
|
if [[ ! -f $KEYFILE ]]; then
|
||||||
|
echo "__SUB:tag_OP.sh: KO. La clef de dévérouillage pour $JSOURCERR est inexistante. Contact: https://g1sms.fr"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
|
@ -80,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.MASTER.crypt"
|
JDESTPUBLISHKEY="./TAG/${JDESTRR}/TAG_publishkey.swarm.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"
|
||||||
|
@ -88,7 +90,9 @@ FINALDEST=$(echo "${JDESTVALUE} + ${VALUE}" | bc -l)
|
||||||
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JDESTRR" ]]; then
|
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JDESTRR" ]]; then
|
||||||
./shell/natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JDESTRR"
|
./shell/natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JDESTRR"
|
||||||
else
|
else
|
||||||
echo "__SUB:tag_OP.sh: KO. La clef $KEYFILE fournie pour ce G1Tag $JDESTRR est inexistante. Be part of the G1sms+SWARM. https://g1sms.fr"
|
if [[ ! -f $KEYFILE ]]; then
|
||||||
|
echo "__SUB:tag_OP.sh: KO. La clef de dévérouillage pour $JDESTRR est inexistante. Contact: https://g1sms.fr"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
|
@ -156,9 +160,9 @@ fi
|
||||||
echo "__SUB:tag_OP.sh: DONE. G1Tag balance updated:
|
echo "__SUB:tag_OP.sh: DONE. G1Tag balance updated:
|
||||||
$JSOURCERR (/ipns/$JSOURCE) : $JSOURCEVALUE => $FINALSOURCE
|
$JSOURCERR (/ipns/$JSOURCE) : $JSOURCEVALUE => $FINALSOURCE
|
||||||
$JDESTRR (/ipns/$JSDEST) : $JDESTVALUE) => $FINALDEST"
|
$JDESTRR (/ipns/$JSDEST) : $JDESTVALUE) => $FINALDEST"
|
||||||
return 1
|
|
||||||
else
|
else
|
||||||
echo "__SUB:tag_OP.sh: NO OPERATION DONE"
|
echo "__SUB:tag_OP.sh: NO OPERATION DONE"
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
READERID=$1
|
READERID=$1
|
||||||
JSOURCE=$2
|
JSOURCE=$2
|
||||||
KEYFILE="./g1sms.priv.key"
|
KEYFILE="./g1sms.priv.key"
|
||||||
MASTERPUB=$(cat "./g1sms.pub.key")
|
NODE_G1PUBKEY=$(cat "./g1sms.pub.key")
|
||||||
|
|
||||||
if [[ ! $READERID || ! $JSOURCE || ! -f "$KEYFILE" || ! $MASTERPUB ]]; then "Something is wrong! Do you know what you are doing?"; exit; fi
|
if [[ ! $READERID || ! $JSOURCE || ! -f "$KEYFILE" || ! $NODE_G1PUBKEY ]]; then "Something is wrong! Do you know what you are doing?"; exit; fi
|
||||||
|
|
||||||
NODEG1TAG=$(cat "./wallets_swarm/.$READERID/TAG/$READERID") # Contains IPNS link to Node G1Tag
|
NODEG1TAG=$(cat "./wallets_swarm/.$READERID/TAG/$READERID") # Contains IPNS link to Node G1Tag
|
||||||
if [[ ! $NODEG1TAG ]]; then
|
if [[ ! $NODEG1TAG ]]; then
|
||||||
|
@ -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.MASTER.crypt"
|
JSOURCEPUBLISHKEY="./TAG/${JSOURCERR}/TAG_publishkey.swarm.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")
|
||||||
|
|
|
@ -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 $MASTERKEYFILE ($G1VAL) -> $CASHBACK"
|
log "__SUB:tag_READ.sh: Silkaj TX $SWARM_G1AUTHFILE ($G1VAL) -> $CASHBACK"
|
||||||
PAY=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] CAPTURE G1Tag $RR" -y)
|
PAY=$(./silkaj/silkaj transaction --auth-file -file="$SWARM_G1AUTHFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] CAPTURE G1Tag $RR" -y)
|
||||||
|
|
||||||
log "__SUB:tag_READ.sh: Silkaj output = $PAY"
|
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]} $MASTERKEYFILE)"
|
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[1]} ${obj[0]} ${val[1]} $SWARM_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 $MASTERKEYFILE)"
|
log "__SUB:tag_READ.sh: $(./shell/tag_OP.sh ${obj[0]} ${obj[0]} 0 $SWARM_G1AUTHFILE)"
|
||||||
fi
|
fi
|
||||||
CASHBACK=""
|
CASHBACK=""
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,286 @@
|
||||||
|
#!/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_X.sh: QRCODE READER : START"
|
||||||
|
source ./shell/init.sh
|
||||||
|
source ./shell/functions.sh
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
function log () {
|
||||||
|
echo "$line
|
||||||
|
$1" >> /tmp/tag_READ_X.log
|
||||||
|
}
|
||||||
|
|
||||||
|
SWARM_G1AUTHFILE="${MY_PATH}/../g1sms.priv.key"
|
||||||
|
if [ ! -f $SWARM_G1AUTHFILE ]; then echo "ERREUR CLEF DECHIFFRAGE!"; exit; fi
|
||||||
|
# TODO G1TAG: USE CREATOR NODE KEY FILE INSTEAD OF SWARM_G1AUTHFILE SWARM KEY
|
||||||
|
|
||||||
|
# DOUCHETTE ES TU LA?
|
||||||
|
if [ ! $G1TX ]; then echo "Branchez votre lecteur de QR code!"; exit; fi
|
||||||
|
./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
|
|
@ -0,0 +1,300 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import time
|
||||||
|
import fourletterphat
|
||||||
|
|
||||||
|
fourletterphat.clear()
|
||||||
|
|
||||||
|
fourletterphat.print_str("SCAN")
|
||||||
|
fourletterphat.set_blink(fourletterphat.HT16K33_BLINK_HALFHZ)
|
||||||
|
fourletterphat.show()
|
||||||
|
time.sleep(1)
|
||||||
|
fourletterphat.set_blink(fourletterphat.HT16K33_BLINK_OFF)
|
||||||
|
fourletterphat.print_str("CODE")
|
||||||
|
fourletterphat.show()
|
||||||
|
time.sleep(0.5)
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import fourletterphat
|
||||||
|
fourletterphat.clear()
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import time
|
||||||
|
import fourletterphat
|
||||||
|
|
||||||
|
while True:
|
||||||
|
fourletterphat.clear()
|
||||||
|
|
||||||
|
str_time = time.strftime("%H%M")
|
||||||
|
|
||||||
|
# Display the time
|
||||||
|
fourletterphat.print_number_str(str_time)
|
||||||
|
|
||||||
|
# Blink the middle decimal point
|
||||||
|
# int(time.time() % 2) will alternate 1 0 1 0
|
||||||
|
# which we can use to directly set the point
|
||||||
|
fourletterphat.set_decimal(1, int(time.time() % 2))
|
||||||
|
|
||||||
|
fourletterphat.show()
|
||||||
|
time.sleep(0.1)
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
import sys
|
||||||
|
import fourletterphat
|
||||||
|
|
||||||
|
# if bad number of arguments...
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
|
||||||
|
# display command usage
|
||||||
|
print("""
|
||||||
|
Usage:
|
||||||
|
python 4LETTER.scroll.py "message a afficher"
|
||||||
|
""")
|
||||||
|
|
||||||
|
# exit with status code error
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
# Get message from arguments
|
||||||
|
message = sys.argv[1]
|
||||||
|
fourletterphat.scroll_print( message )
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import time
|
||||||
|
import fourletterphat as flp
|
||||||
|
|
||||||
|
spinner = ["|", "/", "-", "\\"]
|
||||||
|
|
||||||
|
while True:
|
||||||
|
for i in range(4):
|
||||||
|
for s in spinner:
|
||||||
|
s = s * 4
|
||||||
|
flp.clear()
|
||||||
|
flp.print_str(s)
|
||||||
|
flp.show()
|
||||||
|
time.sleep(0.1)
|
|
@ -0,0 +1,332 @@
|
||||||
|
#!/bin/bash
|
||||||
|
###########################################################
|
||||||
|
# FORK of pishrink.sh
|
||||||
|
# SHRINK IMAGE OF YOUR RASPIAN PI SD CARD
|
||||||
|
#
|
||||||
|
# + TODO: THIS SCRIPT RESET IPFS / G1 Keys / SWARM config
|
||||||
|
# AND RUN CONFIG on FIRST IMG BOOT in /etc/rc.local
|
||||||
|
###########################################################
|
||||||
|
version="v0.1.3"
|
||||||
|
|
||||||
|
CURRENT_DIR=$(pwd)
|
||||||
|
SCRIPTNAME="${0##*/}"
|
||||||
|
LOGFILE=${CURRENT_DIR}/${SCRIPTNAME%.*}.log
|
||||||
|
|
||||||
|
function info() {
|
||||||
|
echo "$SCRIPTNAME: $1..."
|
||||||
|
}
|
||||||
|
|
||||||
|
function error() {
|
||||||
|
echo -n "$SCRIPTNAME: ERROR occured in line $1: "
|
||||||
|
shift
|
||||||
|
echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
if losetup "$loopback" &>/dev/null; then
|
||||||
|
losetup -d "$loopback"
|
||||||
|
fi
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
|
local old_owner=$(stat -c %u:%g "$src")
|
||||||
|
chown "$old_owner" "$LOGFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function logVariables() {
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
|
echo "Line $1" >> "$LOGFILE"
|
||||||
|
shift
|
||||||
|
local v var
|
||||||
|
for var in "$@"; do
|
||||||
|
eval "v=\$$var"
|
||||||
|
echo "$var: $v" >> "$LOGFILE"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFilesystem() {
|
||||||
|
info "Checking filesystem"
|
||||||
|
e2fsck -pf "$loopback"
|
||||||
|
(( $? < 4 )) && return
|
||||||
|
|
||||||
|
info "Filesystem error detected!"
|
||||||
|
|
||||||
|
info "Trying to recover corrupted filesystem"
|
||||||
|
e2fsck -y "$loopback"
|
||||||
|
(( $? < 4 )) && return
|
||||||
|
|
||||||
|
if [[ $repair == true ]]; then
|
||||||
|
info "Trying to recover corrupted filesystem - Phase 2"
|
||||||
|
e2fsck -fy -b 32768 "$loopback"
|
||||||
|
(( $? < 4 )) && return
|
||||||
|
fi
|
||||||
|
error $LINENO "Filesystem recoveries failed. Giving up..."
|
||||||
|
exit -9
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
local help
|
||||||
|
read -r -d '' help << EOM
|
||||||
|
Usage: $0 [-sdrzh] imagefile.img [newimagefile.img]
|
||||||
|
|
||||||
|
-s: Don't expand filesystem when image is booted the first time
|
||||||
|
-d: Write debug messages in a debug log file
|
||||||
|
-r: Use advanced filesystem repair option if the normal one fails
|
||||||
|
-z: Gzip compress image after shrinking
|
||||||
|
EOM
|
||||||
|
echo "$help"
|
||||||
|
exit -1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-sdrpzh] imagefile.img [newimagefile.img]"
|
||||||
|
echo ""
|
||||||
|
echo " -s: Skip autoexpand"
|
||||||
|
echo " -d: Debug mode on"
|
||||||
|
echo " -r: Use advanced repair options"
|
||||||
|
echo " -z: Gzip compress image after shrinking"
|
||||||
|
echo " -h: display help text"
|
||||||
|
exit -1
|
||||||
|
}
|
||||||
|
|
||||||
|
should_skip_autoexpand=false
|
||||||
|
debug=false
|
||||||
|
repair=false
|
||||||
|
gzip_compress=false
|
||||||
|
|
||||||
|
while getopts ":sdrzh" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
s) should_skip_autoexpand=true ;;
|
||||||
|
d) debug=true;;
|
||||||
|
r) repair=true;;
|
||||||
|
z) gzip_compress=true;;
|
||||||
|
h) help;;
|
||||||
|
*) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [ "$debug" = true ]; then
|
||||||
|
info "Creating log file $LOGFILE"
|
||||||
|
rm "$LOGFILE" &>/dev/null
|
||||||
|
exec 1> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&1)
|
||||||
|
exec 2> >(stdbuf -i0 -o0 -e0 tee -a "$LOGFILE" >&2)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${0##*/} $version"
|
||||||
|
|
||||||
|
#Args
|
||||||
|
src="$1"
|
||||||
|
img="$1"
|
||||||
|
|
||||||
|
#Usage checks
|
||||||
|
if [[ -z "$img" ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
if [[ ! -f "$img" ]]; then
|
||||||
|
error $LINENO "$img is not a file..."
|
||||||
|
exit -2
|
||||||
|
fi
|
||||||
|
if (( EUID != 0 )); then
|
||||||
|
error $LINENO "You need to be running as root."
|
||||||
|
exit -3
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Check that what we need is installed
|
||||||
|
for command in parted losetup tune2fs md5sum e2fsck resize2fs; do
|
||||||
|
command -v $command >/dev/null 2>&1
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
error $LINENO "$command is not installed."
|
||||||
|
exit -4
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
#Copy to new file if requested
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
info "Copying $1 to $2..."
|
||||||
|
cp --reflink=auto --sparse=always "$1" "$2"
|
||||||
|
if (( $? != 0 )); then
|
||||||
|
error $LINENO "Could not copy file..."
|
||||||
|
exit -5
|
||||||
|
fi
|
||||||
|
old_owner=$(stat -c %u:%g "$1")
|
||||||
|
chown "$old_owner" "$2"
|
||||||
|
img="$2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cleanup at script exit
|
||||||
|
trap cleanup ERR EXIT
|
||||||
|
|
||||||
|
#Gather info
|
||||||
|
info "Gatherin data"
|
||||||
|
beforesize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
||||||
|
parted_output=$(parted -ms "$img" unit B print | tail -n 1)
|
||||||
|
partnum=$(echo "$parted_output" | cut -d ':' -f 1)
|
||||||
|
partstart=$(echo "$parted_output" | cut -d ':' -f 2 | tr -d 'B')
|
||||||
|
loopback=$(losetup -f --show -o "$partstart" "$img")
|
||||||
|
tune2fs_output=$(tune2fs -l "$loopback")
|
||||||
|
currentsize=$(echo "$tune2fs_output" | grep '^Block count:' | tr -d ' ' | cut -d ':' -f 2)
|
||||||
|
blocksize=$(echo "$tune2fs_output" | grep '^Block size:' | tr -d ' ' | cut -d ':' -f 2)
|
||||||
|
|
||||||
|
logVariables $LINENO tune2fs_output currentsize blocksize
|
||||||
|
|
||||||
|
#Check if we should make pi expand rootfs on next boot
|
||||||
|
if [ "$should_skip_autoexpand" = false ]; then
|
||||||
|
#Make pi expand rootfs on next boot
|
||||||
|
mountdir=$(mktemp -d)
|
||||||
|
mount "$loopback" "$mountdir"
|
||||||
|
|
||||||
|
if [ "$(md5sum "$mountdir/etc/rc.local" | cut -d ' ' -f 1)" != "0542054e9ff2d2e0507ea1ffe7d4fc87" ]; then
|
||||||
|
echo "Creating new /etc/rc.local"
|
||||||
|
mv "$mountdir/etc/rc.local" "$mountdir/etc/rc.local.bak"
|
||||||
|
#####Do not touch the following lines#####
|
||||||
|
cat <<\EOF1 > "$mountdir/etc/rc.local"
|
||||||
|
#!/bin/bash
|
||||||
|
do_expand_rootfs() {
|
||||||
|
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
|
||||||
|
|
||||||
|
PART_NUM=${ROOT_PART#mmcblk0p}
|
||||||
|
if [ "$PART_NUM" = "$ROOT_PART" ]; then
|
||||||
|
echo "$ROOT_PART is not an SD card. Don't know how to expand"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the starting offset of the root partition
|
||||||
|
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
|
||||||
|
[ "$PART_START" ] || return 1
|
||||||
|
# Return value will likely be error for fdisk as it fails to reload the
|
||||||
|
# partition table because the root fs is mounted
|
||||||
|
fdisk /dev/mmcblk0 <<EOF
|
||||||
|
p
|
||||||
|
d
|
||||||
|
$PART_NUM
|
||||||
|
n
|
||||||
|
p
|
||||||
|
$PART_NUM
|
||||||
|
$PART_START
|
||||||
|
|
||||||
|
p
|
||||||
|
w
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > /etc/rc.local &&
|
||||||
|
#!/bin/sh
|
||||||
|
echo "Expanding /dev/$ROOT_PART"
|
||||||
|
resize2fs /dev/$ROOT_PART
|
||||||
|
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
|
||||||
|
|
||||||
|
EOF
|
||||||
|
reboot
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
raspi_config_expand() {
|
||||||
|
/usr/bin/env raspi-config --expand-rootfs
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
return -1
|
||||||
|
else
|
||||||
|
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
|
||||||
|
reboot
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
raspi_config_expand
|
||||||
|
echo "WARNING: Using backup expand..."
|
||||||
|
sleep 5
|
||||||
|
do_expand_rootfs
|
||||||
|
echo "ERROR: Expanding failed..."
|
||||||
|
sleep 5
|
||||||
|
rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local
|
||||||
|
exit 0
|
||||||
|
EOF1
|
||||||
|
#####End no touch zone#####
|
||||||
|
chmod +x "$mountdir/etc/rc.local"
|
||||||
|
fi
|
||||||
|
umount "$mountdir"
|
||||||
|
else
|
||||||
|
echo "Skipping autoexpanding process..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Make sure filesystem is ok
|
||||||
|
checkFilesystem
|
||||||
|
|
||||||
|
if ! minsize=$(resize2fs -P "$loopback"); then
|
||||||
|
rc=$?
|
||||||
|
error $LINENO "resize2fs failed with rc $rc"
|
||||||
|
exit -10
|
||||||
|
fi
|
||||||
|
minsize=$(cut -d ':' -f 2 <<< "$minsize" | tr -d ' ')
|
||||||
|
logVariables $LINENO minsize
|
||||||
|
if [[ $currentsize -eq $minsize ]]; then
|
||||||
|
error $LINENO "Image already shrunk to smallest size"
|
||||||
|
exit -11
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Add some free space to the end of the filesystem
|
||||||
|
extra_space=$(($currentsize - $minsize))
|
||||||
|
logVariables $LINENO extra_space
|
||||||
|
for space in 5000 1000 100; do
|
||||||
|
if [[ $extra_space -gt $space ]]; then
|
||||||
|
minsize=$(($minsize + $space))
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
logVariables $LINENO minsize
|
||||||
|
|
||||||
|
#Shrink filesystem
|
||||||
|
info "Shrinking filesystem"
|
||||||
|
resize2fs -p "$loopback" $minsize
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
error $LINENO "resize2fs failed"
|
||||||
|
mount "$loopback" "$mountdir"
|
||||||
|
mv "$mountdir/etc/rc.local.bak" "$mountdir/etc/rc.local"
|
||||||
|
umount "$mountdir"
|
||||||
|
losetup -d "$loopback"
|
||||||
|
exit -12
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
#Shrink partition
|
||||||
|
partnewsize=$(($minsize * $blocksize))
|
||||||
|
newpartend=$(($partstart + $partnewsize))
|
||||||
|
logVariables $LINENO partnewsize newpartend
|
||||||
|
if ! parted -s -a minimal "$img" rm "$partnum"; then
|
||||||
|
rc=$?
|
||||||
|
error $LINENO "parted failed with rc $rc"
|
||||||
|
exit -13
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! parted -s "$img" unit B mkpart primary "$partstart" "$newpartend"; then
|
||||||
|
rc=$?
|
||||||
|
error $LINENO "parted failed with rc $rc"
|
||||||
|
exit -14
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Truncate the file
|
||||||
|
info "Shrinking image"
|
||||||
|
if ! endresult=$(parted -ms "$img" unit B print free); then
|
||||||
|
rc=$?
|
||||||
|
error $LINENO "parted failed with rc $rc"
|
||||||
|
exit -15
|
||||||
|
fi
|
||||||
|
|
||||||
|
endresult=$(tail -1 <<< "$endresult" | cut -d ':' -f 2 | tr -d 'B')
|
||||||
|
logVariables $LINENO endresult
|
||||||
|
if ! truncate -s "$endresult" "$img"; then
|
||||||
|
rc=$?
|
||||||
|
error $LINENO "trunate failed with rc $rc"
|
||||||
|
exit -16
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $gzip_compress == true ]]; then
|
||||||
|
info "Gzipping the shrunk image"
|
||||||
|
if [[ ! $(gzip -f9 "$img") ]]; then
|
||||||
|
img=$img.gz
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
||||||
|
logVariables $LINENO aftersize
|
||||||
|
|
||||||
|
info "Shrunk $img from $beforesize to $aftersize"
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
CopyLeft 2019 Pascal Engélibert
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from duniterpy.key import SigningKey
|
||||||
|
|
||||||
|
def getargv(arg, default=""):
|
||||||
|
if arg in sys.argv and len(sys.argv) > sys.argv.index(arg)+1:
|
||||||
|
return sys.argv[sys.argv.index(arg)+1]
|
||||||
|
else:
|
||||||
|
return default
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if "--help" in sys.argv or not "-i" in sys.argv or not "-o" in sys.argv:
|
||||||
|
print("""Duniter MiniTools: Mass Keygen
|
||||||
|
CopyLeft 2019 Pascal Engélibert
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python3 keygen.py -i <input_file> -o <output_file>
|
||||||
|
Format: CSV ; Separator: tab
|
||||||
|
""")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
infile = open(getargv("-i"), "r")
|
||||||
|
outfile = open(getargv("-o"), "w")
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
line = infile.readline()
|
||||||
|
if line == "":
|
||||||
|
break
|
||||||
|
i += 1
|
||||||
|
if "\n" in line:
|
||||||
|
line = line[:len(line)-1]
|
||||||
|
|
||||||
|
cols = line.split("\t")
|
||||||
|
while "" in cols:
|
||||||
|
cols.remove("")
|
||||||
|
if len(cols) < 2:
|
||||||
|
print("Error (line "+str(i)+"): less than 2 columns! (at least 2 expected)")
|
||||||
|
break
|
||||||
|
|
||||||
|
key = SigningKey.from_credentials(cols[0], cols[1])
|
||||||
|
outfile.write(cols[0]+"\t"+cols[1]+"\t"+key.pubkey+"\n")
|
||||||
|
|
||||||
|
infile.close()
|
||||||
|
outfile.close()
|
|
@ -0,0 +1,85 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os, sys, duniterpy.key, libnacl.sign
|
||||||
|
|
||||||
|
def getargv(arg:str, default:str="", n:int=1, args:list=sys.argv) -> str:
|
||||||
|
if arg in args and len(args) > args.index(arg)+n:
|
||||||
|
return args[args.index(arg)+n]
|
||||||
|
else:
|
||||||
|
return default
|
||||||
|
|
||||||
|
def read_data(data_path, b=True):
|
||||||
|
if data_path == "-":
|
||||||
|
if b:
|
||||||
|
return sys.stdin.read().encode()
|
||||||
|
else:
|
||||||
|
return sys.stdin.read()
|
||||||
|
else:
|
||||||
|
if b:
|
||||||
|
return open(os.path.expanduser(data_path), "rb").read()
|
||||||
|
else:
|
||||||
|
return open(os.path.expanduser(data_path), "r").read()
|
||||||
|
|
||||||
|
def write_data(data, result_path):
|
||||||
|
(sys.stdout if result_path == "-" else open(os.path.expanduser(result_path), "wb")).write(data)
|
||||||
|
|
||||||
|
def encrypt(data, pubkey):
|
||||||
|
return duniterpy.key.PublicKey(pubkey).encrypt_seal(data)
|
||||||
|
|
||||||
|
def decrypt(data, privkey):
|
||||||
|
return duniterpy.key.SigningKey.from_seedhex(privkey).decrypt_seal(data)
|
||||||
|
|
||||||
|
def sign(data, privkey):
|
||||||
|
return duniterpy.key.SigningKey.from_seedhex(privkey).sign(data)
|
||||||
|
|
||||||
|
def verify(data, pubkey):
|
||||||
|
try:
|
||||||
|
return libnacl.sign.Verifier(duniterpy.key.PublicKey(pubkey).hex_pk()).verify(data)
|
||||||
|
except ValueError:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def show_help():
|
||||||
|
print("""Usage:
|
||||||
|
python3 natools.py <command> [options]
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
encrypt Encrypt data
|
||||||
|
decrypt Decrypt data
|
||||||
|
sign Sign data
|
||||||
|
verify Verify data
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-i <path> Input file path (default: -)
|
||||||
|
-k <path> Privkey file path (default: authfile.key)
|
||||||
|
-p <str> Pubkey (base58)
|
||||||
|
-o <path> Output file path (default: -)
|
||||||
|
|
||||||
|
Note: "-" means stdin or stdout.
|
||||||
|
""")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if "--help" in sys.argv:
|
||||||
|
show_help()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
data_path = getargv("-i", "-")
|
||||||
|
privkey_path = getargv("-k", "authfile.key")
|
||||||
|
pubkey = getargv("-p")
|
||||||
|
result_path = getargv("-o", "-")
|
||||||
|
|
||||||
|
try:
|
||||||
|
if sys.argv[1] == "encrypt":
|
||||||
|
write_data(encrypt(read_data(data_path), pubkey), result_path)
|
||||||
|
elif sys.argv[1] == "decrypt":
|
||||||
|
write_data(decrypt(read_data(data_path), read_data(privkey_path, False)), result_path)
|
||||||
|
elif sys.argv[1] == "sign":
|
||||||
|
write_data(sign(read_data(data_path), read_data(privkey_path, False)), result_path)
|
||||||
|
elif sys.argv[1] == "verify":
|
||||||
|
write_data(verify(read_data(data_path), pubkey), result_path)
|
||||||
|
else:
|
||||||
|
show_help()
|
||||||
|
except Exception as e:
|
||||||
|
sys.stderr.write("Error: ", e, "\n")
|
||||||
|
show_help()
|
||||||
|
exit(1)
|
0
shell/request_cesium_profile.py → shell/tools/G1_request_cesium_profile.py
Normal file → Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#! /usr/bin/python
|
||||||
|
import fourletterphat
|
||||||
|
from matrixKeypad_RPi_GPIO import keypad
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
# Initialize the keypad class
|
||||||
|
kp = keypad()
|
||||||
|
|
||||||
|
fourletterphat.print_str(" G1?")
|
||||||
|
fourletterphat.show()
|
||||||
|
|
||||||
|
def digit():
|
||||||
|
# Loop while waiting for a keypress
|
||||||
|
r = None
|
||||||
|
while r == None:
|
||||||
|
r = kp.getKey()
|
||||||
|
return r
|
||||||
|
|
||||||
|
#print ("Please enter a 4 digit code: ")
|
||||||
|
|
||||||
|
# Getting digit 1, printing it, then sleep to allow the next digit press.
|
||||||
|
d1 = digit()
|
||||||
|
#print (d1)
|
||||||
|
sleep(0.25)
|
||||||
|
|
||||||
|
d2 = digit()
|
||||||
|
#print (d2)
|
||||||
|
sleep(0.25)
|
||||||
|
|
||||||
|
d3 = digit()
|
||||||
|
#print (d3)
|
||||||
|
sleep(0.25)
|
||||||
|
|
||||||
|
d4 = digit()
|
||||||
|
#print (d4)
|
||||||
|
|
||||||
|
# printing out the assembled 4 digit code.
|
||||||
|
print "%s%s%s%s"%(d1,d2,d3,d4)
|
||||||
|
fourletterphat.clear()
|
||||||
|
fourletterphat.scroll_print("OK %s%s%s%s"%(d1,d2,d3,d4))
|
||||||
|
sleep(2)
|
|
@ -0,0 +1,102 @@
|
||||||
|
# #####################################################
|
||||||
|
# Python Library for 3x4 matrix keypad using
|
||||||
|
# 7 of the avialable GPIO pins on the Raspberry Pi.
|
||||||
|
#
|
||||||
|
# This could easily be expanded to handle a 4x4 but I
|
||||||
|
# don't have one for testing. The KEYPAD constant
|
||||||
|
# would need to be updated. Also the setting/checking
|
||||||
|
# of the colVal part would need to be expanded to
|
||||||
|
# handle the extra column.
|
||||||
|
#
|
||||||
|
# Written by Chris Crumpacker
|
||||||
|
# May 2013
|
||||||
|
#
|
||||||
|
# main structure is adapted from Bandono's
|
||||||
|
# matrixQPI which is wiringPi based.
|
||||||
|
# https://github.com/bandono/matrixQPi?source=cc
|
||||||
|
# #####################################################
|
||||||
|
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
|
class keypad():
|
||||||
|
# CONSTANTS
|
||||||
|
KEYPAD = [
|
||||||
|
[1,2,3],
|
||||||
|
[4,5,6],
|
||||||
|
[7,8,9],
|
||||||
|
["*",0,"#"]
|
||||||
|
]
|
||||||
|
|
||||||
|
ROW = [18,23,24,25]
|
||||||
|
COLUMN = [5,6,13]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
|
||||||
|
def getKey(self):
|
||||||
|
|
||||||
|
# Set all columns as output low
|
||||||
|
for j in range(len(self.COLUMN)):
|
||||||
|
GPIO.setup(self.COLUMN[j], GPIO.OUT)
|
||||||
|
GPIO.output(self.COLUMN[j], GPIO.LOW)
|
||||||
|
|
||||||
|
# Set all rows as input
|
||||||
|
for i in range(len(self.ROW)):
|
||||||
|
GPIO.setup(self.ROW[i], GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||||
|
|
||||||
|
# Scan rows for pushed key/button
|
||||||
|
# A valid key press should set "rowVal" between 0 and 3.
|
||||||
|
rowVal = -1
|
||||||
|
for i in range(len(self.ROW)):
|
||||||
|
tmpRead = GPIO.input(self.ROW[i])
|
||||||
|
if tmpRead == 0:
|
||||||
|
rowVal = i
|
||||||
|
|
||||||
|
# if rowVal is not 0 thru 3 then no button was pressed and we can exit
|
||||||
|
if rowVal <0 or rowVal >3:
|
||||||
|
self.exit()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Convert columns to input
|
||||||
|
for j in range(len(self.COLUMN)):
|
||||||
|
GPIO.setup(self.COLUMN[j], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
|
|
||||||
|
# Switch the i-th row found from scan to output
|
||||||
|
GPIO.setup(self.ROW[rowVal], GPIO.OUT)
|
||||||
|
GPIO.output(self.ROW[rowVal], GPIO.HIGH)
|
||||||
|
|
||||||
|
# Scan columns for still-pushed key/button
|
||||||
|
# A valid key press should set "colVal" between 0 and 2.
|
||||||
|
colVal = -1
|
||||||
|
for j in range(len(self.COLUMN)):
|
||||||
|
tmpRead = GPIO.input(self.COLUMN[j])
|
||||||
|
if tmpRead == 1:
|
||||||
|
colVal=j
|
||||||
|
|
||||||
|
# if colVal is not 0 thru 2 then no button was pressed and we can exit
|
||||||
|
if colVal <0 or colVal >2:
|
||||||
|
self.exit()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Return the value of the key pressed
|
||||||
|
self.exit()
|
||||||
|
return self.KEYPAD[rowVal][colVal]
|
||||||
|
|
||||||
|
def exit(self):
|
||||||
|
# Reinitialize all rows and columns as input at exit
|
||||||
|
for i in range(len(self.ROW)):
|
||||||
|
GPIO.setup(self.ROW[i], GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||||
|
for j in range(len(self.COLUMN)):
|
||||||
|
GPIO.setup(self.COLUMN[j], GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Initialize the keypad class
|
||||||
|
kp = keypad()
|
||||||
|
|
||||||
|
# Loop while waiting for a keypress
|
||||||
|
digit = None
|
||||||
|
while digit == None:
|
||||||
|
digit = kp.getKey()
|
||||||
|
|
||||||
|
# Print the result
|
||||||
|
print digit
|