From ee3a6bc9f424d5d9b327d043fb7abd93ada80664 Mon Sep 17 00:00:00 2001
From: poka
Date: Sat, 14 Dec 2019 20:45:36 +0000
Subject: [PATCH 01/26] Lot of changes in .install. Add Kalkun install (not
finish)
---
.gitignore | 3 +-
.install/1-install_requirements.sh | 62 ++++----
.install/2-configure_ipfs_layer.sh | 2 +-
.install/3-install_copylaradio.sh | 33 ++--
.install/4-install_playsms.sh | 140 -----------------
.install/4a-install_kalkun.sh | 98 ++++++++++++
.install/4b-install_playsms.sh | 102 ++++++++++++
.install/ssl.sh | 30 ++--
.install/templates/1/gammu-smsdrc | 34 ++++
.install/templates/{ => 1}/ipfs.service | 0
.install/templates/{ => 3}/mpd.conf | 0
.install/templates/4a/daemon.php | 10 ++
.install/templates/4a/daemon.sh | 8 +
.install/templates/4a/database.php | 58 +++++++
.install/templates/4a/kalkun.conf | 40 +++++
.install/templates/4a/mysql.sql | 192 +++++++++++++++++++++++
.install/templates/{ => 4b}/install-playsms.conf | 0
.install/templates/{ => 4b}/playsms.conf | 4 +-
.install/templates/{ => 5}/default | 0
.install/templates/{ => rproxy}/proxypass.conf | 0
.install/templates/{ => rproxy}/ssl.conf | 0
.install/templates/{ => rproxy}/ssl_renew.sh | 0
GSM_POWERKEY.py => debug/GSM_POWERKEY.py | 0
GSM_powerkey.sh => debug/GSM_powerkey.sh | 0
debug/debugTTY.sh | 19 +++
debug/gammu-loglevel.sh | 13 ++
debug/gammu-restart.sh | 9 ++
install.sh | 15 +-
test.sh => tests/test.sh | 0
29 files changed, 672 insertions(+), 200 deletions(-)
delete mode 100755 .install/4-install_playsms.sh
create mode 100755 .install/4a-install_kalkun.sh
create mode 100755 .install/4b-install_playsms.sh
create mode 100644 .install/templates/1/gammu-smsdrc
rename .install/templates/{ => 1}/ipfs.service (100%)
rename .install/templates/{ => 3}/mpd.conf (100%)
create mode 100755 .install/templates/4a/daemon.php
create mode 100755 .install/templates/4a/daemon.sh
create mode 100644 .install/templates/4a/database.php
create mode 100644 .install/templates/4a/kalkun.conf
create mode 100644 .install/templates/4a/mysql.sql
rename .install/templates/{ => 4b}/install-playsms.conf (100%)
rename .install/templates/{ => 4b}/playsms.conf (94%)
rename .install/templates/{ => 5}/default (100%)
rename .install/templates/{ => rproxy}/proxypass.conf (100%)
rename .install/templates/{ => rproxy}/ssl.conf (100%)
rename .install/templates/{ => rproxy}/ssl_renew.sh (100%)
rename GSM_POWERKEY.py => debug/GSM_POWERKEY.py (100%)
rename GSM_powerkey.sh => debug/GSM_powerkey.sh (100%)
create mode 100755 debug/debugTTY.sh
create mode 100755 debug/gammu-loglevel.sh
create mode 100755 debug/gammu-restart.sh
rename test.sh => tests/test.sh (100%)
diff --git a/.gitignore b/.gitignore
index 183b73d..7c37ee6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
g1sms.bfproject
g1sms.priv.key
shell/init.sh
+shell/init.sh.old
*~
wallets/
shell/trash/
@@ -9,5 +10,5 @@ history.*
TAG/
.install/errors
.install/log
-shell/init.sh.old
+.install/.OS
.profile
diff --git a/.install/1-install_requirements.sh b/.install/1-install_requirements.sh
index 9011077..602d579 100755
--- a/.install/1-install_requirements.sh
+++ b/.install/1-install_requirements.sh
@@ -15,9 +15,9 @@ sudo apt install curl jq zip unzip htop tree ntpdate gnupg ssmtp mpack imagemagi
silkaj() {
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
- pip3 install duniterpy
- pip3 install silkaj --user
+ sudo apt install python3-pip $libsodium -y || err=1
+ pip3 install duniterpy || err=1
+ pip3 install silkaj --user || err=1
}
@@ -25,35 +25,35 @@ silkaj() {
ipfs() {
[[ -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
+ 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=1
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
+ 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=1
fi
echo "INSTALL ipfs-update"
- sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/
+ sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err=1
rm $MY_PATH/ipfs-update.tar.gz
cd /usr/src/ipfs-update/
- sudo ./install.sh
+ sudo ./install.sh || err=1
cd $MY_PATH
echo "INSTALL latest ipfs"
- sudo ipfs-update install latest
+ sudo ipfs-update install latest || err=1
echo "CREATE SYSTEMD ipfs SERVICE"
[[ -f /etc/systemd/system/ipfs.service ]] && sudo rm /etc/systemd/system/ipfs.service
- sudo cp -f $MY_PATH/templates/ipfs.service /etc/systemd/system/
+ 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
- sudo systemctl enable ipfs
+ sudo systemctl daemon-reload || err=1
+ sudo systemctl enable ipfs || err=1
}
# Install gammu
gammu() {
- sudo apt install ppp screen git minicom gammu -y
+ sudo apt install ppp screen git minicom gammu -y || err=1
sleep 1
- sudo apt install gammu-smsd -y || sudo apt install -f
+ sudo apt install gammu-smsd -y || sudo apt install -f || err=1
sudo usermod -aG gammu $USER
}
@@ -61,22 +61,24 @@ gammu() {
# Install PHP + MySQL
php() {
if [[ $OS == "buster" ]]; then
- sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
- sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.liquidtelecom.com/repo/10.4/debian buster main'
- sudo apt -y update
- 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
+ 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=1
elif [[ $OS == "stretch" ]]; then
- sudo apt -y install lsb-release apt-transport-https ca-certificates
- sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
- echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
- sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
- echo -e "deb [arch=amd64,i386,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/debian stretch main\ndeb-src http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/debian stretch main" | sudo tee /etc/apt/sources.list.d/mariadb.list
- sudo apt -y 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
+ sudo apt -y install lsb-release apt-transport-https ca-certificates || err=1
+ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg || err=1
+ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
+ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 || err=1
+ 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=1
else
- echo "${c_red}Votre système n'est pas pris en charge par ce script d'installation.$c_"
- exit 1
+ 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
@@ -85,4 +87,10 @@ for i in $@; do
$i
done
-exit 0
+if [[ $err ]]; then
+ echo -e "${c_red}Installation des prérequis incomplète$c_"
+ exit 1
+else
+ echo -e "${c_green}Les prérequis ont été correctement installés$c_"
+ exit 0
+fi
diff --git a/.install/2-configure_ipfs_layer.sh b/.install/2-configure_ipfs_layer.sh
index b1b3981..0839556 100755
--- a/.install/2-configure_ipfs_layer.sh
+++ b/.install/2-configure_ipfs_layer.sh
@@ -8,7 +8,7 @@
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
stamp=$(date +%s)
-templates="$MY_PATH/templates"
+templates="$MY_PATH/templates/2"
#######################################
# CONFIGURE IPFS for G1sms+ Pi NODES
diff --git a/.install/3-install_copylaradio.sh b/.install/3-install_copylaradio.sh
index b9f72d1..1de3c4f 100755
--- a/.install/3-install_copylaradio.sh
+++ b/.install/3-install_copylaradio.sh
@@ -9,7 +9,7 @@ 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
+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
## TODO FOR DEBIAN STRETCH
@@ -17,20 +17,20 @@ sudo chmod a+rx /usr/local/bin/youtube-dl
wget -q https://ftp-master.debian.org/keys/release-10.asc -O- | sudo apt-key add -
echo "deb http://deb.debian.org/debian buster non-free" | sudo tee -a /etc/apt/sources.list
sudo apt update
-sudo apt install libid3-tools mpd mpc lame -y libttspico-utils -y
+sudo apt install libid3-tools mpd mpc lame -y libttspico-utils -y || err=1
## CONFIG MPD
sudo cp -f $templates/mpd.conf /etc/mpd.conf
-sudo sed -i "s/_USER/$USER/g" /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
+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
-sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y #libav-tools
-sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse atomicparsley -y #libttspico-utils
+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
@@ -41,10 +41,10 @@ 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
-sudo dpkg -i $MY_PATH/libttspico0.deb
-sudo dpkg -i $MY_PATH/libttspico-utils.deb
-sudo dpkg -i $MY_PATH/libav-tools.deb || sudo apt --fix-broken install -y
+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
@@ -52,7 +52,7 @@ rm $MY_PATH/libttspico-data.deb $MY_PATH/libttspico0.deb $MY_PATH/libttspico-uti
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
+sudo systemctl restart nginx || err=1
#################################
## Get _CopyLaRadio distrib
@@ -67,4 +67,11 @@ sudo systemctl restart nginx
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/albumart
#sudo chmod 777 /home/$USER/_CopyLaRadio/www/rompr/prefs
-exit 0
+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
+
diff --git a/.install/4-install_playsms.sh b/.install/4-install_playsms.sh
deleted file mode 100755
index 95c5ea1..0000000
--- a/.install/4-install_playsms.sh
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/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
-
-[[ ! $PSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domain pour playsms: $c_" && read PSMS_DOMAIN
-
-## Install PHP + MySQL
-$MY_PATH/1-install_requirements.sh php
-
-## Create database
-
-if [[ ! $(sudo mysql -e "show databases;" | grep gammu) ]]; then
- sudo mysql -e "CREATE DATABASE gammu"
- sudo mysql -e "CREATE USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
- sudo mysql -e "GRANT ALL PRIVILEGES ON playsms.* TO 'gammu'@'localhost';"
- sudo mysql -e "FLUSH PRIVILEGES;"
-else
- sudo mysql -e "ALTER USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
-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/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/proxypass.conf /etc/nginx/def_conf/
-sudo cp $MY_PATH/templates/playsms.conf /etc/nginx/conf.d/
-sudo sed -i "s/_PSMS_DOMAIN/$PSMS_DOMAIN/" /etc/nginx/conf.d/playsms.conf
-
-## Active SSL
-
-manageSSL() {
-
- local action=$1
- [[ ! $action =~ ^(on|off|certif)$ ]] && echo "Veuillez choisir ssl, nonssl 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@$PSMS_DOMAIN -d $PSMS_DOMAIN && echo "Le certificat de $PSMS_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/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/' /etc/nginx/conf.d/playsms.conf
-
- sudo sed -i "s/listen 443;/listen 443 ssl;/" /etc/nginx/conf.d/playsms.conf
- [[ ! -d /etc/nginx/includes ]] && sudo mkdir /etc/nginx/includes
- sudo cp $MY_PATH/templates/ssl.conf /etc/nginx/includes/
- sudo sed -i "/Content-Security-Policy/a \ include includes/ssl.conf;\n ssl_certificate /etc/letsencrypt/live/$PSMS_DOMAIN/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/$PSMS_DOMAIN/privkey.pem;" /etc/nginx/conf.d/playsms.conf
- ;;
-
- off)
- sudo sed -i 's/ if/ #if/' /etc/nginx/conf.d/playsms.conf
- sudo sed -i '/ssl.conf;/d' /etc/nginx/conf.d/playsms.conf
- sudo sed -i '/ssl_certificate/d' /etc/nginx/conf.d/playsms.conf
- ;;
- certif)
- [[ -z $(which certbot) ]] && install_certbot
- [[ -n /etc/letsencrypt/live/$PSMS_DOMAIN/fullchain.pem ]] && create_certificate
- ;;
-
- esac
-}
-
-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 $PSMS_DOMAIN ? (o/n) $c_" && read askSSL
-if [[ $askSSL =~ ^(o|y|yes|oui|Y|O|YES)$ ]]; then
- manageSSL certif
- if sudo test -f /etc/letsencrypt/live/$PSMS_DOMAIN/fullchain.pem; then manageSSL on; else manageSSL off && echo "Une erreur s'est produite, basculement vers le mode non SSL"; fi
- http=https
-else
- manageSSL off
- http=http
-fi
-
-sudo service nginx restart
-
-[[ ! $err ]] && echo -e "${c_green}Félicitation ! playSMS est accessible via l'URL $http://$PSMS_DOMAIN" || echo -e "${c_red}Installation incomplète$c_"
-
-exit 0
diff --git a/.install/4a-install_kalkun.sh b/.install/4a-install_kalkun.sh
new file mode 100755
index 0000000..7ea5713
--- /dev/null
+++ b/.install/4a-install_kalkun.sh
@@ -0,0 +1,98 @@
+#!/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
+
+IP=$(ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{ print $2 }')
+[[ ! $KSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domaine pour KALKUN (Sinon $IP sera choisi): $c_" && read KSMS_DOMAIN
+[[ ! $KSMS_DOMAIN ]] && KSMS_DOMAIN=$IP && askSSL=n && noask=o
+
+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
+ sudo mysql -e "CREATE DATABASE gammu"
+ sudo mysql -e "GRANT ALL PRIVILEGES ON gammu.* TO 'gammu'@'localhost';"
+ sudo mysql -e "FLUSH PRIVILEGES;"
+fi
+
+[[ ! $(sudo mysql gammu -e "SHOW TABLES LIKE 'outbox';") ]] && sudo mysql gammu < $MY_PATH/templates/4a/mysql.sql || err=1
+
+## Clone repo KALKUN
+
+[[ -d $MY_PATH/kalkun ]] && sudo rm -rf $MY_PATH/kalkun
+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=1
+echo "debug 1"
+sed -i "s/_DOMAIN/$DOMAIN/g" $MY_PATH/templates/4a/daemon.php || err=1
+
+## 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=1
+sudo chown -R www-data:www-data /var/www/kalkun || err=1
+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
+ sudo sed -i "/^service = files/a service = sql\ndriver = native_mysql\nhost = localhost\nuser = gammu\npassword = $pwdDB\ndatabase = gammu" /etc/gammu-smsdrc || err=1
+ sudo sed -i "/service = files/d" /etc/gammu-smsdrc || err=1
+ $MY_PATH/../debug/gammu-restart.sh || 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/ || err=1
+sudo cp $MY_PATH/templates/4a/kalkun.conf /etc/nginx/conf.d/ || err=1
+sudo sed -i "s/_DOMAIN/$DOMAIN/g" /etc/nginx/conf.d/kalkun.conf || err=1
+
+## 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
+ $MY_PATH/ssl.sh certif APP=kalkun DOMAIN=$DOMAIN || err=1
+ if sudo test -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then
+ $MY_PATH/ssl.sh on APP=kalkun DOMAIN=$DOMAIN || err=1
+ 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=1
+ fi
+ http=https
+ sudo sed -i "s/http/https/g" /var/www/kalkun/scripts/daemon.php || err=1
+else
+ $MY_PATH/ssl.sh off APP=kalkun DOMAIN=$DOMAIN || err=1
+ http=http
+fi
+
+sudo service nginx restart || err=1
+
+if [[ $err ]]; then
+ echo -e "${c_red}Installation incomplète$c_"
+ exit 1
+else
+ echo -e "${c_green}Kalkun est accessible via l'URL $http://$DOMAIN$c_"
+ exit 0
+fi
diff --git a/.install/4b-install_playsms.sh b/.install/4b-install_playsms.sh
new file mode 100755
index 0000000..594d638
--- /dev/null
+++ b/.install/4b-install_playsms.sh
@@ -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
+
diff --git a/.install/ssl.sh b/.install/ssl.sh
index 31b95a5..f5d51de 100755
--- a/.install/ssl.sh
+++ b/.install/ssl.sh
@@ -6,7 +6,19 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
### Vars
#DOMAIN=g1sms-blois-2.p2p.legal
args=$@
-[[ "$args" =~ "type=" ]] && DOMAIN=$(echo "$args" | grep "\
diff --git a/.install/templates/4a/daemon.sh b/.install/templates/4a/daemon.sh
new file mode 100755
index 0000000..37cac37
--- /dev/null
+++ b/.install/templates/4a/daemon.sh
@@ -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
diff --git a/.install/templates/4a/database.php b/.install/templates/4a/database.php
new file mode 100644
index 0000000..1b25db5
--- /dev/null
+++ b/.install/templates/4a/database.php
@@ -0,0 +1,58 @@
+ .install/.OS
@@ -88,13 +87,15 @@ fi
repOld=$repOption
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer les modules complémentaires de copylaradio ? (o/n)$c_" && read repOption
-[[ $repOption =~ ^(o|1|yes|options|a|all)$ ]] && .install/3-install_copylaradio.sh; repOption=$repOld
-[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer l'interface web playSMS ? (o/n)$c_" && read repOption
-[[ $repOption =~ ^(o|1|yes|options|a|all)$ ]] && .install/4-install_playsms.sh; repOption=$repOld
+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 n'est mal déroulé =($c_"
+ echo -e "---\n${c_red}L'installation générale n'est mal déroulé =($c_"
else
- echo -e "---\n${c_green}L'installation de votre noeud G1SMS est terminé !\nBienvenue à bord =)$c_"
+ 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
diff --git a/test.sh b/tests/test.sh
similarity index 100%
rename from test.sh
rename to tests/test.sh
From 7b18a29c7050541e7bef36bbe6ad6250bac751b9 Mon Sep 17 00:00:00 2001
From: poka
Date: Sun, 15 Dec 2019 01:55:15 +0000
Subject: [PATCH 02/26] Improve error management in install. Finish Kalkun
install OK
---
.install/1-install_requirements.sh | 42 +++--
.install/3-install_copylaradio.sh | 2 +-
.install/4a-install_kalkun.sh | 57 ++++---
.install/ssl.sh | 18 +-
.install/templates/{5 => 3}/default | 0
.install/templates/4a/kalkun.sql | 331 ++++++++++++++++++++++++++++++++++++
.install/templates/4a/mysql.sql | 12 --
install.sh | 17 +-
8 files changed, 410 insertions(+), 69 deletions(-)
rename .install/templates/{5 => 3}/default (100%)
create mode 100644 .install/templates/4a/kalkun.sql
diff --git a/.install/1-install_requirements.sh b/.install/1-install_requirements.sh
index 602d579..6db0560 100755
--- a/.install/1-install_requirements.sh
+++ b/.install/1-install_requirements.sh
@@ -5,70 +5,76 @@ 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 -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=1
- pip3 install duniterpy || err=1
- pip3 install silkaj --user || err=1
+ 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=1
+ 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=1
+ 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=1
+ 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=1
+ sudo ./install.sh || err+="Install ipfs-update"
cd $MY_PATH
echo "INSTALL latest ipfs"
- sudo ipfs-update install latest || err=1
+ 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=1
- sudo systemctl enable ipfs || err=1
+ sudo systemctl daemon-reload || err+="Restart IPFS"
+ sudo systemctl enable ipfs || err+="Enable IPFS daemon"
}
# Install gammu
gammu() {
- sudo apt install ppp screen git minicom gammu -y || err=1
+ echo -e "${c_yellow}Installation de gammu...$c_"
+ sudo apt install ppp screen git minicom gammu -y || err+="Install gammu requirements"
sleep 1
- sudo apt install gammu-smsd -y || sudo apt install -f || err=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=1
+ 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=1
- sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg || err=1
+ 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-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 || err=1
+ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 || err+="Download PHP key"
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=1
+ 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
@@ -88,7 +94,7 @@ for i in $@; do
done
if [[ $err ]]; then
- echo -e "${c_red}Installation des prérequis incomplète$c_"
+ 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_"
diff --git a/.install/3-install_copylaradio.sh b/.install/3-install_copylaradio.sh
index 1de3c4f..e45c776 100755
--- a/.install/3-install_copylaradio.sh
+++ b/.install/3-install_copylaradio.sh
@@ -2,7 +2,7 @@
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
-templates="$MY_PATH/templates"
+templates="$MY_PATH/templates/3"
isARM=$(cat $MY_PATH/.OS | grep YES)
diff --git a/.install/4a-install_kalkun.sh b/.install/4a-install_kalkun.sh
index 7ea5713..15f4872 100755
--- a/.install/4a-install_kalkun.sh
+++ b/.install/4a-install_kalkun.sh
@@ -19,7 +19,6 @@ DOMAIN=$KSMS_DOMAIN
$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
@@ -28,28 +27,37 @@ else
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
-
-[[ ! $(sudo mysql gammu -e "SHOW TABLES LIKE 'outbox';") ]] && sudo mysql gammu < $MY_PATH/templates/4a/mysql.sql || err=1
+if [[ -z $(sudo mysql gammu -e "SHOW TABLES LIKE 'outbox';") ]]; then
+ echo -e "${c_yellow}Importation du dump gammu...$c_"
+ sudo mysql gammu < $MY_PATH/templates/4a/mysql.sql || err+="Import dump MySQL"
+fi
+if [[ -z $(sudo mysql gammu -e "SHOW TABLES LIKE 'kalkun';") ]]; then
+ echo -e "${c_yellow}Importation du dump kalkun...$c_"
+ 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=1
-echo "debug 1"
-sed -i "s/_DOMAIN/$DOMAIN/g" $MY_PATH/templates/4a/daemon.php || err=1
+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"
+
+# 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=1
-sudo chown -R www-data:www-data /var/www/kalkun || err=1
+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
@@ -57,40 +65,47 @@ sudo chmod u+x /var/www/kalkun/scripts/*
## Active gammu in MySQL mode
if [[ $(grep "service = files" /etc/gammu-smsdrc) ]]; then
- sudo sed -i "/^service = files/a service = sql\ndriver = native_mysql\nhost = localhost\nuser = gammu\npassword = $pwdDB\ndatabase = gammu" /etc/gammu-smsdrc || err=1
- sudo sed -i "/service = files/d" /etc/gammu-smsdrc || err=1
- $MY_PATH/../debug/gammu-restart.sh || err=1
+ 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=1
-sudo cp $MY_PATH/templates/4a/kalkun.conf /etc/nginx/conf.d/ || err=1
-sudo sed -i "s/_DOMAIN/$DOMAIN/g" /etc/nginx/conf.d/kalkun.conf || err=1
+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
- $MY_PATH/ssl.sh certif APP=kalkun DOMAIN=$DOMAIN || err=1
+ 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=1
+ $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=1
+ $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=1
+ 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=1
+ $MY_PATH/ssl.sh off APP=kalkun DOMAIN=$DOMAIN || err+="Disable SSL certification"
http=http
fi
-sudo service nginx restart || err=1
+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$c_"
+ echo -e "${c_red}Installation incomplète: $err$c_"
exit 1
else
echo -e "${c_green}Kalkun est accessible via l'URL $http://$DOMAIN$c_"
diff --git a/.install/ssl.sh b/.install/ssl.sh
index f5d51de..84ea3aa 100755
--- a/.install/ssl.sh
+++ b/.install/ssl.sh
@@ -4,8 +4,8 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
### Vars
-#DOMAIN=g1sms-blois-2.p2p.legal
-args=$@
+args=$(echo $@ | tr " " "\n")
+
if [[ "$args" =~ "DOMAIN=" ]]; then
DOMAIN=$(echo "$args" | grep "\
Date: Sun, 15 Dec 2019 23:24:16 +0000
Subject: [PATCH 03/26] Add wvdial to requirements
---
.install/1-install_requirements.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.install/1-install_requirements.sh b/.install/1-install_requirements.sh
index bb13f9b..b3642a4 100755
--- a/.install/1-install_requirements.sh
+++ b/.install/1-install_requirements.sh
@@ -54,7 +54,7 @@ ipfs() {
# Install gammu
gammu() {
echo -e "${c_yellow}Installation de gammu...$c_"
- sudo apt install ppp screen git minicom gammu -y || err+="Install gammu requirements"
+ 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"
From 8647b941d6eda5c18ecdfedcd72501d8c6844585 Mon Sep 17 00:00:00 2001
From: poka
Date: Sun, 15 Dec 2019 23:27:06 +0000
Subject: [PATCH 04/26] Add kalkun script exectution if exist iin
sms_received.sh
---
sms_received.sh | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/sms_received.sh b/sms_received.sh
index 7ad4f64..2b4b461 100755
--- a/sms_received.sh
+++ b/sms_received.sh
@@ -6,7 +6,7 @@
#
# G1sms+ est totalement décentralisé! Il peut être fait de multiples SWARM de Services dont les codes évoluent de façon décentralisé.
# Puis se mettent à jour autour des $ADMINPHONE par consensus d'utilisateurs ;)
-#
+#
# Log => tail -f /tmp/g1sms.log -n 200
# gammu => tail -f /tmp/smsd.log -n 200
#
@@ -16,16 +16,20 @@
#
# Utiliser la commande ./search fournie pour fouiller dans le code, mais tout est ordonnancé d'ici, donc vous êtes au bon endroit pour commencer à farfouiller.
###############################################################################
-# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE
+# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE
# PHYSIQUE ET INFORMATIQUE DE VOTRE NOEUD ET NE PAS INTRODUIRE DE CODE MALVEILLANT
# DANS LE GROUPE SI VOUS ETES AMENES A EN PROPOSER UNE MISE A JOUR.
-# UNE COMMISSION EST PERCU SUR CERTAINS TRANSFERTS.
+# UNE COMMISSION EST PERCU SUR CERTAINS TRANSFERTS.
# ELLE EST PROVISION EN CAS DE FRAUDE ET SA REATRIBUTION POURRA EVOLUER...
#
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: GPL (http://www.google.com/search?q=GPL)
################################################################################
+
+# Execute Kalkun daemon
+[[ -f /var/www/kalkun/scripts/daemon.sh ]] && /var/www/kalkun/scripts/daemon.sh
+
export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
export CHEMIN="/home/$YOU/G1sms+"
cd $CHEMIN
@@ -55,7 +59,7 @@ log "#############################################"
security
##################################################################
-# Refresh All peers SWARM Wallets.
+# Refresh All peers SWARM Wallets.
##################################################################
ipfs_swarm_wallets_refresh
@@ -109,9 +113,9 @@ case "$CMD" in
else
./shell/sms_ERROR.sh "$PHONE" "ex:: VIR 100 mot5678 = Envoyer 100 $UNIT au portefeuille G1sms+ 'mot5678' (On peut aussi utiliser le pseudo d'un Membre)" &
fi
- ;;
+ ;;
REC)
- # ex: "REC 2000 John J 12" (Virer 2000 UNIT au G1sms+ wallet de John pour les 12 prochains jours)
+ # ex: "REC 2000 John J 12" (Virer 2000 UNIT au G1sms+ wallet de John pour les 12 prochains jours)
AMOUNT=$(echo "$TEXT" | awk '{print $2}' | grep -E "^\-?[0-9]+$")
VIRDEST=$(echo "$TEXT" | awk '{print $3}' | grep -E "([A-Za-z0-9\-\_]+$)")
PERIOD=$(echo "$TEXT" | awk '{print toupper($4)}' | grep -E "([A-Za-z0-9\-\_]+$)")
@@ -119,7 +123,7 @@ case "$CMD" in
if [[ "$VIRDEST" != "" && "$AMOUNT" != "" && "$PERIOD" != "" && "$TIME" != "" ]]; then
./shell/sms_REC.sh "$PHONE" "$VIRDEST" "$AMOUNT" "$PERIOD" "$TIME" &
else
- ./shell/sms_ERROR.sh "$PHONE" "ex:: REC 20 Fred M 12 => Virer 20 $UNIT au portefeuille G1sms+ de Fred pendant 12 Mois (Choisir la période: J,S,M,A)." &
+ ./shell/sms_ERROR.sh "$PHONE" "ex:: REC 20 Fred M 12 => Virer 20 $UNIT au portefeuille G1sms+ de Fred pendant 12 Mois (Choisir la période: J,S,M,A)." &
fi
;;
C|S|SOLDE)
@@ -165,7 +169,7 @@ case "$CMD" in
if [[ "$VAL" != "" ]]; then
./shell/sms_G1TAG.sh "$PHONE" "$VAL" "$NUM" &
else
- ./shell/sms_ERROR.sh "$PHONE" "ex:: TAG 2 12 => Créer 12 G1Tag de 2 G1" &
+ ./shell/sms_ERROR.sh "$PHONE" "ex:: TAG 2 12 => Créer 12 G1Tag de 2 G1" &
fi
;;
U|UNIT)
@@ -189,7 +193,7 @@ case "$CMD" in
exit
;;
ADMIN)
- # If Phone is ADMIN
+ # If Phone is ADMIN
if [[ "$PHONE" == "$ADMINPHONE" ]]; then
CMD=$(echo "$TEXT" | awk '{print toupper($2)}')
PARAM=$(echo "$TEXT" | awk '{print substr($0,index($0,$3))}')
From 975963b9b6577b6c44d7036b0e5bafd5410c2ae3 Mon Sep 17 00:00:00 2001
From: qo-op
Date: Tue, 17 Dec 2019 11:51:13 +0100
Subject: [PATCH 05/26] Tag Reader G1Tx
---
_chain | 2 +-
_comments | 1 +
_nanodate | 2 +-
_publishkey.gpg | Bin 1288 -> 1288 bytes
shell/functions.sh | 5 +-
shell/init.sh.old | 79 +++++++++++++++++++++++++++++++
shell/sms_G1TAG.sh | 27 ++++++-----
shell/tag_OP.sh | 4 +-
shell/tag_READ_X.sh | 55 +++++++++++++--------
shell/tools/G1_TUX_keygen.py | 0
shell/tools/G1_TUX_natools.py | 0
shell/tools/G1_request_cesium_profile.py | 0
shell/tools/matrixKeypad.py | 2 +-
shell/tools/matrixKeypad_RPi_GPIO.pyc | Bin
14 files changed, 137 insertions(+), 40 deletions(-)
create mode 100755 shell/init.sh.old
mode change 100644 => 100755 shell/tools/G1_TUX_keygen.py
mode change 100644 => 100755 shell/tools/G1_TUX_natools.py
mode change 100644 => 100755 shell/tools/G1_request_cesium_profile.py
mode change 100644 => 100755 shell/tools/matrixKeypad_RPi_GPIO.pyc
diff --git a/_chain b/_chain
index 33d4fcc..c021b22 100755
--- a/_chain
+++ b/_chain
@@ -1 +1 @@
-Qmad8nh1sLJJS8UtyXQJ2GzYrv768dDsBfwhtFyBjXh8Z3
+QmRd3LFiGbA8s17vsYdwWftSnEnnEQGzAzCEPbJBLDrXEf
diff --git a/_comments b/_comments
index 9cc3739..d7fd648 100755
--- a/_comments
+++ b/_comments
@@ -172,3 +172,4 @@ OK
2019-12-14: COMMENT
2019-12-14:
2019-12-14:
+2019-12-17: Better G1Tx
diff --git a/_nanodate b/_nanodate
index d0acc79..ae44054 100755
--- a/_nanodate
+++ b/_nanodate
@@ -1 +1 @@
-1576284752579254475
+1576547374550330601
diff --git a/_publishkey.gpg b/_publishkey.gpg
index 8927cc32575f599cf1239609f08309603c3c6fc6..9e229543f35e4b8b1aaf9a92855f6bae87534489 100755
GIT binary patch
literal 1288
zcmV+j1^4=l4Fm}T0;bIgR`ao^9>CJ-0Se*$|7I8|a0Hmuj0#JKn7nH4RnrA`24H#5LIEaIipL^Q^2;VAUAt
z@Q_xfe4>#BMQwW;pE|;NHr_$zHBBnbd|;pafQ^MO^rbNWu#<9hVVzVjkhkQuti88W
zSYQ-`#OdE?F3C;kls^qAL|u@!al@_xK6HZvCG|~J%{hK~Hw!FnGX6tlLCbb-cphX<
zySwJ%LoR01AG)OnjIGemk6iDtUCXa5>Z>S+v;JF!YOw$RB8zW(ox#}u@*FW3LO8j$f}RmZzZ
zN_r{W_{uR_$ekb`o`ag6`YCSkilq6wD|>b!#PjwWDqBx2&(gbOS#t5)<5}@Yd*oBKnJ(b_!V!kbuGE4i{gOu)q4j_>Qn5Qyf^8`K$wvOoA3Iv(8|wcn@T3dOD(b<
z2GyVa4M-o}U;$4{<7V7C!Ooesd-kaT5kGOFYxg^Js2nM;xe?@>BM{7?Waf-ub+nB`cT(x2Z$iCi6WF6@hU5u5u3J*{y*u}UYEPtRFz31RvZt3W_$a~|$-s0%AedTu%Q3cd
z>4@U%B02j~%M?m;;a`Q`J+75%=Ku{jpr_vbx1!k2UTf66Qmkr=mW={dY;>-3l&Im0
z4EaA{DMyD_IeH?)3`ji?2uQpm?3_OK)IBJ%??Lsj$?-I)QJSTmycAQA@)M7GyhMmM
z8?bx%$cIrG=?e%&_5BWKL?;S6Z2H%VbedfLd1DsR3@+Z-2n5%gESl1j1LT?1Tv!wO+o?ooi%S_$s@V=pqI@
zS(7CF5kv(+N=$IIj;S4
yLAzZG%Ncj^3LrtdKCE+wfEV967QKu*+66{P!;KiSaUE@Q(_@~S5bdw|)Zp
zohX7+Oldp=hS`ie3$5X=xjS5`1&K;snAk5?x(3qVkW95ieBDSd-f7cR*Q4c+#yPvX
z+M#=b!b6uvI)tt4({PqLCHBX8N%EX@vWMaH6FQO1kmJoK&@C*;tK)zoy0?$Yt7w6h;HXj(+ZT~fFE116La7t@gcZIG)7RD^lSF0&ZL?UIEl
zZhvjP7{9z&9_wqmZu=)GX*0iUI81FJJOGY-`EJF2ve`fNXr!F}nr7>=!5B_CCUIZx
zD?!+l=jla{MjW^npADhf*59u`%TIGpd!OzC2eUBSA>hI8-V$$e(|)V}6~vl;fr{9o
z>Ixk8QX>{29Jp{@3v_WI(naFZL#&+)6u3ak?-hd@whqRrtu4Z`F1yYJe)`SGTZ}oH
z$ga1OE6u?maxyD0>v>AyZX?)%-oo#}MBAC6YScpsKe^eP1@U@VKTijY`$`eJ)14yk
zRQnr;ih7vk%+SnU#qYttdK$8|%7oTECdDyPwHE;9*}&mW-Yhcih|vVLCQqAz%Iqa
zN`fBbY|boZz%}85FskzKldD*o(El=0+8aX}iAaLEz)w1Wf&^-O9FbPASclp@4pKu=w{b;Yk> /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 aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
+ export CHEMIN="/home/$YOU/G1sms+"
+ cd $CHEMIN
+ ##################################################################
+ # 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="+33651136520"
+ export ADRESSE="G1_Fablab_Toulouse"
+ export G1DAB="NO"
+ ##################################################################
+ # ADMIN COMMAND PHONE ORIGIN
+ export ADMINPHONE="+33647683646"
+ export ADMINPSEUDO="Fred"
+ ##################################################################
+ # DUNITER/CESIUM+ DEFAULT SERVERS
+ export DUNITER="https://g1.duniter.org"
+ export CESIUM="https://g1.data.le-sou.org"
+
+ # TODO Use latest Silkaj from "sudo fredp3 install silkaj"
+ # export SILKAJ="/usr/local/bin/silkaj"
+ source $CHEMIN/shell/init_keys.sh
+
diff --git a/shell/sms_G1TAG.sh b/shell/sms_G1TAG.sh
index 2951d25..e022f48 100755
--- a/shell/sms_G1TAG.sh
+++ b/shell/sms_G1TAG.sh
@@ -49,11 +49,11 @@ if [[ $UNKNOWN == "unknown" ]]; then
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
+#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
@@ -115,16 +115,19 @@ log "__SUB:sms_G1TAG.sh: CREATE $NUMBER x $2 $UNIT G1Tag(s) for $MEMBER ($PHONE)
c=0
while [[ $c -lt $NUMBER ]]; do
((c++))
- # Create Unique SWARM G1tag!
- AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g ); PR=$(echo ${AA} | cut -d ' ' -f 1 );
- while [ -d "./wallets_swarm/TAG/${RR}" ]; do
- AA=$(./shell/diceware.sh 6 | xargs);
- RR=$(echo ${AA} | sed s/\ //g );
+ # Nom du G1Tag imprimé du le QRCode RJ
+ AA=$(./shell/diceware.sh 6 | xargs); # Nom = Diceware de 6 mots
+ RR=$(echo ${AA} | sed s/\ //g ); # Nom concaténé
+ PR=$(echo ${AA} | cut -d ' ' -f 1 ); # Prénom du G1Tag
+ # Create Unique G1tag!
+ while [[ $(ls "./wallets_swarm/.Qm*/TAG/${RR}") ]]; do
+ AA=$(./shell/diceware.sh 6 | xargs); RR=$(echo ${AA} | sed s/\ //g ); PR=$(echo ${AA} | cut -d ' ' -f 1 );
done
+ # Clef de chiffrage PGP imprimée sur le QRCode BJ
BB=$(date +%N | sha256sum | base64 | head -c 32) #YjY4MDc3OTVjNmUxN2JhYWVjYmU3MDcy
# 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)
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
@@ -153,7 +156,7 @@ TAGCHAIN="./TAG/${RR}/TAG_chain" # contains IPFS current ipfs hash
####################################################
# 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 "0" > "$TAGN"
echo "${NANODATE}" > "$TAGDATE"
diff --git a/shell/tag_OP.sh b/shell/tag_OP.sh
index 4a47744..a7075de 100755
--- a/shell/tag_OP.sh
+++ b/shell/tag_OP.sh
@@ -69,7 +69,7 @@ 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
./shell/natools.py decrypt -k "$KEYFILE" -i "$JSOURCEPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JSOURCERR"
else
- if [[ ! -f $KEYFILE ]] then
+ 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
@@ -90,7 +90,7 @@ FINALDEST=$(echo "${JDESTVALUE} + ${VALUE}" | bc -l)
if [[ -f $KEYFILE && ! -f "/home/$YOU/.ipfs/keystore/$JDESTRR" ]]; then
./shell/natools.py decrypt -k "$KEYFILE" -i "$JDESTPUBLISHKEY" -o "/home/$YOU/.ipfs/keystore/$JDESTRR"
else
- if [[ ! -f $KEYFILE ]] then
+ 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
diff --git a/shell/tag_READ_X.sh b/shell/tag_READ_X.sh
index 5e101c5..538939c 100755
--- a/shell/tag_READ_X.sh
+++ b/shell/tag_READ_X.sh
@@ -27,14 +27,16 @@ if [ ! -f $MASTERKEYFILE ]; then echo "ERREUR CLEF DECHIFFRAGE!"; exit; fi
# DOUCHETTE ES TU LA?
if [ ! $G1TX ]; then echo "Branchez votre lecteur de QR code!"; exit; fi
./shell/tools/4LETTER.scroll.py "G1TX START"
-./shell/timeout.sh -t 2 ./shell/tools/4LETTER.spinner.py
-
+./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)
@@ -55,7 +57,7 @@ cat /dev/ttyACM0 | while read line; do
FID=$(echo $ID | awk '{print toupper($1)}')
RR=$(echo $ID | sed s/\ //g)
- ./shell/tools/4LETTER.scroll.py "G1TAG $FID READ"
+ ./shell/tools/4LETTER.scroll.py "G1TAG $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)}')
if [[ "$CURRENCY" == "zen" ]]; then CUR="zène"; else CUR=$CURRENCY; fi # Correction du défaut de prononciation.
@@ -65,7 +67,7 @@ cat /dev/ttyACM0 | while read line; do
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 *** $RVALUE ZEN"
+ ./shell/tools/4LETTER.scroll.py "$RVALUE ZEN *** $G1VAL G1"
fi
cmd="RJ"
CASHBACK=""
@@ -85,7 +87,7 @@ cat /dev/ttyACM0 | while read line; do
FID=$(echo $ID | awk '{print toupper($1)}')
RR=$(echo $ID | sed s/\ //g)
- ./shell/tools/4LETTER.scroll.py "G1TAG $FID >>TX>> "
+ ./shell/tools/4LETTER.scroll.py "G1TAG [TX] $FID >"
BVALUE=$(su $YOU -c "ipfs cat /ipns/$J/TAG_amount")
CURRENCY=$(su $YOU -c "ipfs cat /ipns/$J/TAG_currency" | awk '{print tolower($1)}')
if [[ "$CURRENCY" == "zen" ]]; then CUR="zène"; else CUR=$CURRENCY; fi # Correction du défaut de prononciation.
@@ -110,8 +112,9 @@ cat /dev/ttyACM0 | while read line; do
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 *** $BVALUE ZEN MAX"
+ ./shell/tools/4LETTER.scroll.py "$BVALUE ZEN *** $G1VAL G1 MAX"
fi
cmd="BJ"
val+=("$BVALUE")
@@ -132,21 +135,21 @@ cat /dev/ttyACM0 | while read line; do
cmd="G1"
val+=("$VALUE")
else
- log "__SUB:tag_READ_X.sh: ERREUR QR code illisible. longueur $J = ${#J}"
if [[ "$VALUE" == "" ]]; then
DUNITER=$(./shell/checknodes.sh 'BAN')
- echo "ERREUR TIMEOUT. CHANGE SILKAJ SERVER: $DUNITER"
+ 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 "G1 ${val[0]} / G1 ${val[0]}"
+ ./shell/tools/4LETTER.scroll.py " 2 X "
fi
else
./shell/tools/4LETTER.scroll.py "ERREUR QRCODE INCONNU"
@@ -159,10 +162,12 @@ cat /dev/ttyACM0 | while read line; do
###############################################################
# APRES G1 CASHBACK : G1 Tag BJ WRITE => ENCAISSEMENT
if [[ "${cmd}" == "BJ" && "$CASHBACK" != "" && -f /home/$YOU/.ipfs/keystore/${RR} ]]; then
- ./shell/tools/4LETTER.scroll.py "ENCAISSEMENT G1TAG"
+ ./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.scroll.py "VERS PORTEFEUILLE G1"
+ ./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"
@@ -173,16 +178,19 @@ cat /dev/ttyACM0 | while read line; do
# Make Silkaj TX
G1VAL=$(bc -l <<< "scale=2; $BVALUE / 100" | cut -d '.' -f 1)
log "__SUB:tag_READ_X.sh: Silkaj TX $MASTERKEYFILE ($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="$MASTERKEYFILE" --amount=$G1VAL --output=$CASHBACK --comment="[G1sms+] G1Tag $RR ZEN -> G1" -y)
log "__SUB:tag_READ_X.sh: Silkaj output = $PAY"
- if [[ "$(echo $PAY | cut -d '|' -f 1)" == "KO" ]]; then
+ # 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"
+ ./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"
@@ -208,7 +216,7 @@ cat /dev/ttyACM0 | while read line; do
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 "${FID} G1TAG VIDE !! DETRUCTION !!"
+ ./shell/tools/4LETTER.scroll.py "DETRUIRE G1TAG ${FID}"
# CLEAN IPFS keystore: remove NOT created NODE keys
SOURCENODEID=$(cat "./TAG/${RR}/TAG_nodeid")
@@ -236,14 +244,17 @@ cat /dev/ttyACM0 | while read line; do
if [[ "$PASSENGER" != "" ]]; then
./shell/tools/4LETTER.scroll.py "IMPOSSIBLE TAG PASSENGER";
else
- # READ KEYBOARD VALUE !!!
- COMBIEN=$(./shell/tools/matrixKeypad.py)
+ ###########################################################
+ # 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} TRANSFERT DE $COMBIEN ZEN"
- log "__SUB:tag_READ_X.sh: $(./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIEN $MASTERKEYFILE)"
+ ./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 $MASTERKEYFILE"
+ ./shell/tag_OP.sh ${obj[1]} ${obj[0]} $COMBIENZEN "$MASTERKEYFILE"
else
- ./shell/tools/4LETTER.scroll.py "$COMBIEN DEPASSE ${val[1]} $CUR DU G1TAG ${FID}"
+ ./shell/tools/4LETTER.scroll.py "ERREUR $COMBIEN > VALEUR DE ${FID} *** ${val[1]} ZEN"
fi
fi
CASHBACK=""
@@ -265,9 +276,11 @@ cat /dev/ttyACM0 | while read line; do
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
diff --git a/shell/tools/G1_TUX_keygen.py b/shell/tools/G1_TUX_keygen.py
old mode 100644
new mode 100755
diff --git a/shell/tools/G1_TUX_natools.py b/shell/tools/G1_TUX_natools.py
old mode 100644
new mode 100755
diff --git a/shell/tools/G1_request_cesium_profile.py b/shell/tools/G1_request_cesium_profile.py
old mode 100644
new mode 100755
diff --git a/shell/tools/matrixKeypad.py b/shell/tools/matrixKeypad.py
index 492de43..ba1c3d4 100755
--- a/shell/tools/matrixKeypad.py
+++ b/shell/tools/matrixKeypad.py
@@ -6,7 +6,7 @@ from time import sleep
# Initialize the keypad class
kp = keypad()
-fourletterphat.print_str("ZEN?")
+fourletterphat.print_str(" G1?")
fourletterphat.show()
def digit():
diff --git a/shell/tools/matrixKeypad_RPi_GPIO.pyc b/shell/tools/matrixKeypad_RPi_GPIO.pyc
old mode 100644
new mode 100755
From 014634e84077e99468d216c420e6a794b386c5ae Mon Sep 17 00:00:00 2001
From: qo-op
Date: Tue, 17 Dec 2019 17:22:06 +0100
Subject: [PATCH 06/26] TAG REFRESH
---
shell/cron_G1TAG_REFRESH.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++
shell/cron_MINUTE.sh | 33 ++----------------
shell/init_keys.sh | 2 +-
3 files changed, 86 insertions(+), 32 deletions(-)
create mode 100755 shell/cron_G1TAG_REFRESH.sh
diff --git a/shell/cron_G1TAG_REFRESH.sh b/shell/cron_G1TAG_REFRESH.sh
new file mode 100755
index 0000000..debb381
--- /dev/null
+++ b/shell/cron_G1TAG_REFRESH.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='\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=$(./shell/timeout.sh -t 8 su $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 "$MASTERKEYFILE" -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}"
+
+ # 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
+##################################################################
diff --git a/shell/cron_MINUTE.sh b/shell/cron_MINUTE.sh
index 9e0ffe1..483b68f 100755
--- a/shell/cron_MINUTE.sh
+++ b/shell/cron_MINUTE.sh
@@ -26,7 +26,7 @@ if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installat
ipfs_swarm_wallets_refresh "SIMPLE"
################################################################################
-# PRINT G1Tag
+# PRINT G1Tag PRINTED FROM ANOTHER NODE
# CREATE and REMOVE rr.bin -> done.rr
if [[ -d "./wallets_swarm/.$IPFSNODEID/PRINT/" ]]; then
log "__SUB:cron_MINUTE.sh: SEARCH NEW PRINT FOR ME .$IPFSNODEID"
@@ -74,36 +74,7 @@ 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 3 in the morning, or in the night? It depends on your day..."
fi
##################################################################
diff --git a/shell/init_keys.sh b/shell/init_keys.sh
index 515692f..67210aa 100755
--- a/shell/init_keys.sh
+++ b/shell/init_keys.sh
@@ -47,7 +47,7 @@ if [[ -f ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate ]]; then
last=$(cat ./wallets/.$IPFSNODEID/$IPFSNODEID.nanodate)
timediff=$( echo "${NANODATE} - ${last}" | bc -l )
# Get median nanodate before
- # NODE TIME SYNC 120 milliards de nanosecondes
+ # NODE TIME SYNC 120 milliards de nanosecondes = 120s
if [[ $timediff -gt 120000000000 ]]; then
log "__SUB:ntpdate pool.ntp.org: $timediff $(ntpdate pool.ntp.org)"
export NANODATE=$(date -u +%s%N)
From c03a3245d6cac7786859c010e85ad04cb00be119 Mon Sep 17 00:00:00 2001
From: poka
Date: Tue, 17 Dec 2019 20:02:40 +0100
Subject: [PATCH 07/26] Add contact to database when wallet is created. Remove
contact from database where wellet is destroyed
---
debug/GSM_POWERKEY.py => GSM_POWERKEY.py | 0
debug/GSM_powerkey.sh => GSM_powerkey.sh | 0
shell/functions.sh | 42 ++++++++++++++++++++++++++++++++
shell/sms_DESTROY.sh | 15 +++++++-----
shell/sms_NEW.sh | 12 +++++----
5 files changed, 58 insertions(+), 11 deletions(-)
rename debug/GSM_POWERKEY.py => GSM_POWERKEY.py (100%)
rename debug/GSM_powerkey.sh => GSM_powerkey.sh (100%)
diff --git a/debug/GSM_POWERKEY.py b/GSM_POWERKEY.py
similarity index 100%
rename from debug/GSM_POWERKEY.py
rename to GSM_POWERKEY.py
diff --git a/debug/GSM_powerkey.sh b/GSM_powerkey.sh
similarity index 100%
rename from debug/GSM_powerkey.sh
rename to GSM_powerkey.sh
diff --git a/shell/functions.sh b/shell/functions.sh
index 4e00c34..7fc456d 100755
--- a/shell/functions.sh
+++ b/shell/functions.sh
@@ -614,3 +614,45 @@ function move_g1cents (){
# UPDATE MY new ./wallet STATUS to SWARM
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 -u$userDB -p$pwdDB gammu -e"
+
+ local MEMBERUID=$1
+ local PHONE=$2
+
+ local reqPhoneExist="SELECT * FROM pbk WHERE Number=$PHONE"
+
+ if [[ -z $($sql "$reqPhoneExist") ]]; then
+ local reqAddContact="INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('-1', '$MEMBERUID', '$PHONE', '1', 'false')"
+ $sql "$reqAddContact" || 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 -u$userDB -p$pwdDB gammu -e"
+
+ local MEMBERUID=$1
+ local PHONE=$2
+
+ local reqPhoneExist="SELECT * FROM pbk WHERE Number=$PHONE"
+
+ if [[ ! -z $($sql "$reqPhoneExist") ]]; then
+ local reqRmContact="DELETE FROM pbk WHERE Number=$PHONE"
+ $sql "$reqRmContact" || exit 1
+ else
+ log "${red}Contact doesn't exist$c_"
+ fi
+
+}
+
diff --git a/shell/sms_DESTROY.sh b/shell/sms_DESTROY.sh
index 26bdece..372309a 100755
--- a/shell/sms_DESTROY.sh
+++ b/shell/sms_DESTROY.sh
@@ -6,7 +6,7 @@
################################################################################
source ./shell/init.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"
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!"
exit
else
- log "__SUB:sms_DESTROY.sh: VIREMENT $next OK "
+ log "__SUB:sms_DESTROY.sh: VIREMENT $next ${c_green}OK$c_"
fi
done
fi
@@ -50,12 +50,12 @@ if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]
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 : OK"
+ 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 "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ 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
@@ -71,5 +71,8 @@ $back"
sms_SEND "$PHONE" "$mess"
-log "__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+# Remove contact from database
+rm_contact $MEMBERUID $PHONE && log "${c_green}Contact has been deleted from database$c_" || "${c_red}Contact can't be deleted database$c_"
+
+log "${c_yellow}__SUB:sms_DESTROY.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~$c_"
exit
diff --git a/shell/sms_NEW.sh b/shell/sms_NEW.sh
index 1d4949a..d4f637c 100755
--- a/shell/sms_NEW.sh
+++ b/shell/sms_NEW.sh
@@ -6,7 +6,7 @@
################################################################################
source ./shell/init.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"
MEMBERUID="$2"
@@ -15,9 +15,9 @@ MEMBERUID="$2"
sms_INIT_ACCOUNT "$PHONE"
if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then
# UID RECEIVED in SMS
- VIRDEST=$MEMBERUID
+ VIRDEST=$MEMBERUID
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN")
- if [[ $MEMRIB == "" ]]; then exit; fi
+ if [[ $MEMRIB == "" ]]; then exit; fi
MEMBER="$MEMBERUID"
fi
@@ -51,8 +51,10 @@ sleep 2
sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
$MEMRIB"
+# Add contact to database
+add_contact $MEMBERUID $PHONE && log "${c_green}Contact has been added to database$c_" || "${c_red}Contact can't be added to database$c_"
-
-log "END sms_NEW.sh"
+log "${c_yellow}END sms_NEW.sh$c_"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit
+
From 7126c11e04a179974a92a59d295f2525527060ed Mon Sep 17 00:00:00 2001
From: qo-op
Date: Tue, 17 Dec 2019 20:18:49 +0100
Subject: [PATCH 08/26] shell/manual_BILLETS_PERIMES.sh
---
_chain | 2 +-
_comments | 1 +
_nanodate | 2 +-
_publishkey.gpg | Bin 1288 -> 1288 bytes
shell/manual_BILLETS_PERIMES.sh | 2 +-
silkaj/src/constants.py | 2 +-
6 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/_chain b/_chain
index c021b22..493f092 100755
--- a/_chain
+++ b/_chain
@@ -1 +1 @@
-QmRd3LFiGbA8s17vsYdwWftSnEnnEQGzAzCEPbJBLDrXEf
+QmTDcHP1Nqy4SFzYCwuDH3JxvBT7fsdAKWQvrcvsVPMUpD
diff --git a/_comments b/_comments
index d7fd648..c06d6e2 100755
--- a/_comments
+++ b/_comments
@@ -173,3 +173,4 @@ OK
2019-12-14:
2019-12-14:
2019-12-17: Better G1Tx
+2019-12-17: G1TAG REFRESH & more
diff --git a/_nanodate b/_nanodate
index ae44054..a017c9f 100755
--- a/_nanodate
+++ b/_nanodate
@@ -1 +1 @@
-1576547374550330601
+1576604811163661452
diff --git a/_publishkey.gpg b/_publishkey.gpg
index 9e229543f35e4b8b1aaf9a92855f6bae87534489..5a2f3c4d9fcf5296250fbbcbf5ad63ebad4d2c45 100755
GIT binary patch
literal 1288
zcmV+j1^4=l4Fm}T0vYn|A(C*8g}~D40R;;-A-QTEM1{7};D23B=K!*U>~q8&?@xYG
zS>q8n#PFAfz)x)$R+8xCuRISdCMd$Wq>D8cQiC{>VZreo)?ix)ylPykDX1s%Xdf*
znxO##0w;VO?qfKv#_<&08Z9SUN)9^XJWZ$rlin0Co~yurH*C@I;huXV3SMTHF9YRq
zi$fZw$|;oH>jsW(K=nLNTL4&Jv|;f2lAPcKxUV9wSnW>HXx^Crp!UVlEPua);at;>ltX^u
zsdC+|ofFcl$|KsQh>-6$gYIL!I{P$0M8#kR2kSP3m(gA+T;|N+ZFPH!LnM{SBWLW<
z+PCP_j;;{V&ifvf8=58JQwtBZ2mhXZJcF6bze$^wOhHpp1~NS}n$!`oyJ>QwWoTDJ
z!DD>b>J-YFDDB@IoQVww(*oiIp`jEb`V7UJjGdHc)j;m}tN-6w;@+JUoMfnH8E)wU
ztd9Y9(?>BQhwMvs*}vkVXfCnT%KFQ5wM22!9{D~IM&EebDRXg?^
z;~Cr)ifa}zTIqBIq~b-^JVd_Z3=TNV3B{qF;
zCtO*?P{O29X*0IpR|XZD+Nd-BIHxfxzKw9@nBtQ3ad+74iS8W*m1%jCJ@tM<5vtAE3lkn~BN51dsoE`GwrD_WvfmVb
zcXbU?mo*vUz%?;_l3)vC!OJzP{1cPadR^z^s%)R=7#w#X?H%$~OF|WpgAM|+LOcS>
zler)rTTTcxY$FCj<8ORrqJAZN`q}1C1^U(OHO{7zj({oA46_HcO(J&~G8f_LCQ|leqwz-j#E8|_v{u~9SuG+q#Y+Tb@&qIKtd9|}D>2RW`-&AZ-
zna*0NOhq5v{E%~Xv2`{O43zYj
y+RD?|wJyf0{5UL%yDm1}UsG_d@UZjz8PWLofFT0`8~Qt-dkYvY-k>PK@KF0IhIl^!
literal 1288
zcmV+j1^4=l4Fm}T0;bIgR`ao^9>CJ-0Se*$|7I8|a0Hmuj0#JKn7nH4RnrA`24H#5LIEaIipL^Q^2;VAUAt
z@Q_xfe4>#BMQwW;pE|;NHr_$zHBBnbd|;pafQ^MO^rbNWu#<9hVVzVjkhkQuti88W
zSYQ-`#OdE?F3C;kls^qAL|u@!al@_xK6HZvCG|~J%{hK~Hw!FnGX6tlLCbb-cphX<
zySwJ%LoR01AG)OnjIGemk6iDtUCXa5>Z>S+v;JF!YOw$RB8zW(ox#}u@*FW3LO8j$f}RmZzZ
zN_r{W_{uR_$ekb`o`ag6`YCSkilq6wD|>b!#PjwWDqBx2&(gbOS#t5)<5}@Yd*oBKnJ(b_!V!kbuGE4i{gOu)q4j_>Qn5Qyf^8`K$wvOoA3Iv(8|wcn@T3dOD(b<
z2GyVa4M-o}U;$4{<7V7C!Ooesd-kaT5kGOFYxg^Js2nM;xe?@>BM{7?Waf-ub+nB`cT(x2Z$iCi6WF6@hU5u5u3J*{y*u}UYEPtRFz31RvZt3W_$a~|$-s0%AedTu%Q3cd
z>4@U%B02j~%M?m;;a`Q`J+75%=Ku{jpr_vbx1!k2UTf66Qmkr=mW={dY;>-3l&Im0
z4EaA{DMyD_IeH?)3`ji?2uQpm?3_OK)IBJ%??Lsj$?-I)QJSTmycAQA@)M7GyhMmM
z8?bx%$cIrG=?e%&_5BWKL?;S6Z2H%VbedfLd1DsR3@+Z-2n5%gESl1j1LT?1Tv!wO+o?ooi%S_$s@V=pqI@
zS(7CF5kv(+N=$IIj;S4
yL
Date: Wed, 18 Dec 2019 00:54:42 +0100
Subject: [PATCH 09/26] SMS RAZ
---
shell/cron_G1TAG_REFRESH.sh | 2 +-
shell/manual_BILLETS_PERIMES.sh | 2 +-
shell/sms_DESTROY.sh | 22 +++++++++++-----------
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/shell/cron_G1TAG_REFRESH.sh b/shell/cron_G1TAG_REFRESH.sh
index debb381..ff4251d 100755
--- a/shell/cron_G1TAG_REFRESH.sh
+++ b/shell/cron_G1TAG_REFRESH.sh
@@ -45,7 +45,7 @@ for tag in ./wallets/.$IPFSNODEID/TAG/*; do
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)
+ 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"
diff --git a/shell/manual_BILLETS_PERIMES.sh b/shell/manual_BILLETS_PERIMES.sh
index 3961903..8b202c0 100755
--- a/shell/manual_BILLETS_PERIMES.sh
+++ b/shell/manual_BILLETS_PERIMES.sh
@@ -39,7 +39,7 @@ for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do
PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" -y)
if [[ ! $(echo $PAY | grep "successfully sent") ]]; then
- echo "!!!! ERREUR: Something Wrong happened with $result"
+ echo "!!!! ERREUR: $virement Something Wrong happened with $result"
if [[ ! $virement ]]; then mv $result /tmp/$result; fi
else
echo "Tout s'est bien passé! On supprime $result et continue avec le billet $Nbillets"
diff --git a/shell/sms_DESTROY.sh b/shell/sms_DESTROY.sh
index 372309a..01f2142 100755
--- a/shell/sms_DESTROY.sh
+++ b/shell/sms_DESTROY.sh
@@ -43,6 +43,17 @@ if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" && "$PAY" != "" && "$(echo $back | cut -d '|' -f 1)" != "KO" ]]; then
# DESTROY FILESYSTEM AND G1sms WALLET SWARM REFERENCE
if [[ "$PHONE" != "" ]]; then
+# SEND SMS BEFORE DELETE FOLDER
+mess="[G1sms+] $PAY
+Portefeuille détruit!
+Viré vers $MEMBER
+$MEMRIB
+
+Merci, à bientôt.
+$ADMINPSEUDO @ $NODEUIDNA
+$back"
+sms_SEND "$PHONE" "$mess"
+
rm -Rf ./wallets/$PHONE;
rm -Rf ./wallets_swarm/$PHONE;
cents=$(echo $(bc -l <<< "scale=0; $GETLIMIT * 100") | cut -d '.' -f 1)
@@ -60,17 +71,6 @@ if [[ "$MEMBERUID" == "DON" || "$MEMBERUID" == "" || "$MEMBERUID" == "$MEMBER" ]
fi
fi
-mess="[G1sms+] $PAY
-Portefeuille détruit!
-Viré vers $MEMBER
-$MEMRIB
-
-Merci, à bientôt.
-$ADMINPSEUDO @ $NODEUIDNA
-$back"
-
-sms_SEND "$PHONE" "$mess"
-
# Remove contact from database
rm_contact $MEMBERUID $PHONE && log "${c_green}Contact has been deleted from database$c_" || "${c_red}Contact can't be deleted database$c_"
From dd74cff5aa1790da2e78a38c0e6260c87881c58f Mon Sep 17 00:00:00 2001
From: qo-op
Date: Wed, 18 Dec 2019 00:57:15 +0100
Subject: [PATCH 10/26] mysql-stretch.sql
---
.install/templates/4a/mysql-stretch.sql | 227 ++++++++++++++++++++++++++++++++
1 file changed, 227 insertions(+)
create mode 100644 .install/templates/4a/mysql-stretch.sql
diff --git a/.install/templates/4a/mysql-stretch.sql b/.install/templates/4a/mysql-stretch.sql
new file mode 100644
index 0000000..44448af
--- /dev/null
+++ b/.install/templates/4a/mysql-stretch.sql
@@ -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 ;
From a00cfd9e6e4f502aa2599d19f73cde0612e82db5 Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 01:53:42 +0100
Subject: [PATCH 11/26] Fix non SSL for kalkun. Add default contact group. Add
new user in contact group
---
.install/1-install_requirements.sh | 1 -
.install/4a-install_kalkun.sh | 2 ++
.install/ssl.sh | 3 +++
.install/templates/4a/kalkun.conf | 4 +---
.install/templates/4a/kalkun.sql | 17 +++++++++++++----
shell/functions.sh | 2 +-
shell/init.sh.old | 10 +++++-----
shell/sms_DESTROY.sh | 2 +-
shell/sms_NEW.sh | 2 +-
9 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/.install/1-install_requirements.sh b/.install/1-install_requirements.sh
index 91d9ed3..514cf3f 100755
--- a/.install/1-install_requirements.sh
+++ b/.install/1-install_requirements.sh
@@ -70,7 +70,6 @@ php() {
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-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 || err+="Download PHP key"
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
diff --git a/.install/4a-install_kalkun.sh b/.install/4a-install_kalkun.sh
index 15f4872..0fbcec2 100755
--- a/.install/4a-install_kalkun.sh
+++ b/.install/4a-install_kalkun.sh
@@ -38,6 +38,8 @@ if [[ -z $(sudo mysql gammu -e "SHOW TABLES LIKE 'outbox';") ]]; then
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
diff --git a/.install/ssl.sh b/.install/ssl.sh
index 84ea3aa..5dc466f 100755
--- a/.install/ssl.sh
+++ b/.install/ssl.sh
@@ -51,6 +51,7 @@ create_certificate() {
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
@@ -60,6 +61,8 @@ on)
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
;;
diff --git a/.install/templates/4a/kalkun.conf b/.install/templates/4a/kalkun.conf
index 0aa6f72..779ecd2 100644
--- a/.install/templates/4a/kalkun.conf
+++ b/.install/templates/4a/kalkun.conf
@@ -4,9 +4,7 @@ server {
listen [::]:443 ssl;
server_name _DOMAIN;
- add_header Content-Security-Policy upgrade-insecure-requests;
-# add_header 'Access-Control-Allow-Origin' '*';
-
+ #add_header Content-Security-Policy upgrade-insecure-requests;
#if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; }
location / {
diff --git a/.install/templates/4a/kalkun.sql b/.install/templates/4a/kalkun.sql
index 4b665aa..ed090a1 100644
--- a/.install/templates/4a/kalkun.sql
+++ b/.install/templates/4a/kalkun.sql
@@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS `user` (
--
INSERT INTO `user` (`id_user`, `username`, `realname`, `password`, `phone_number`, `level`) VALUES
-(1, 'kalkun', 'Kalkun SMS', 'f0af18413d1c9e0366d8d1273160f55d5efeddfe', '123456789', 'admin');
+(1, 'admin', 'G1Admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', '0600000000', 'admin');
-- --------------------------------------------------------
@@ -147,9 +147,9 @@ CREATE TABLE IF NOT EXISTS `user_settings` (
`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 'english',
+ `language` varchar(20) NOT NULL DEFAULT 'french',
`conversation_sort` enum('asc','desc') NOT NULL DEFAULT 'asc',
- `country_code` varchar(2) NOT NULL DEFAULT 'US',
+ `country_code` varchar(2) NOT NULL DEFAULT 'FR',
PRIMARY KEY (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -158,7 +158,7 @@ CREATE TABLE IF NOT EXISTS `user_settings` (
--
INSERT INTO `user_settings` (`id_user`, `theme`, `signature`, `permanent_delete`, `paging`, `bg_image`, `delivery_report`, `language`, `conversation_sort`) VALUES
-(1, 'green', 'false;--\nPut your signature here', 'false', 20, 'true;background.jpg', 'default' , 'english', 'asc');
+(1, 'green', 'false;--\nVotre signature ici', 'false', 20, 'true;background.jpg', 'default' , 'french', 'asc');
-- --------------------------------------------------------
@@ -329,3 +329,12 @@ CREATE TABLE `ci_sessions` (
`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');
diff --git a/shell/functions.sh b/shell/functions.sh
index 7fc456d..20f82ec 100755
--- a/shell/functions.sh
+++ b/shell/functions.sh
@@ -629,7 +629,7 @@ function add_contact(){
local reqPhoneExist="SELECT * FROM pbk WHERE Number=$PHONE"
if [[ -z $($sql "$reqPhoneExist") ]]; then
- local reqAddContact="INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('-1', '$MEMBERUID', '$PHONE', '1', 'false')"
+ local reqAddContact="INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('1', '$MEMBERUID', '$PHONE', '1', 'false')"
$sql "$reqAddContact" || exit 1
else
log "${red}Contact already exist$c_"
diff --git a/shell/init.sh.old b/shell/init.sh.old
index 47d1f27..65517c1 100755
--- a/shell/init.sh.old
+++ b/shell/init.sh.old
@@ -1,6 +1,6 @@
#!/bin/bash
##################################################################
-# Author: Fred (support@qo-op.com)
+# Author: poka (support@qo-op.com)
# Version: 0.1
# License: GPL (http://www.google.com/search?q=GPL)
##################################################################
@@ -61,13 +61,13 @@ fi
export NODECOMM=10
##################################################################
# SMS SIM Card Phone Number
- export MASTERPHONE="+33651136520"
- export ADRESSE="G1_Fablab_Toulouse"
+ export MASTERPHONE="+3368818767"
+ export ADRESSE="Blois"
export G1DAB="NO"
##################################################################
# ADMIN COMMAND PHONE ORIGIN
- export ADMINPHONE="+33647683646"
- export ADMINPSEUDO="Fred"
+ export ADMINPHONE="+33650573417"
+ export ADMINPSEUDO="poka"
##################################################################
# DUNITER/CESIUM+ DEFAULT SERVERS
export DUNITER="https://g1.duniter.org"
diff --git a/shell/sms_DESTROY.sh b/shell/sms_DESTROY.sh
index 372309a..1f9fec9 100755
--- a/shell/sms_DESTROY.sh
+++ b/shell/sms_DESTROY.sh
@@ -72,7 +72,7 @@ $back"
sms_SEND "$PHONE" "$mess"
# Remove contact from database
-rm_contact $MEMBERUID $PHONE && log "${c_green}Contact has been deleted from database$c_" || "${c_red}Contact can't be deleted database$c_"
+rm_contact $MEMBERUID $PHONE && 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
diff --git a/shell/sms_NEW.sh b/shell/sms_NEW.sh
index d4f637c..04f537a 100755
--- a/shell/sms_NEW.sh
+++ b/shell/sms_NEW.sh
@@ -52,7 +52,7 @@ sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
$MEMRIB"
# Add contact to database
-add_contact $MEMBERUID $PHONE && log "${c_green}Contact has been added to database$c_" || "${c_red}Contact can't be added to database$c_"
+add_contact $MEMBERUID $PHONE && 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 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
From f07f5f994afe7a626cc3a5a849dc9dd89f1988e3 Mon Sep 17 00:00:00 2001
From: qo-op
Date: Wed, 18 Dec 2019 02:31:12 +0100
Subject: [PATCH 12/26] shell/sms_ABO.sh
---
_chain | 2 +-
_comments | 1 +
_nanodate | 2 +-
_publishkey.gpg | Bin 1288 -> 1288 bytes
shell/cron_G1TAG_REFRESH.sh | 2 +-
shell/functions.sh | 4 ++--
shell/sms_ABO.sh | 24 ++++++++++++++++++++----
sms_received.sh | 5 ++---
8 files changed, 28 insertions(+), 12 deletions(-)
mode change 100644 => 100755 shell/sms_ABO.sh
diff --git a/_chain b/_chain
index 493f092..953407d 100755
--- a/_chain
+++ b/_chain
@@ -1 +1 @@
-QmTDcHP1Nqy4SFzYCwuDH3JxvBT7fsdAKWQvrcvsVPMUpD
+QmbRvGMpwZws4ii5xe5x8EgK1SSxNBaNNjinwdWjhye3TR
diff --git a/_comments b/_comments
index c06d6e2..7842c23 100755
--- a/_comments
+++ b/_comments
@@ -174,3 +174,4 @@ OK
2019-12-14:
2019-12-17: Better G1Tx
2019-12-17: G1TAG REFRESH & more
+2019-12-18: RAZ
diff --git a/_nanodate b/_nanodate
index a017c9f..7778f6d 100755
--- a/_nanodate
+++ b/_nanodate
@@ -1 +1 @@
-1576604811163661452
+1576627244479575204
diff --git a/_publishkey.gpg b/_publishkey.gpg
index 5a2f3c4d9fcf5296250fbbcbf5ad63ebad4d2c45..619e3dc50687c359bc2dc032d3aeb90658ecfee3 100755
GIT binary patch
literal 1288
zcmV+j1^4=l4Fm}T0tzl_!_Nv3yui}x0VC1ylAIPxJroN22|@7*|4&J!EX5-P4<7Ty
z#@!yLtP{1+fPga`XURI@?+W_Hn_6i_fz7@`up(-H@u(lK=bwg}2~_EVtS+NfPG=iL
zpI>6EWLk=Z?U1%#_<~qq{UPZr;$tvkfF2%P$cc%*0`Gpksx+#rm(t4**=z*5;7Mq$Ui+)U{{KB^=
zJIhY^ysF&tXr$PwI8LTHzNNrqb$CaB_#|uaHrnR|EVmq4#jdKb?yOv*p=kbfUqACb
zoXtzywvs1`!>zw^wSrg8&oFK0Bzj9=TxE~+kGNAp@BpyD(CH|quuIGz{qx^K@1>W6
zh?%*SX7-5cz}HgX0LB~a=Ul%?wbWIJB-wEa0BLkvzE~|1D38n{3M#Oj1D*5@I0H*f
zv)5{?_aE}MgkH4#fb=aZ5K&Muv)?w-e|j198Mn+Ke(x?-2#!fEtzHSa8t`VWE3gwYSyJn}KeKrTbcaDOT
zVKdDzoq^3@=}o?>jNI&gc}tr$A?hHoyP(hYyJsm!Gr@8A*r&Jb#`k)m!+1whU=UoC
zU;YV3vvay2D*rO-e-r0`uyn*dK5#KSw>Q@=EPrm?K
zh9No25#x@H0G+jBpH*V)?#=eR9=*5q|3OgD%tB@n=l;rg#)=)?kM$++L|CIi}h3mZXQ`&a6t&b>aHxlf?Qq0UzbDuQ{OtoK1_3!Wj=Qvk5j8hjcP@=$5sQf@d8;@G
ztd&?5V`b*Bz%{ncK&MMXO*hK>KDf0h_Z#(X%`lKSs7UVX?93qEO>-gCFBleLwDw%}
zt^87Y*mw(=Dn7gTiyZ|0^0U3J)bcbYzJSw&w0JQ6O0||N=;ix?rk;Vw#7`i8vQE`-
zESK?mi~7STKw%R89}uS6)eRNdxEs~q8&?@xYG
zS>q8n#PFAfz)x)$R+8xCuRISdCMd$Wq>D8cQiC{>VZreo)?ix)ylPykDX1s%Xdf*
znxO##0w;VO?qfKv#_<&08Z9SUN)9^XJWZ$rlin0Co~yurH*C@I;huXV3SMTHF9YRq
zi$fZw$|;oH>jsW(K=nLNTL4&Jv|;f2lAPcKxUV9wSnW>HXx^Crp!UVlEPua);at;>ltX^u
zsdC+|ofFcl$|KsQh>-6$gYIL!I{P$0M8#kR2kSP3m(gA+T;|N+ZFPH!LnM{SBWLW<
z+PCP_j;;{V&ifvf8=58JQwtBZ2mhXZJcF6bze$^wOhHpp1~NS}n$!`oyJ>QwWoTDJ
z!DD>b>J-YFDDB@IoQVww(*oiIp`jEb`V7UJjGdHc)j;m}tN-6w;@+JUoMfnH8E)wU
ztd9Y9(?>BQhwMvs*}vkVXfCnT%KFQ5wM22!9{D~IM&EebDRXg?^
z;~Cr)ifa}zTIqBIq~b-^JVd_Z3=TNV3B{qF;
zCtO*?P{O29X*0IpR|XZD+Nd-BIHxfxzKw9@nBtQ3ad+74iS8W*m1%jCJ@tM<5vtAE3lkn~BN51dsoE`GwrD_WvfmVb
zcXbU?mo*vUz%?;_l3)vC!OJzP{1cPadR^z^s%)R=7#w#X?H%$~OF|WpgAM|+LOcS>
zler)rTTTcxY$FCj<8ORrqJAZN`q}1C1^U(OHO{7zj({oA46_HcO(J&~G8f_LCQ|leqwz-j#E8|_v{u~9SuG+q#Y+Tb@&qIKtd9|}D>2RW`-&AZ-
zna*0NOhq5v{E%~Xv2`{O43zYj
y+RD?|wJyf0{5UL%yDm1}UsG_d@UZjz8PWLofFT0`8~Qt-dkYvY-k>PK@KF0IhIl^!
diff --git a/shell/cron_G1TAG_REFRESH.sh b/shell/cron_G1TAG_REFRESH.sh
index ff4251d..de8eaec 100755
--- a/shell/cron_G1TAG_REFRESH.sh
+++ b/shell/cron_G1TAG_REFRESH.sh
@@ -67,7 +67,7 @@ for tag in ./wallets/.$IPFSNODEID/TAG/*; do
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
diff --git a/shell/functions.sh b/shell/functions.sh
index 20f82ec..7dbb9bf 100755
--- a/shell/functions.sh
+++ b/shell/functions.sh
@@ -116,8 +116,8 @@ if [[ $PHONE ]]; then rm -Rf ./wallets_swarm/$PHONE; fi
su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
count=1
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
-#for id in ./wallets_swarm/.Qm*/;
-for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
+for id in ./wallets_swarm/.Qm*/;
+#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
diff --git a/shell/sms_ABO.sh b/shell/sms_ABO.sh
old mode 100644
new mode 100755
index 7601a87..1686a3a
--- a/shell/sms_ABO.sh
+++ b/shell/sms_ABO.sh
@@ -11,12 +11,28 @@
# TODO: Create information Channels and moderate OPT IN/OUT
source ./shell/init.sh
source ./shell/functions.sh
-log "__SUB:sms_ABO.sh: START ($1=SERVICE, $2=YESNO)"
-SERVICE=$1
-YESNO=$2
-PARAMS=$3
+log "__SUB:sms_ABO.sh: START ($1=PHONE, $2=SERVICE)"
+PHONE=$1
+SERVICE=$2
+
+sms_INIT_ACCOUNT "$PHONE"
case "$SERVICE" in
+ ON)
+ log "Abonnement Kalkun"
+ if [[ "$MEMBER" != "" ]]; then
+ add_contact $MEMBER $PHONE && log "${c_green}Contact has been added to database$c_" || "${c_red}Contact can't be added to database$c_";
+ sms_SEND "$PHONE" "$MEMBER votre inscription annuaire est active"
+ fi
+ ;;
+ OFF)
+ log "Retrait Kalkun"
+ if [[ $MEMBER ]]; then
+ rm_contact $MEMBER $PHONE && log "${c_green}Contact has been deleted from database$c_" || "${c_red}Contact can't be deleted database$c_";
+ sms_SEND "$PHONE" "$MEMBER retrait annuaire prise en compte..."
+ fi
+ ;;
+
MARCHE)
log "Avertissement G1 marchés"
# PARAMS could be "$distance" to Member GeoPoint...
diff --git a/sms_received.sh b/sms_received.sh
index 2b4b461..4bf00d5 100755
--- a/sms_received.sh
+++ b/sms_received.sh
@@ -184,9 +184,8 @@ case "$CMD" in
;;
ABO)
# GERER SES ABONNEMENT CANAUX INFO SMS
- CANAL=$(echo "$TEXT" | awk '{print $2}'| grep -E "([A-Za-z0-9\-\_]+$)")
- YESNO=$(echo "$TEXT" | awk '{print $3}'| grep -E "([A-Za-z0-9\-\_]+$)")
- ./shell/sms_ABO.sh "$PHONE" "$CANAL" "$YESNO" &
+ SERVICE=$(echo "$TEXT" | awk '{print toupper($2)}'| grep -E "([A-Za-z0-9\-\_]+$)")
+ ./shell/sms_ABO.sh "$PHONE" "$SERVICE" &
;;
DELIVERED|PENDING|FAILED)
# If delivered/pending notification come back (gammu/phone config)
From 123b4ea563e332a6625b466134a3d6334bbe6bc6 Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 02:47:10 +0100
Subject: [PATCH 13/26] Adapat install kallkun for gammu 1.37 on stretch
---
.install/4a-install_kalkun.sh | 14 +++++++++++---
.install/templates/.profile | 12 +++++-------
.install/templates/init.sh | 10 +++++-----
install.sh | 21 ++++++++++++++-------
4 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/.install/4a-install_kalkun.sh b/.install/4a-install_kalkun.sh
index 0fbcec2..67f4952 100755
--- a/.install/4a-install_kalkun.sh
+++ b/.install/4a-install_kalkun.sh
@@ -9,9 +9,13 @@ 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 }')
-[[ ! $KSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domaine pour KALKUN (Sinon $IP sera choisi): $c_" && read KSMS_DOMAIN
-[[ ! $KSMS_DOMAIN ]] && KSMS_DOMAIN=$IP && askSSL=n && noask=o
+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/\
Date: Wed, 18 Dec 2019 02:53:11 +0100
Subject: [PATCH 14/26] Fix ABO log
---
shell/sms_ABO.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/shell/sms_ABO.sh b/shell/sms_ABO.sh
index 1686a3a..8af0bfa 100755
--- a/shell/sms_ABO.sh
+++ b/shell/sms_ABO.sh
@@ -21,14 +21,14 @@ case "$SERVICE" in
ON)
log "Abonnement Kalkun"
if [[ "$MEMBER" != "" ]]; then
- add_contact $MEMBER $PHONE && log "${c_green}Contact has been added to database$c_" || "${c_red}Contact can't be added to database$c_";
+ add_contact $MEMBER $PHONE && 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"
fi
;;
OFF)
log "Retrait Kalkun"
if [[ $MEMBER ]]; then
- rm_contact $MEMBER $PHONE && log "${c_green}Contact has been deleted from database$c_" || "${c_red}Contact can't be deleted database$c_";
+ rm_contact $MEMBER $PHONE && 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..."
fi
;;
From 043b7db512c568a92b6334ce149f99d2c016be78 Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 03:16:33 +0100
Subject: [PATCH 15/26] Remover Sender:@username. Echo admin / admin default
login. Good default settings
---
.install/4a-install_kalkun.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.install/4a-install_kalkun.sh b/.install/4a-install_kalkun.sh
index 67f4952..e35ffce 100755
--- a/.install/4a-install_kalkun.sh
+++ b/.install/4a-install_kalkun.sh
@@ -61,6 +61,7 @@ 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
@@ -118,6 +119,7 @@ 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 $http://$DOMAIN$c_"
+ 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
From 7ccfd8f377aa30bbf358159d08a65b8cc2fd8671 Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 16:23:58 +0100
Subject: [PATCH 16/26] Fix add user to group. Check if group 1 doesn't exist,
create it
---
shell/functions.sh | 40 ++++++++++++++++++++++++++--------------
shell/sms_ABO.sh | 8 ++++----
shell/sms_DESTROY.sh | 2 +-
shell/sms_NEW.sh | 2 +-
4 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/shell/functions.sh b/shell/functions.sh
index 7dbb9bf..43edb1c 100755
--- a/shell/functions.sh
+++ b/shell/functions.sh
@@ -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 () {
# sms_SEND ($1=phone, $2=message)
local dest="$1"
@@ -621,16 +628,19 @@ function move_g1cents (){
function add_contact(){
userDB="gammu"
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
- local sql="mysql -u$userDB -p$pwdDB gammu -e"
+ local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
- local MEMBERUID=$1
- local PHONE=$2
+ local PHONE=$1
+ local MEMBERUID=$2
- local reqPhoneExist="SELECT * FROM pbk WHERE Number=$PHONE"
+ [[ -z $MEMBERUID ]] && MEMBERUID=$PHONE
- if [[ -z $($sql "$reqPhoneExist") ]]; then
- local reqAddContact="INSERT INTO pbk (GroupID, Name, Number, id_user, is_public) VALUES ('1', '$MEMBERUID', '$PHONE', '1', 'false')"
- $sql "$reqAddContact" || exit 1
+ [[ -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
@@ -640,19 +650,21 @@ function add_contact(){
function rm_contact(){
userDB="gammu"
pwdDB=$(cat /etc/gammu-smsdrc | grep "password =" | awk '{ print $3 }' || exit 1)
- local sql="mysql -u$userDB -p$pwdDB gammu -e"
+ local sql="mysql -N -u$userDB -p$pwdDB gammu -e"
- local MEMBERUID=$1
- local PHONE=$2
+ local PHONE=$1
+ local MEMBERUID=$2
- local reqPhoneExist="SELECT * FROM pbk WHERE Number=$PHONE"
+ [[ -z $MEMBERUID ]] && MEMBERUID=$PHONE
- if [[ ! -z $($sql "$reqPhoneExist") ]]; then
- local reqRmContact="DELETE FROM pbk WHERE Number=$PHONE"
- $sql "$reqRmContact" || exit 1
+ 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
}
+$@
diff --git a/shell/sms_ABO.sh b/shell/sms_ABO.sh
index 8af0bfa..e3c77fb 100755
--- a/shell/sms_ABO.sh
+++ b/shell/sms_ABO.sh
@@ -19,16 +19,16 @@ sms_INIT_ACCOUNT "$PHONE"
case "$SERVICE" in
ON)
- log "Abonnement Kalkun"
+ log "Abonnement Kalkun"
if [[ "$MEMBER" != "" ]]; then
- add_contact $MEMBER $PHONE && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_";
+ 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_";
sms_SEND "$PHONE" "$MEMBER votre inscription annuaire est active"
fi
;;
OFF)
- log "Retrait Kalkun"
+ log "Retrait Kalkun"
if [[ $MEMBER ]]; then
- rm_contact $MEMBER $PHONE && log "${c_green}Contact has been deleted from database$c_" || log "${c_red}Contact can't be deleted database$c_";
+ rm_contact $PHONE $MEMBERUID && 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..."
fi
;;
diff --git a/shell/sms_DESTROY.sh b/shell/sms_DESTROY.sh
index ae0bcb7..5369a74 100755
--- a/shell/sms_DESTROY.sh
+++ b/shell/sms_DESTROY.sh
@@ -72,7 +72,7 @@ sms_SEND "$PHONE" "$mess"
fi
# Remove contact from database
-rm_contact $MEMBERUID $PHONE && log "${c_green}Contact has been deleted from database$c_" || log "${c_red}Contact can't be deleted database$c_"
+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
diff --git a/shell/sms_NEW.sh b/shell/sms_NEW.sh
index 04f537a..0c945d8 100755
--- a/shell/sms_NEW.sh
+++ b/shell/sms_NEW.sh
@@ -52,7 +52,7 @@ sms_SEND "$PHONE" "Compte relié? $MEMBER $MAIL
$MEMRIB"
# Add contact to database
-add_contact $MEMBERUID $PHONE && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_"
+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 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
From fac3136524dd1d4561642b61eff8c0d94ead9a51 Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 16:25:59 +0100
Subject: [PATCH 17/26] Fix add user to group. Check if group 1 doesn't exist,
create it
---
shell/functions.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/shell/functions.sh b/shell/functions.sh
index 43edb1c..a7e80f3 100755
--- a/shell/functions.sh
+++ b/shell/functions.sh
@@ -666,5 +666,3 @@ function rm_contact(){
fi
}
-
-$@
From 7c0d9977f69d290dd38ad573ed7a11e83dfa805a Mon Sep 17 00:00:00 2001
From: poka
Date: Wed, 18 Dec 2019 16:35:29 +0100
Subject: [PATCH 18/26] Fix sms_abo memberid
---
shell/sms_ABO.sh | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/shell/sms_ABO.sh b/shell/sms_ABO.sh
index e3c77fb..28ff437 100755
--- a/shell/sms_ABO.sh
+++ b/shell/sms_ABO.sh
@@ -19,18 +19,14 @@ sms_INIT_ACCOUNT "$PHONE"
case "$SERVICE" in
ON)
- log "Abonnement Kalkun"
- if [[ "$MEMBER" != "" ]]; then
- 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_";
- sms_SEND "$PHONE" "$MEMBER votre inscription annuaire est active"
- fi
+ 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"
- if [[ $MEMBER ]]; then
- rm_contact $PHONE $MEMBERUID && 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..."
- fi
+ 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)
From 8d2e611162e118f7b540cb9bb76238f6bbb55b0e Mon Sep 17 00:00:00 2001
From: poka
Date: Fri, 20 Dec 2019 19:59:01 +0100
Subject: [PATCH 19/26] Fix debug/GSM_powerkey.sh do not stop key if is
started. Replace by . Add .install/templates/2b/gammu-smsdrc
---
.install/.GPATH | 1 +
...re_ipfs_layer.sh => 2a-configure_ipfs_layer.sh} | 2 +-
.install/2b-configure_gammu.sh | 34 ++++++
.install/5-install_rompr.sh | 14 +++
.install/templates/.profile | 1 +
.install/templates/2/swarm.key | 3 -
.install/templates/2b/gammu-smsdrc | 26 +++++
.install/templates/5/youtube-dl.php | 128 +++++++++++++++++++++
.install/templates/init.sh | 10 +-
GSM_POWERKEY.py | 10 --
_CopyLaRadio/copy.sh | 8 +-
GSM_powerkey.sh => debug/GSM_powerkey.sh | 13 ++-
debug/smsc.txt | 5 +
install.sh | 15 ++-
search | 4 +-
shell/cron_MINUTE.sh | 8 +-
shell/init.sh.old | 10 +-
shell/init_keys.sh | 20 ++--
shell/sms_EMAIL.sh | 3 +-
sms_received.sh | 10 +-
www/rompr/REC/youtube-dl.php | 16 +--
21 files changed, 289 insertions(+), 52 deletions(-)
create mode 100644 .install/.GPATH
rename .install/{2-configure_ipfs_layer.sh => 2a-configure_ipfs_layer.sh} (98%)
create mode 100644 .install/2b-configure_gammu.sh
create mode 100755 .install/5-install_rompr.sh
delete mode 100644 .install/templates/2/swarm.key
create mode 100644 .install/templates/2b/gammu-smsdrc
create mode 100644 .install/templates/5/youtube-dl.php
delete mode 100755 GSM_POWERKEY.py
rename GSM_powerkey.sh => debug/GSM_powerkey.sh (54%)
create mode 100644 debug/smsc.txt
diff --git a/.install/.GPATH b/.install/.GPATH
new file mode 100644
index 0000000..ac91fa6
--- /dev/null
+++ b/.install/.GPATH
@@ -0,0 +1 @@
+GPATH=/home/pi/G1sms+
diff --git a/.install/2-configure_ipfs_layer.sh b/.install/2a-configure_ipfs_layer.sh
similarity index 98%
rename from .install/2-configure_ipfs_layer.sh
rename to .install/2a-configure_ipfs_layer.sh
index 0839556..162f6f6 100755
--- a/.install/2-configure_ipfs_layer.sh
+++ b/.install/2a-configure_ipfs_layer.sh
@@ -8,7 +8,7 @@
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
stamp=$(date +%s)
-templates="$MY_PATH/templates/2"
+templates="$MY_PATH/templates/2a"
#######################################
# CONFIGURE IPFS for G1sms+ Pi NODES
diff --git a/.install/2b-configure_gammu.sh b/.install/2b-configure_gammu.sh
new file mode 100644
index 0000000..4940c5c
--- /dev/null
+++ b/.install/2b-configure_gammu.sh
@@ -0,0 +1,34 @@
+#!/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") ]] && sudo systemctl stop getty@tty1.service && sudo systemctl disable getty@tty1.service
+
+## 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
+
+## 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
+
+
+
+## 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_"
+
+exit 0
diff --git a/.install/5-install_rompr.sh b/.install/5-install_rompr.sh
new file mode 100755
index 0000000..987c507
--- /dev/null
+++ b/.install/5-install_rompr.sh
@@ -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
diff --git a/.install/templates/.profile b/.install/templates/.profile
index d202a9a..c32b4b1 100644
--- a/.install/templates/.profile
+++ b/.install/templates/.profile
@@ -2,4 +2,5 @@ ADMINPSEUDO=_ADMINPSEUDO
ADMINPHONE=_ADMINPHONE
MASTERPHONE=_MASTERPHONE
ADRESSE="_ADRESSE"
+PIN=_PIN
KSMS_DOMAIN=
diff --git a/.install/templates/2/swarm.key b/.install/templates/2/swarm.key
deleted file mode 100644
index 829df9d..0000000
--- a/.install/templates/2/swarm.key
+++ /dev/null
@@ -1,3 +0,0 @@
-/key/swarm/psk/1.0.0/
-/base16/
-66f6fcfa6e89bc14721d905370dae9026442eb44fa4d0c92464da887074a234f
diff --git a/.install/templates/2b/gammu-smsdrc b/.install/templates/2b/gammu-smsdrc
new file mode 100644
index 0000000..77fbaad
--- /dev/null
+++ b/.install/templates/2b/gammu-smsdrc
@@ -0,0 +1,26 @@
+# Configuration file for Gammu SMS Daemon
+
+[gammu]
+port = /dev/ttyS0
+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
diff --git a/.install/templates/5/youtube-dl.php b/.install/templates/5/youtube-dl.php
new file mode 100644
index 0000000..efd05ca
--- /dev/null
+++ b/.install/templates/5/youtube-dl.php
@@ -0,0 +1,128 @@
+[REC]';
+ zcopylink += ' *';
+ 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='
';
+$result='
';
+if( $radio == "" ) { $radio = "CopyLaRadio"; }
+if( $radio == "Nova zz" ) {
+ $artist = "undefined";
+ $title = "undefined";
+}
+// Write request for copy.sh triggering
+if( $search == "REC" ) {
+///////////////////
+ $result.='♫ '.$radio.' ♫
';
+ // 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.='LIEN: '.$lnk.'
';
+///////////////////
+ // 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.='
+'.$artist.' / '.$title.'
+';
+///////////////////
+ // 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 = '
+';
+
+$lnkform.='
+
+
+
+';
+
+?>
+
+
+
+
+
+
+
+ - Recherche YouTube & Copie privée
+
+
+
+
+
+
diff --git a/.install/templates/init.sh b/.install/templates/init.sh
index 672085c..7f5a01b 100755
--- a/.install/templates/init.sh
+++ b/.install/templates/init.sh
@@ -4,6 +4,11 @@
# 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
+source $MY_PATH/.install/.GPATH
+
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
function log () {
# log ($1=text)
@@ -31,8 +36,7 @@ fi
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 $CHEMIN
+ cd $GPATH
##################################################################
# Activate logging to /tmp/g1sms.log (YES/NO)
export DOLOG="YES"
@@ -75,5 +79,5 @@ fi
# TODO Use latest Silkaj from "sudo fredp3 install silkaj"
# export SILKAJ="/usr/local/bin/silkaj"
- source $CHEMIN/shell/init_keys.sh
+ source $GPATH/shell/init_keys.sh
diff --git a/GSM_POWERKEY.py b/GSM_POWERKEY.py
deleted file mode 100755
index 037387e..0000000
--- a/GSM_POWERKEY.py
+++ /dev/null
@@ -1,10 +0,0 @@
-import RPi.GPIO as GPIO
-import time
-GPIO.setmode(GPIO.BOARD)
-GPIO.setup(7, GPIO.OUT)
-while True:
- GPIO.output(7, GPIO.LOW)
- time.sleep(4)
- GPIO.output(7, GPIO.HIGH)
- break
-GPIO.cleanup()
diff --git a/_CopyLaRadio/copy.sh b/_CopyLaRadio/copy.sh
index 8391a86..c94b441 100755
--- a/_CopyLaRadio/copy.sh
+++ b/_CopyLaRadio/copy.sh
@@ -1,5 +1,9 @@
#!/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
#echo > /tmp/ytdl.list
@@ -74,9 +78,9 @@ elif [[ "$radio" != "" && "$artist" == "" && "$song" == "" ]]; then
# EXTERNAL PARSER: ADD SCRAPERS IN ./libradio
~/parle.sh "Recherche RADIO ${radio}"
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"
- php "/home/pi/G1sms+/_CopyLaRadio/libradio/${radio}.php"
+ php "$GPATH/_CopyLaRadio/libradio/${radio}.php"
else
~/parle.sh "Aucun module de décodage pour cette radio."
fi
diff --git a/GSM_powerkey.sh b/debug/GSM_powerkey.sh
similarity index 54%
rename from GSM_powerkey.sh
rename to debug/GSM_powerkey.sh
index 3615018..5526df2 100755
--- a/GSM_powerkey.sh
+++ b/debug/GSM_powerkey.sh
@@ -1,9 +1,16 @@
#!/bin/bash
+
+MY_PATH="`dirname \"$0\"`"
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`"
+
if [ ! -e /sys/class/gpio/gpio4 ]; then
- echo "File exists."
+ echo "File doesn't exists."
echo "4" > /sys/class/gpio/export
fi
+
echo "out" > /sys/class/gpio/gpio4/direction
-echo "0" > /sys/class/gpio/gpio4/value
-sleep 2
echo "1" > /sys/class/gpio/gpio4/value
+
+sleep 3 && $MY_PATH/gammu-restart.sh
+
+exit 0
diff --git a/debug/smsc.txt b/debug/smsc.txt
new file mode 100644
index 0000000..1dd1c98
--- /dev/null
+++ b/debug/smsc.txt
@@ -0,0 +1,5 @@
++33695000695
++33695000647
++33695000646
++33695000643
++33695000636
diff --git a/install.sh b/install.sh
index 0ecd354..e44d8bb 100755
--- a/install.sh
+++ b/install.sh
@@ -6,6 +6,10 @@
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
+
+echo "GPATH=$MY_PATH" > $MY_PATH/.install/.GPATH
+source $MY_PATH/.install/.GPATH
+
init_loc="$MY_PATH/shell/init.sh"
now=$(date +%Y-%m-%d)
unset err
@@ -47,7 +51,7 @@ $MY_PATH/.install/export_colors.sh
if [[ $force_req == "o" || -z $(which ipfs) || -z $(which gammu) ]];then
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_"
$MY_PATH/.install/1-install_requirements.sh silkaj ipfs gammu || err+=1
- $MY_PATH/.install/2-configure_ipfs_layer.sh || err+=1
+ $MY_PATH/.install/2a-configure_ipfs_layer.sh || err+=1
else
echo -e "${c_green}IPFS et gammu sont déjà installé !$c_"
fi
@@ -66,7 +70,10 @@ if [[ -f $MY_PATH/.install/templates/init.sh ]]; then
[[ ! $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
- echo -e "ADMINPSEUDO: $ADMINPSEUDO\nADMINPHONE: $ADMINPHONE\nMASTERPHONE: $MASTERPHONE\nADRESSE: $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
@@ -83,6 +90,7 @@ if [[ -f $MY_PATH/.install/templates/init.sh ]]; then
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
@@ -91,6 +99,9 @@ else
exit 1
fi
+## Configuration de gammu
+$MY_PATH/.install/2b-configure_gammu.sh || err=1
+
## Installations optionnels
repOld=$repOption
diff --git a/search b/search
index b2c0947..f5b8195 100755
--- a/search
+++ b/search
@@ -2,7 +2,7 @@
clear
echo "------------------------------------------------------------------------------"
if [ "$1" == "" ]; then
- echo " Nothing to search for!"
+ echo " Nothing to search for!"
else
echo " Searching for "$1" recursively. Please Wait..."
echo "------------------------------------------------------------------------------"
@@ -10,7 +10,7 @@ else
fi
echo "------------------------------------------------------------------------------"
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'"
fi
diff --git a/shell/cron_MINUTE.sh b/shell/cron_MINUTE.sh
index 483b68f..9e6c50f 100755
--- a/shell/cron_MINUTE.sh
+++ b/shell/cron_MINUTE.sh
@@ -7,10 +7,14 @@
# CE FICHIER cron_MINUTE.sh EST EXECUTE TOUTES LES MINUTES
# IL CONSTITUE LE BATEMENT DE COEUR DU SYSTEME
################################################################################
+
+MY_PATH="`dirname \"$0\"`" # relative
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
+source $MY_PATH/../.install/.GPATH
+
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
IPFSNODEID=$(su $YOU -c "ipfs id -f='\n'")
-CHEMIN="/home/$YOU/G1sms+"
-cd $CHEMIN
+cd $GPATH
source ./shell/init.sh
source ./shell/functions.sh
diff --git a/shell/init.sh.old b/shell/init.sh.old
index 65517c1..7a2984a 100755
--- a/shell/init.sh.old
+++ b/shell/init.sh.old
@@ -5,6 +5,11 @@
# License: GPL (http://www.google.com/search?q=GPL)
##################################################################
# Adapter les valeurs au contexte spatio-temporel du NODE G1SMS
+
+MY_PATH="`dirname \"$0\"`" # relative
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
+source $MY_PATH/../.install/.GPATH
+
function log () {
# log ($1=text)
if [ "$DOLOG" == "YES" ]
@@ -31,8 +36,7 @@ fi
export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
- export CHEMIN="/home/$YOU/G1sms+"
- cd $CHEMIN
+ cd $GPATH
##################################################################
# Activate logging to /tmp/g1sms.log (YES/NO)
export DOLOG="YES"
@@ -75,5 +79,5 @@ fi
# TODO Use latest Silkaj from "sudo fredp3 install silkaj"
# export SILKAJ="/usr/local/bin/silkaj"
- source $CHEMIN/shell/init_keys.sh
+ source $GPATH/shell/init_keys.sh
diff --git a/shell/init_keys.sh b/shell/init_keys.sh
index 67210aa..eb495a9 100755
--- a/shell/init_keys.sh
+++ b/shell/init_keys.sh
@@ -6,9 +6,13 @@
##################################################################
# CHECK & WARN | CREATE Keys (gpg encrypt, G1wallet, IPNS publish)
##################################################################
+
+MY_PATH="`dirname \"$0\"`" # relative
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
+source $MY_PATH/.install/.GPATH
+
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+
-CHEMIN="/home/$YOU/G1sms+"
##################################################################
# G1sms+ Node KEYS (G1wallet, gpg, IPNS)
@@ -20,17 +24,17 @@ if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS E
# G1sms+ Swarm KEYS
##################################################################
# G1sms Service - G1Wallet
-if [[ -f "${CHEMIN}/g1sms.pub.key" && -f "${CHEMIN}/g1sms.priv.key" ]]; then
- chown root:root ${CHEMIN}/g1sms.priv.key
- chmod 600 ${CHEMIN}/g1sms.priv.key
- export MASTERPUB=$(cat "${CHEMIN}/g1sms.pub.key")
- export MASTERKEYFILE="${CHEMIN}/g1sms.priv.key"
+if [[ -f "${GPATH}/g1sms.pub.key" && -f "${GPATH}/g1sms.priv.key" ]]; then
+ chown root:root ${GPATH}/g1sms.priv.key
+ chmod 600 ${GPATH}/g1sms.priv.key
+ export MASTERPUB=$(cat "${GPATH}/g1sms.pub.key")
+ export MASTERKEYFILE="${GPATH}/g1sms.priv.key"
else
echo "ATTENTION!! Vous devez posséder la clef du G1 Wallet utilisé par le SWARM G1sms!!"
./shell/parle.sh "Les clefs du portefeuille essaim G1 SMS sont absente. Au revoir."
echo "Fichiers manquants:"
- echo "${CHEMIN}/g1sms.pub.key"
- echo "${CHEMIN}/g1sms.priv.key"
+ echo "${GPATH}/g1sms.pub.key"
+ echo "${GPATH}/g1sms.priv.key"
echo "Contactez nous sur https://g1sms.fr"
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
exit
diff --git a/shell/sms_EMAIL.sh b/shell/sms_EMAIL.sh
index 2ebba7b..14d901a 100755
--- a/shell/sms_EMAIL.sh
+++ b/shell/sms_EMAIL.sh
@@ -7,9 +7,10 @@
# 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/functions.sh
+
log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
phone="$1"
diff --git a/sms_received.sh b/sms_received.sh
index 4bf00d5..c6d1f93 100755
--- a/sms_received.sh
+++ b/sms_received.sh
@@ -27,14 +27,16 @@
# License: GPL (http://www.google.com/search?q=GPL)
################################################################################
+MY_PATH="`dirname \"$0\"`" # relative
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
+
# Execute Kalkun daemon
[[ -f /var/www/kalkun/scripts/daemon.sh ]] && /var/www/kalkun/scripts/daemon.sh
export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
-export CHEMIN="/home/$YOU/G1sms+"
-cd $CHEMIN
-source ./shell/init.sh
-source ./shell/functions.sh
+cd $GPATH
+source $MY_PATH/shell/init.sh
+source $MY_PATH/shell/functions.sh
##################################################################
# Get global variables from gammu-smsd
diff --git a/www/rompr/REC/youtube-dl.php b/www/rompr/REC/youtube-dl.php
index 26e2eda..ad1d71d 100644
--- a/www/rompr/REC/youtube-dl.php
+++ b/www/rompr/REC/youtube-dl.php
@@ -1,11 +1,11 @@
[REC]';
+// 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 = ' [REC]';
zcopylink += ' *';
- lines[0].text += zcopylink;
+ lines[0].text += zcopylink;
// ZEEBOX HACK ZONE
*/
// RUN CLI if($argc>1) parse_str(implode('&',array_slice($argv, 1)), $_REQUEST);
@@ -22,7 +22,7 @@ $len=strlen($artist.$title);
//$result='
';
$result='
';
if( $radio == "" ) { $radio = "CopyLaRadio"; }
-if( $radio == "Nova zz" ) {
+if( $radio == "Nova zz" ) {
$artist = "undefined";
$title = "undefined";
}
@@ -62,7 +62,7 @@ if( $search == "REC" ) {
} else {
shell_exec('/home/pi/G1sms+/_CopyLaRadio/parle.sh "Aucun module"');
}
-
+
} else {
shell_exec('/home/pi/G1sms+/_CopyLaRadio/parle.sh "Identification imprécise. Podcast? Fichier local?"');
}
@@ -116,10 +116,10 @@ $lnkform.='