Improve OS detection, install requirements mechanique and install PHP+MySQL in requirements option
This commit is contained in:
parent
6bfae483dc
commit
b1a333ae2e
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
MY_PATH="`dirname \"$0\"`" # relative
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
isARM=$(uname -a | grep arm)
|
|
||||||
|
OS=$(head -n1 $MY_PATH/.OS)
|
||||||
|
isARM=$(cat $MY_PATH/.OS | grep YES)
|
||||||
|
|
||||||
# Basics
|
# Basics
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install curl jq zip unzip htop tree ntpdate gnupg ssmtp mpack imagemagick qrencode bc libttspico-utils libttspico0 libttspico-data -y
|
sudo apt install curl jq zip unzip htop tree ntpdate gnupg ssmtp mpack imagemagick qrencode bc -y
|
||||||
|
|
||||||
|
|
||||||
# Silkaj + Duniterpy
|
# Silkaj + Duniterpy
|
||||||
|
@ -22,10 +24,10 @@ silkaj() {
|
||||||
# Install IPFS
|
# Install IPFS
|
||||||
ipfs() {
|
ipfs() {
|
||||||
[[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop
|
[[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop
|
||||||
if [[ -z $isARM ]]; then
|
if [[ $isARM ]]; then
|
||||||
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
|
|
||||||
else
|
|
||||||
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
|
||||||
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "INSTALL ipfs-update"
|
echo "INSTALL ipfs-update"
|
||||||
|
@ -58,12 +60,12 @@ gammu() {
|
||||||
|
|
||||||
# Install PHP + MySQL
|
# Install PHP + MySQL
|
||||||
php() {
|
php() {
|
||||||
if [[ $(grep buster /etc/os-release) ]]; then
|
if [[ $OS == "buster" ]]; then
|
||||||
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
|
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 add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.liquidtelecom.com/repo/10.4/debian buster main'
|
||||||
sudo apt -y update
|
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
|
||||||
elif [[ $(grep stretch /etc/os-release) ]]; then
|
elif [[ $OS == "stretch" ]]; then
|
||||||
sudo apt -y install lsb-release apt-transport-https ca-certificates
|
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
|
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
|
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
|
||||||
|
|
|
@ -4,14 +4,20 @@ MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
templates="$MY_PATH/templates"
|
templates="$MY_PATH/templates"
|
||||||
|
|
||||||
isARM=$(uname -a | grep arm)
|
isARM=$(cat $MY_PATH/.OS | grep YES)
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
## INSTALL TOOLS
|
## INSTALL TOOLS
|
||||||
######## YOUTUBE-DL ##########
|
######## 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
|
||||||
sudo chmod a+rx /usr/local/bin/youtube-dl
|
sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||||
sudo apt install libid3-tools mpd mpc lame -y
|
|
||||||
|
## TODO FOR DEBIAN STRETCH
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
## CONFIG MPD
|
## CONFIG MPD
|
||||||
|
@ -28,12 +34,12 @@ sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid
|
||||||
|
|
||||||
wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb
|
wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb
|
||||||
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb
|
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb
|
||||||
if [[ -z $isARM ]]; then
|
if [[ $isARM ]]; then
|
||||||
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
|
|
||||||
else
|
|
||||||
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico0.deb
|
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico0.deb
|
||||||
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb
|
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb
|
||||||
|
else
|
||||||
|
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
|
fi
|
||||||
sudo dpkg -i $MY_PATH/libttspico-data.deb
|
sudo dpkg -i $MY_PATH/libttspico-data.deb
|
||||||
sudo dpkg -i $MY_PATH/libttspico0.deb
|
sudo dpkg -i $MY_PATH/libttspico0.deb
|
||||||
|
|
|
@ -12,35 +12,18 @@ args=$@
|
||||||
|
|
||||||
[[ ! $PSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domain pour playsms: $c_" && read PSMS_DOMAIN
|
[[ ! $PSMS_DOMAIN ]] && echo -e "${c_yellow}Choisissez un nom de domain pour playsms: $c_" && read PSMS_DOMAIN
|
||||||
|
|
||||||
sudo apt -y update
|
## Install PHP + MySQL
|
||||||
sudo apt -y install unzip zip
|
$MY_PATH/1-install_requirements.sh php
|
||||||
if [[ $(grep buster /etc/os-release) ]]; 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
|
|
||||||
elif [[ $(grep stretch /etc/os-release) ]]; 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
|
|
||||||
else
|
|
||||||
echo "${c_red}Votre système n'est pas pris en charge par ce script d'installation.$c_"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Create database
|
## Create database
|
||||||
|
|
||||||
if [[ ! $(sudo mysql -e "show databases;" | grep playsms) ]]; then
|
if [[ ! $(sudo mysql -e "show databases;" | grep gammu) ]]; then
|
||||||
sudo mysql -e "CREATE DATABASE playsms"
|
sudo mysql -e "CREATE DATABASE gammu"
|
||||||
sudo mysql -e "CREATE USER 'playsms'@'localhost' IDENTIFIED BY '$pwdDB';"
|
sudo mysql -e "CREATE USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
|
||||||
sudo mysql -e "GRANT ALL PRIVILEGES ON playsms.* TO 'playsms'@'localhost';"
|
sudo mysql -e "GRANT ALL PRIVILEGES ON playsms.* TO 'gammu'@'localhost';"
|
||||||
sudo mysql -e "FLUSH PRIVILEGES;"
|
sudo mysql -e "FLUSH PRIVILEGES;"
|
||||||
else
|
else
|
||||||
sudo mysql -e "ALTER USER 'playsms'@'localhost' IDENTIFIED BY '$pwdDB';"
|
sudo mysql -e "ALTER USER 'gammu'@'localhost' IDENTIFIED BY '$pwdDB';"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Clone repo playSMS
|
## Clone repo playSMS
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
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 }')
|
||||||
|
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
|
||||||
|
###
|
||||||
|
|
||||||
|
install_certbot(){
|
||||||
|
sudo apt update
|
||||||
|
if [[ $(grep -E 'stretch|buster' /etc/os-release) ]]; then
|
||||||
|
sudo apt install certbot python-certbot-nginx -y
|
||||||
|
elif [[ $(grep -E '16.|17.|18.|19.' /etc/os-release) ]]; then
|
||||||
|
sudo apt install software-properties-common
|
||||||
|
sudo add-apt-repository universe
|
||||||
|
sudo add-apt-repository ppa:certbot/certbot
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install certbot python-certbot-nginx
|
||||||
|
else
|
||||||
|
echo "OS non supporté pour certbot." && exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
create_certificate() {
|
||||||
|
sudo certbot --nginx certonly --non-interactive --agree-tos -m $USER@$DOMAIN -d $DOMAIN && echo "Le certificat de $DOMAIN a bien été déployé" || echo "Une erreur s'est produite lors de la création du certificat SSL"
|
||||||
|
|
||||||
|
## Cronification
|
||||||
|
[[ ! -e /opt/scripts ]] && sudo mkdir /opt/scripts
|
||||||
|
sudo cp $MY_PATH/templates/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/$DOMAIN/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/$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/$DOMAIN/fullchain.pem ]] && create_certificate
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
|
@ -1,11 +1,11 @@
|
||||||
# MySQL database username
|
# MySQL database username
|
||||||
DBUSER="playsms"
|
DBUSER="gammu"
|
||||||
|
|
||||||
# MySQL database password
|
# MySQL database password
|
||||||
DBPASS="_pwdDB"
|
DBPASS="_pwdDB"
|
||||||
|
|
||||||
# MySQL database name
|
# MySQL database name
|
||||||
DBNAME="playsms"
|
DBNAME="gammu"
|
||||||
|
|
||||||
# MySQL database host
|
# MySQL database host
|
||||||
DBHOST="localhost"
|
DBHOST="localhost"
|
||||||
|
|
12
install.sh
12
install.sh
|
@ -8,16 +8,28 @@ MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
init_loc="$MY_PATH/shell/init.sh"
|
init_loc="$MY_PATH/shell/init.sh"
|
||||||
now=$(date +%Y-%m-%d)
|
now=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
## Récupère les données du profile
|
||||||
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
|
[[ -f $MY_PATH/.profile ]] && source $MY_PATH/.profile
|
||||||
|
|
||||||
|
## Récupère les arguments
|
||||||
args="$@"
|
args="$@"
|
||||||
[[ $args =~ all ]] && repOption=o
|
[[ $args =~ all ]] && repOption=o
|
||||||
[[ $args =~ noptions ]] && repOption=n
|
[[ $args =~ noptions ]] && repOption=n
|
||||||
[[ $args =~ force ]] && force_req=o
|
[[ $args =~ force ]] && force_req=o
|
||||||
[[ $args =~ noask ]] && noask=o
|
[[ $args =~ noask ]] && noask=o
|
||||||
|
|
||||||
|
## Vérifie le type de système
|
||||||
|
[[ $(uname -a | grep arm) ]] && isARM=YES || unset isARM
|
||||||
|
if [[ $(grep stretch /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
|
||||||
|
|
||||||
unset err
|
unset err
|
||||||
|
|
||||||
|
## Vérifie si le script est en lancé par root
|
||||||
if [ "$EUID" -eq 0 ]
|
if [ "$EUID" -eq 0 ]
|
||||||
then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_"
|
then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue