2016-04-29 21:24:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2017-02-08 06:44:35 +01:00
|
|
|
#move to script directory so all relative paths work
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
2017-03-04 20:54:32 +01:00
|
|
|
#includes
|
|
|
|
|
. ./config.sh
|
2017-02-08 06:44:35 +01:00
|
|
|
. ./colors.sh
|
2017-03-05 18:30:59 +01:00
|
|
|
. ./environment.sh
|
2017-02-08 06:44:35 +01:00
|
|
|
|
2016-04-29 21:24:22 +02:00
|
|
|
#send a message
|
2017-02-08 06:44:35 +01:00
|
|
|
verbose "Installing the web server"
|
2016-04-29 21:24:22 +02:00
|
|
|
|
2018-10-10 04:50:37 +02:00
|
|
|
#change the version of php for debian stretch
|
|
|
|
|
if [ ."$os_codename" = ."stretch" ]; then
|
2018-11-06 07:35:42 +01:00
|
|
|
php_version=7.0
|
2018-10-10 04:50:37 +02:00
|
|
|
fi
|
|
|
|
|
|
2017-03-05 05:19:30 +01:00
|
|
|
#if [ ."$cpu_architecture" = ."arm" ]; then
|
2017-02-28 17:32:26 +01:00
|
|
|
#9.x - */stretch/
|
|
|
|
|
#8.x - */jessie/
|
2017-03-05 05:19:30 +01:00
|
|
|
#fi
|
2018-10-10 04:38:20 +02:00
|
|
|
if [ ."$php_version" = ."5.6" ]; then
|
2017-03-04 21:38:24 +01:00
|
|
|
#verbose "Switching forcefully to php5* packages"
|
2017-03-05 05:11:08 +01:00
|
|
|
which add-apt-repository || apt-get install -y software-properties-common
|
2017-03-04 21:38:24 +01:00
|
|
|
#LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
|
|
|
|
|
#LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php5-compat
|
2017-03-05 19:04:41 +01:00
|
|
|
elif [ ."$os_name" = ."Ubuntu" ]; then
|
2017-02-23 18:49:57 +01:00
|
|
|
#16.10.x - */yakkety/
|
|
|
|
|
#16.04.x - */xenial/
|
|
|
|
|
#14.04.x - */trusty/
|
2017-03-05 19:04:41 +01:00
|
|
|
if [ ."$os_codename" = ."trusty" ]; then
|
2017-02-28 17:32:26 +01:00
|
|
|
which add-apt-repository || apt-get install -y software-properties-common
|
2017-02-23 18:49:57 +01:00
|
|
|
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
|
|
|
|
|
fi
|
2017-04-20 01:55:50 +02:00
|
|
|
elif [ ."$cpu_architecture" = ."arm" ]; then
|
2018-11-06 07:35:42 +01:00
|
|
|
#Pi2 and Pi3 Raspbian
|
|
|
|
|
#Odroid
|
|
|
|
|
if [ ."$os_codename" = ."stretch" ]; then
|
|
|
|
|
php_version=7.2
|
|
|
|
|
else
|
|
|
|
|
php_version=5.6
|
|
|
|
|
fi
|
|
|
|
|
apt-get -y install apt-transport-https lsb-release ca-certificates
|
|
|
|
|
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
|
|
|
|
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
2017-02-23 18:49:57 +01:00
|
|
|
else
|
|
|
|
|
#9.x - */stretch/
|
|
|
|
|
#8.x - */jessie/
|
2017-03-05 19:04:41 +01:00
|
|
|
if [ ."$os_codename" = ."jessie" ]; then
|
2018-03-07 05:15:39 +01:00
|
|
|
apt-get -y install apt-transport-https lsb-release ca-certificates
|
2018-03-07 05:17:37 +01:00
|
|
|
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
2018-03-07 05:15:39 +01:00
|
|
|
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
2017-02-23 18:49:57 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
apt-get update
|
|
|
|
|
|
2018-10-10 04:38:20 +02:00
|
|
|
#use php version 5.6 for arm
|
2017-04-20 01:55:50 +02:00
|
|
|
#if [ .$cpu_architecture = .'arm' ]; then
|
2018-10-10 04:38:20 +02:00
|
|
|
# php_version=5.6
|
2017-04-20 01:55:50 +02:00
|
|
|
#fi
|
2017-03-05 18:42:12 +01:00
|
|
|
|
2016-04-29 21:24:22 +02:00
|
|
|
#enable fusionpbx nginx config
|
2017-02-09 16:24:37 +01:00
|
|
|
cp nginx/fusionpbx /etc/nginx/sites-available/fusionpbx
|
2017-03-05 19:04:41 +01:00
|
|
|
|
2017-02-28 17:32:26 +01:00
|
|
|
#prepare socket name
|
2018-10-10 04:38:20 +02:00
|
|
|
if [ ."$php_version" = ."5.6" ]; then
|
2017-02-28 17:32:26 +01:00
|
|
|
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php5-fpm.sock;#g'
|
2017-03-04 21:38:24 +01:00
|
|
|
fi
|
2018-10-10 04:38:20 +02:00
|
|
|
if [ ."$php_version" = ."7.0" ]; then
|
|
|
|
|
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.0-fpm.sock;#g'
|
|
|
|
|
fi
|
|
|
|
|
if [ ."$php_version" = ."7.1" ]; then
|
2018-03-07 05:15:39 +01:00
|
|
|
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.1-fpm.sock;#g'
|
2017-02-28 17:32:26 +01:00
|
|
|
fi
|
2018-10-10 04:38:20 +02:00
|
|
|
if [ ."$php_version" = ."7.2" ]; then
|
|
|
|
|
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.2-fpm.sock;#g'
|
|
|
|
|
fi
|
2016-04-29 21:24:22 +02:00
|
|
|
ln -s /etc/nginx/sites-available/fusionpbx /etc/nginx/sites-enabled/fusionpbx
|
|
|
|
|
|
|
|
|
|
#self signed certificate
|
|
|
|
|
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/nginx.key
|
|
|
|
|
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/nginx.crt
|
|
|
|
|
|
|
|
|
|
#remove the default site
|
2017-01-15 08:11:53 +01:00
|
|
|
rm /etc/nginx/sites-enabled/default
|
|
|
|
|
|
2017-08-09 09:04:45 +02:00
|
|
|
#update config if LetsEncrypt folder is unwanted
|
|
|
|
|
if [ .$letsencrypt_folder = .false ]; then
|
|
|
|
|
sed -i '151,155d' /etc/nginx/sites-available/fusionpbx
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-02 23:21:49 +01:00
|
|
|
#add the letsencrypt directory
|
2017-08-09 09:04:45 +02:00
|
|
|
if [ .$letsencrypt_folder = .true ]; then
|
|
|
|
|
mkdir -p /var/www/letsencrypt/
|
|
|
|
|
fi
|
2017-02-02 23:21:49 +01:00
|
|
|
|
2017-01-15 08:11:53 +01:00
|
|
|
#restart nginx
|
|
|
|
|
service nginx restart
|