Browse Source

Lot of changes in .install. Add Kalkun install (not finish)

poka 8 months ago
parent
commit
aa9a7d2254

+ 2 - 1
.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

+ 35 - 27
.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

+ 1 - 1
.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

+ 20 - 13
.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
+

+ 0 - 140
.install/4-install_playsms.sh

@@ -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

+ 98 - 0
.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

+ 102 - 0
.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
+

+ 21 - 9
.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 "\<DOMAIN=" | awk -F '=' '{ print $2 }')
+if [[ "$args" =~ "DOMAIN=" ]]; then
+	DOMAIN=$(echo "$args" | grep "\<DOMAIN=" | awk -F '=' '{ print $2 }')
+else
+	echo "Veuillez sélectionner un domaine avec DOMAIN=mondommain.com"
+	exit 1
+fi
+if [[ "$args" =~ "APP=" ]]; then
+        APP=$(echo "$args" | grep "\<APP=" | awk -F '=' '{ print $2 }')
+else
+        echo "Veuillez sélectionner une application avec APP=monapp"
+        exit 1
+fi
+
 action=$(echo "$args" | tr " " "\n" | grep -v "=")
 [[ ! $action =~ ^(on|off|certif)$ ]] && echo "Veuillez choisir on, off ou certif pour créer un certificat ssl" && exit 1
 ###
@@ -31,25 +43,25 @@ create_certificate() {
 
 	## Cronification
 	[[ ! -e /opt/scripts ]] && sudo mkdir /opt/scripts
-	sudo cp $MY_PATH/templates/ssl_renew.sh /opt/scripts/
+	sudo cp $MY_PATH/templates/rproxy/ssl_renew.sh /opt/scripts/
 	[[ -z $(sudo crontab -l | grep "/opt/scripts/ssl_renew.sh") ]] && (sudo crontab -l ; sudo echo "12 2 * * 1 /opt/scripts/ssl_renew.sh") | sudo crontab -u root -
 }
 
 
 case $action in
 on)
-	sudo sed -i 's/ #if/ if/' /etc/nginx/conf.d/playsms.conf
+	sudo sed -i 's/ #if/ if/g' /etc/nginx/conf.d/$DOMAIN.conf
 
-	sudo sed -i "s/listen 443;/listen 443 ssl;/" /etc/nginx/conf.d/playsms.conf
+	sudo sed -i "s/listen 443;/listen 443 ssl;/g" /etc/nginx/conf.d/$APP.conf
 	[[ ! -d /etc/nginx/includes ]] && sudo mkdir /etc/nginx/includes
-	sudo cp $MY_PATH/templates/ssl.conf /etc/nginx/includes/
-	sudo sed -i "/Content-Security-Policy/a \   include includes/ssl.conf;\n   ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;\n   ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;" /etc/nginx/conf.d/playsms.conf
+	sudo cp $MY_PATH/templates/rproxy/ssl.conf /etc/nginx/includes/
+	sudo sed -i "/Content-Security-Policy/a \   include includes/ssl.conf;\n   ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;\n   ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;" /etc/nginx/conf.d/$APP.conf
 ;;
 
 off)
-	sudo sed -i 's/ if/ #if/' /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
+	sudo sed -i 's/ if/ #if/g' /etc/nginx/conf.d/$APP.conf
+	sudo sed -i '/ssl.conf;/d' /etc/nginx/conf.d/$APP.conf
+	sudo sed -i '/ssl_certificate/d' /etc/nginx/conf.d/$APP.conf
 ;;
 certif)
 	[[ -z $(which certbot) ]] && install_certbot

+ 34 - 0
.install/templates/1/gammu-smsdrc

@@ -0,0 +1,34 @@
+# Configuration file for Gammu SMS Daemon
+
+# Gammu library configuration, see gammurc(5)
+[gammu]
+# Please configure this!
+port = /dev/ttyUSB0
+synchronizetime = yes
+gammucoding = utf8
+connection = at
+# Debugging
+logformat = textall
+
+# SMSD configuration, see gammu-smsdrc(5)
+[smsd]
+#service = files
+service = sql
+driver = native_mysql
+host = localhost
+user = playsms
+password = DlNHoAZQbuCBJYYI0a1TWfu8X6197pDY6GfARLLUSB
+database = kalkun
+
+logfile = /var/log/gammu-smsd.log
+# Increase for debugging information
+smsc = 33695000695
+PIN = 1234
+
+# Paths where messages are stored
+inboxpath = /var/spool/gammu/inbox/
+outboxpath = /var/spool/gammu/outbox/
+sentsmspath = /var/spool/gammu/sent/
+errorsmspath = /var/spool/gammu/error/
+
+debuglevel = 4

.install/templates/ipfs.service → .install/templates/1/ipfs.service


+ 3 - 0
.install/templates/2/swarm.key

@@ -0,0 +1,3 @@
+/key/swarm/psk/1.0.0/
+/base16/
+66f6fcfa6e89bc14721d905370dae9026442eb44fa4d0c92464da887074a234f

.install/templates/mpd.conf → .install/templates/3/mpd.conf


+ 10 - 0
.install/templates/4a/daemon.php

@@ -0,0 +1,10 @@
+<?php
+// Make sure it's run from CLI
+if(php_sapi_name() != 'cli' && !empty($_SERVER['REMOTE_ADDR'])) exit("Access Denied.");
+
+// Please configure this
+$url = "https://g1sms-blois-2.p2p.legal";
+
+fclose(fopen($url."/index.php/daemon/message_routine/", "r"));
+
+?>

+ 8 - 0
.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

+ 58 - 0
.install/templates/4a/database.php

@@ -0,0 +1,58 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| DATABASE CONNECTIVITY SETTINGS
+| -------------------------------------------------------------------
+| This file will contain the settings needed to access your database.
+|
+| For complete instructions please consult the "Database Connection"
+| page of the User Guide.
+|
+| -------------------------------------------------------------------
+| EXPLANATION OF VARIABLES
+| -------------------------------------------------------------------
+|
+|	['hostname'] The hostname of your database server.
+|	['username'] The username used to connect to the database
+|	['password'] The password used to connect to the database
+|	['database'] The name of the database you want to connect to
+|	['dbdriver'] The database type. ie: mysql.  Currently supported:
+				 mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
+|	['dbprefix'] You can add an optional prefix, which will be added
+|				 to the table name when using the  Active Record class
+|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
+|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
+|	['cache_on'] TRUE/FALSE - Enables/disables query caching
+|	['cachedir'] The path to the folder where cache files should be stored
+|	['char_set'] The character set used in communicating with the database
+|	['dbcollat'] The character collation used in communicating with the database
+|
+| The $active_group variable lets you choose which connection group to
+| make active.  By default there is only one group (the "default" group).
+|
+| The $active_record variables lets you determine whether or not to load
+| the active record class
+*/
+
+$active_group = "default";
+$active_record = TRUE;
+
+$db['default']['hostname'] = "127.0.0.1";
+
+// MySQL
+$db['default']['username'] = "gammu";
+$db['default']['password'] = "_PWD";
+$db['default']['database'] = "gammu";
+$db['default']['dbdriver'] = "mysqli";
+
+$db['default']['dbprefix'] = "";
+$db['default']['pconnect'] = FALSE;
+$db['default']['db_debug'] = TRUE;
+$db['default']['cache_on'] = FALSE;
+$db['default']['cachedir'] = "";
+$db['default']['char_set'] = "utf8";
+$db['default']['dbcollat'] = "utf8_general_ci";
+
+
+/* End of file database.php */
+/* Location: ./application/config/database.php */

+ 40 - 0
.install/templates/4a/kalkun.conf

@@ -0,0 +1,40 @@
+server {
+   listen 80;
+   listen 443;
+   listen [::]:443 ssl;
+   server_name _DOMAIN;
+
+   add_header Content-Security-Policy upgrade-insecure-requests;
+#   add_header 'Access-Control-Allow-Origin' '*';
+
+   #if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; }
+
+   location / {
+     try_files $uri/ $uri /index.php?/$request_uri; # =404;
+      include /etc/nginx/def_conf/proxypass.conf;
+   }
+
+
+   index  index.php index.html;
+   root	/var/www/kalkun;
+
+    # set expiration of assets to MAX for caching
+    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
+            expires max;
+            log_not_found off;
+    }
+
+   # php parsing
+   location ~ \.php$ {
+        include fastcgi_params;
+        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
+        fastcgi_index index.php;
+        fastcgi_param SCRIPT_FILENAME $request_filename;
+   }
+
+   error_log  /var/log/nginx/kalkun_error.log;
+   access_log  /var/log/nginx/kalkun_access.log;
+
+
+}
+

+ 192 - 0
.install/templates/4a/mysql.sql

@@ -0,0 +1,192 @@
+-- 
+-- Database for Gammu SMSD
+-- 
+-- In case you get errors about not supported charset, please
+-- replace utf8mb4 with utf8.
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `gammu`
+-- 
+
+CREATE TABLE IF NOT EXISTS `gammu` (
+  `Version` integer NOT NULL default '0' PRIMARY KEY
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+-- 
+-- Dumping data for table `gammu`
+-- 
+
+INSERT IGNORE INTO `gammu` (`Version`) VALUES (17);
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `inbox`
+-- 
+
+CREATE TABLE IF NOT EXISTS `inbox` (
+  `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `ReceivingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `Text` text NOT NULL,
+  `SenderNumber` varchar(20) NOT NULL default '',
+  `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
+  `UDH` text NOT NULL,
+  `SMSCNumber` varchar(20) NOT NULL default '',
+  `Class` integer NOT NULL default '-1',
+  `TextDecoded` text NOT NULL,
+  `ID` integer unsigned NOT NULL auto_increment,
+  `RecipientID` text NOT NULL,
+  `Processed` enum('false','true') NOT NULL default 'false',
+  `Status` integer NOT NULL default '-1',
+  PRIMARY KEY `ID` (`ID`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
+
+-- 
+-- Dumping data for table `inbox`
+-- 
+
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `outbox`
+-- 
+
+CREATE TABLE IF NOT EXISTS `outbox` (
+  `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `SendBefore` time NOT NULL DEFAULT '23:59:59',
+  `SendAfter` time NOT NULL DEFAULT '00:00:00',
+  `Text` text,
+  `DestinationNumber` varchar(20) NOT NULL default '',
+  `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
+  `UDH` text,
+  `Class` integer default '-1',
+  `TextDecoded` text NOT NULL,
+  `ID` integer unsigned NOT NULL auto_increment,
+  `MultiPart` enum('false','true') default 'false',
+  `RelativeValidity` integer default '-1',
+  `SenderID` varchar(255),
+  `SendingTimeOut` timestamp NULL default CURRENT_TIMESTAMP,
+  `DeliveryReport` enum('default','yes','no') default 'default',
+  `CreatorID` text NOT NULL,
+  `Retries` int(3) default 0,
+  `Priority` integer default 0,
+  `Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
+  `StatusCode` integer NOT NULL default '-1',
+  PRIMARY KEY `ID` (`ID`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+CREATE INDEX outbox_date ON outbox(SendingDateTime, SendingTimeOut);
+CREATE INDEX outbox_sender ON outbox(SenderID(250));
+
+-- 
+-- Dumping data for table `outbox`
+-- 
+
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `outbox_multipart`
+-- 
+
+CREATE TABLE IF NOT EXISTS `outbox_multipart` (
+  `Text` text,
+  `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
+  `UDH` text,
+  `Class` integer default '-1',
+  `TextDecoded` text,
+  `ID` integer unsigned NOT NULL default '0',
+  `SequencePosition` integer NOT NULL default '1',
+  `Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error','Reserved') NOT NULL default 'Reserved',
+  `StatusCode` integer NOT NULL default '-1',
+  PRIMARY KEY (`ID`, `SequencePosition`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+-- 
+-- Dumping data for table `outbox_multipart`
+-- 
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `phones`
+-- 
+
+CREATE TABLE IF NOT EXISTS `phones` (
+  `ID` text NOT NULL,
+  `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `TimeOut` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `Send` enum('yes','no') NOT NULL default 'no',
+  `Receive` enum('yes','no') NOT NULL default 'no',
+  `IMEI` varchar(35) NOT NULL,
+  `IMSI` varchar(35) NOT NULL,
+  `NetCode` varchar(10) default 'ERROR',
+  `NetName` varchar(35) default 'ERROR',
+  `Client` text NOT NULL,
+  `Battery` integer NOT NULL DEFAULT -1,
+  `Signal` integer NOT NULL DEFAULT -1,
+  `Sent` int NOT NULL DEFAULT 0,
+  `Received` int NOT NULL DEFAULT 0,
+  PRIMARY KEY (`IMEI`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+-- 
+-- Dumping data for table `phones`
+-- 
+
+-- --------------------------------------------------------
+
+-- 
+-- Table structure for table `sentitems`
+-- 
+
+CREATE TABLE IF NOT EXISTS `sentitems` (
+  `UpdatedInDB` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `InsertIntoDB` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `SendingDateTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `DeliveryDateTime` timestamp NULL,
+  `Text` text NOT NULL,
+  `DestinationNumber` varchar(20) NOT NULL default '',
+  `Coding` enum('Default_No_Compression','Unicode_No_Compression','8bit','Default_Compression','Unicode_Compression') NOT NULL default 'Default_No_Compression',
+  `UDH` text NOT NULL,
+  `SMSCNumber` varchar(20) NOT NULL default '',
+  `Class` integer NOT NULL default '-1',
+  `TextDecoded` text NOT NULL,
+  `ID` integer unsigned NOT NULL default '0',
+  `SenderID` varchar(255) NOT NULL,
+  `SequencePosition` integer NOT NULL default '1',
+  `Status` enum('SendingOK','SendingOKNoReport','SendingError','DeliveryOK','DeliveryFailed','DeliveryPending','DeliveryUnknown','Error') NOT NULL default 'SendingOK',
+  `StatusError` integer NOT NULL default '-1',
+  `TPMR` integer NOT NULL default '-1',
+  `RelativeValidity` integer NOT NULL default '-1',
+  `CreatorID` text NOT NULL,
+  `StatusCode` integer NOT NULL default '-1',
+  PRIMARY KEY (`ID`, `SequencePosition`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+CREATE INDEX sentitems_date ON sentitems(DeliveryDateTime);
+CREATE INDEX sentitems_tpmr ON sentitems(TPMR);
+CREATE INDEX sentitems_dest ON sentitems(DestinationNumber);
+CREATE INDEX sentitems_sender ON sentitems(SenderID(250));
+
+-- 
+-- Dumping data for table `sentitems`
+-- 
+
+--
+-- Table structure for `ci_sessions`
+--
+
+CREATE TABLE IF NOT EXISTS `ci_sessions` (
+  `id` varchar(128) NOT NULL,
+  `ip_address` varchar(45) NOT NULL,
+  `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
+  `data` blob NOT NULL,
+  KEY `ci_sessions_timestamp` (`timestamp`)
+);

.install/templates/install-playsms.conf → .install/templates/4b/install-playsms.conf


+ 2 - 2
.install/templates/playsms.conf

@@ -2,7 +2,7 @@ server {
    listen 80;
    listen 443;
    listen [::]:443 ssl;
-   server_name _PSMS_DOMAIN;
+   server_name _DOMAIN;
 
    add_header Content-Security-Policy upgrade-insecure-requests;
    add_header 'Access-Control-Allow-Origin' '*';
@@ -16,7 +16,7 @@ server {
 
 
    index  index.php index.html;
-   root	/var/www/playsms/;
+   root	/var/www/playsms;
 
     # set expiration of assets to MAX for caching
     location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {

.install/templates/default → .install/templates/5/default


.install/templates/proxypass.conf → .install/templates/rproxy/proxypass.conf


.install/templates/ssl.conf → .install/templates/rproxy/ssl.conf


.install/templates/ssl_renew.sh → .install/templates/rproxy/ssl_renew.sh


GSM_POWERKEY.py → debug/GSM_POWERKEY.py


GSM_powerkey.sh → debug/GSM_powerkey.sh


+ 19 - 0
debug/debugTTY.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+usbserial=($(lsmod | grep -w usbserial | awk '{ print $4 }' | awk -F, '{ print $1 " " $2 }'))
+
+
+sudo modprobe -r option
+sudo modprobe -r usbserial
+
+sudo modprobe option
+sudo modprobe usbserial
+
+#for i in "${usbserial[@]}"; do
+#echo "tata: $i"
+#	sudo modprobe -r $i
+#	sudo modprobe $i
+#done
+
+
+exit 0

+ 13 - 0
debug/gammu-loglevel.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+MY_PATH="`dirname \"$0\"`"              # relative
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`"  # absolutized and normalized
+
+[[ ! $1 ]] && echo "Veuillez choisir un niveau de log" && exit 1
+
+sudo sed -i "/debuglevel/d" /etc/gammu-smsdrc
+echo "debuglevel = $1" | sudo tee -a /etc/gammu-smsdrc
+
+$MY_PATH/gammu-restart.sh
+
+exit 0

+ 9 - 0
debug/gammu-restart.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+PID=$(sudo ps auxf | grep "/usr/bin/gammu-smsd" | grep -v -E "color=auto|grep" | awk '{ print $2 }')
+
+[[ $PID ]] && sudo kill -9 "$PID"
+
+sudo service gammu-smsd restart
+
+exit 0

+ 8 - 7
install.sh

@@ -21,9 +21,8 @@ args="$@"
 
 ## Vérifie le type de système
 [[ $(uname -a | grep arm) ]] && isARM=YES || unset isARM
-if [[ $(grep stretch /etc/os-release) ]]; then OS=stretch;
+if [[ $(grep -E 'stretch|18.|19.' /etc/os-release) ]]; then OS=stretch;
 elif [[ $(grep buster /etc/os-release) ]]; then OS=buster;
-elif [[ $(grep -E '18.|19.' /etc/os-release) ]]; then OS=ubuntu18;
 else echo "${c_red}Votre OS n'est pas supporté$c_"; exit 1; fi
 echo -e "$OS\n$isARM" > .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

test.sh → tests/test.sh