forked from norman/fusionpbx-install.sh-github-mirror
Postgres install is working nginx is closer
This commit is contained in:
@@ -10,7 +10,7 @@ switch_source=true # true
|
|||||||
|
|
||||||
# Database Settings
|
# Database Settings
|
||||||
database_password=random # random or as a pre-set value
|
database_password=random # random or as a pre-set value
|
||||||
database_repo=official # PostgresSQL official, system, 2ndquadrant
|
database_version=9.6 # Postgres 9.6, 9.5, or 9.4
|
||||||
database_backup=false # true or false
|
database_backup=false # true or false
|
||||||
|
|
||||||
# General Settings
|
# General Settings
|
||||||
|
|||||||
@@ -6,74 +6,41 @@ cd "$(dirname "$0")"
|
|||||||
#includes
|
#includes
|
||||||
. ./config.sh
|
. ./config.sh
|
||||||
. ./colors.sh
|
. ./colors.sh
|
||||||
. ./environment.sh
|
|
||||||
|
|
||||||
#send a message
|
#send a message
|
||||||
verbose "Installing the web server"
|
verbose "Installing the web server"
|
||||||
|
|
||||||
#if [ ."$cpu_architecture" = ."arm" ]; then
|
#install nginx
|
||||||
#9.x - */stretch/
|
pkg install --yes nginx
|
||||||
#8.x - */jessie/
|
|
||||||
#fi
|
|
||||||
if [ ."$php_version" = ."5" ]; then
|
|
||||||
#verbose "Switching forcefully to php5* packages"
|
|
||||||
which add-apt-repository || apt-get install -y software-properties-common
|
|
||||||
#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
|
|
||||||
elif [ ."$os_name" = ."Ubuntu" ]; then
|
|
||||||
#16.10.x - */yakkety/
|
|
||||||
#16.04.x - */xenial/
|
|
||||||
#14.04.x - */trusty/
|
|
||||||
if [ ."$os_codename" = ."trusty" ]; then
|
|
||||||
which add-apt-repository || apt-get install -y software-properties-common
|
|
||||||
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
#9.x - */stretch/
|
|
||||||
#8.x - */jessie/
|
|
||||||
if [ ."$os_codename" = ."jessie" ]; then
|
|
||||||
echo "deb http://packages.dotdeb.org $os_codename all" > /etc/apt/sources.list.d/dotdeb.list
|
|
||||||
echo "deb-src http://packages.dotdeb.org $os_codename all" >> /etc/apt/sources.list.d/dotdeb.list
|
|
||||||
wget -O - https://www.dotdeb.org/dotdeb.gpg | apt-key add -
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
apt-get update
|
|
||||||
|
|
||||||
#use php version 5 for arm
|
#enable nginx
|
||||||
if [ .$cpu_architecture = .'arm' ]; then
|
echo 'nginx_enable="YES"' >> /etc/rc.conf
|
||||||
php_version=5
|
echo 'php_fpm_enable="YES"' >> /etc/rc.conf
|
||||||
fi
|
|
||||||
|
|
||||||
#install dependencies
|
#install dependencies
|
||||||
apt-get install -y nginx
|
|
||||||
if [ ."$php_version" = ."5" ]; then
|
if [ ."$php_version" = ."5" ]; then
|
||||||
apt-get install -y php5 php5-cli php5-fpm php5-pgsql php5-sqlite php5-odbc php5-curl php5-imap php5-mcrypt
|
#pkg install php57
|
||||||
fi
|
fi
|
||||||
if [ ."$php_version" = ."7" ]; then
|
if [ ."$php_version" = ."7" ]; then
|
||||||
apt-get install -y php7.0 php7.0-cli php7.0-fpm php7.0-pgsql php7.0-sqlite3 php7.0-odbc php7.0-curl php7.0-imap php7.0-mcrypt php7.0-xml
|
pkg install --yes php70 php70-phar php70-pgsql php70-pdo php70-pdo_pgsql php70-pdo_odbc php70-pdo_sqlite php70-json php70-gd
|
||||||
|
php70-imap php70-ldap php70-mcrypt php70-openssl php70-sockets php70-simplexml php70-xml php70-session
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#enable fusionpbx nginx config
|
#enable fusionpbx nginx config
|
||||||
cp nginx/fusionpbx /etc/nginx/sites-available/fusionpbx
|
#cp nginx/fusionpbx.conf /usr/local/etc/nginx/conf.d/fusionpbx
|
||||||
|
|
||||||
#prepare socket name
|
|
||||||
if [ ."$php_version" = ."5" ]; then
|
|
||||||
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php5-fpm.sock;#g'
|
|
||||||
fi
|
|
||||||
if [ ."$php_version" = ."7" ]; then
|
|
||||||
sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.0-fpm.sock;#g'
|
|
||||||
fi
|
|
||||||
ln -s /etc/nginx/sites-available/fusionpbx /etc/nginx/sites-enabled/fusionpbx
|
|
||||||
|
|
||||||
#self signed certificate
|
#self signed certificate
|
||||||
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/nginx.key
|
#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
|
#ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/nginx.crt
|
||||||
|
|
||||||
#remove the default site
|
#remove the default site
|
||||||
rm /etc/nginx/sites-enabled/default
|
#rm /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
#add the letsencrypt directory
|
#add the letsencrypt directory
|
||||||
mkdir -p /var/www/letsencrypt/
|
mkdir -p /var/www/letsencrypt/
|
||||||
|
|
||||||
#restart nginx
|
#restart php fpm and nginx
|
||||||
|
service php-fpm restart
|
||||||
service nginx restart
|
service nginx restart
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
freebsd/resources/nginx/fusionpbx.conf
Normal file
29
freebsd/resources/nginx/fusionpbx.conf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name fusionpbx;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log info;
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/local/www/fusionpbx;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/local/www/nginx-dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /usr/local/www/fusionpbx$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,63 +6,51 @@ cd "$(dirname "$0")"
|
|||||||
#includes
|
#includes
|
||||||
. ./config.sh
|
. ./config.sh
|
||||||
. ./colors.sh
|
. ./colors.sh
|
||||||
. ./environment.sh
|
|
||||||
|
|
||||||
#send a message
|
#send a message
|
||||||
echo "Install PostgreSQL"
|
echo "Install PostgreSQL"
|
||||||
|
|
||||||
#generate a random password
|
#generate a random password
|
||||||
password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64)
|
password=$(cat /dev/random | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16)
|
||||||
|
|
||||||
#install message
|
#install message
|
||||||
echo "Install PostgreSQL and create the database and users\n"
|
echo "Install PostgreSQL and create the database and users\n"
|
||||||
|
|
||||||
#use the system database repo for arm
|
#postgres install
|
||||||
if [ .$cpu_architecture = .'arm' ]; then
|
if [ ."$database_version" = ."9.6" ]; then
|
||||||
database_repo="system"
|
pkg install --yes postgresql96-server
|
||||||
|
fi
|
||||||
|
if [ ."$database_version" = ."9.5" ]; then
|
||||||
|
pkg install --yes postgresql95-server
|
||||||
|
fi
|
||||||
|
if [ ."$database_version" = ."9.4" ]; then
|
||||||
|
pkg install --yes postgresql94-server
|
||||||
|
fi
|
||||||
|
if [ ."$database_version" = ."9.3" ]; then
|
||||||
|
pkg install --yes postgresql93-server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#included in the distribution
|
#enable postgres
|
||||||
if [ ."$database_repo" = ."system" ]; then
|
echo 'postgresql_enable=true' >> /etc/rc.conf
|
||||||
apt-get install -y --force-yes sudo postgresql
|
|
||||||
fi
|
|
||||||
|
|
||||||
#postgres official repository
|
#initialize the database
|
||||||
if [ ."$database_repo" = ."official" ]; then
|
/usr/local/etc/rc.d/postgresql initdb
|
||||||
echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' > /etc/apt/sources.list.d/pgdg.list
|
|
||||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
|
||||||
apt-get update && apt-get upgrade -y
|
|
||||||
apt-get install -y --force-yes sudo postgresql
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Add PostgreSQL and BDR REPO
|
#restart the service
|
||||||
if [ ."$database_repo" = ."2ndquadrant" ]; then
|
service postgresql restart
|
||||||
echo 'deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' >> /etc/apt/sources.list.d/postgresql.list
|
|
||||||
echo 'deb http://packages.2ndquadrant.com/bdr/apt/ jessie-2ndquadrant main' >> /etc/apt/sources.list.d/2ndquadrant.list
|
|
||||||
/usr/bin/wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
|
|
||||||
/usr/bin/wget --quiet -O - http://packages.2ndquadrant.com/bdr/apt/AA7A6805.asc | apt-key add -
|
|
||||||
apt-get update && apt-get upgrade -y
|
|
||||||
apt-get install -y --force-yes sudo postgresql-bdr-9.4 postgresql-bdr-9.4-bdr-plugin postgresql-bdr-contrib-9.4
|
|
||||||
fi
|
|
||||||
|
|
||||||
#systemd
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl restart postgresql
|
|
||||||
|
|
||||||
#init.d
|
|
||||||
#/usr/sbin/service postgresql restart
|
|
||||||
|
|
||||||
#install the database backup
|
#install the database backup
|
||||||
cp backup/fusionpbx-backup.sh /etc/cron.daily
|
#cp backup/fusionpbx-backup.sh /etc/cron.daily
|
||||||
chmod 755 /etc/cron.daily/fusionpbx-backup.sh
|
#chmod 755 /etc/cron.daily/fusionpbx-backup.sh
|
||||||
sed -i "s/zzz/$password/g" /etc/cron.daily/fusionpbx-backup.sh
|
#sed -i "s/zzz/$password/g" /etc/cron.daily/fusionpbx-backup.sh
|
||||||
|
|
||||||
#move to /tmp to prevent a red herring error when running sudo with psql
|
#move to /tmp to prevent an error when running sudo with psql
|
||||||
cwd=$(pwd)
|
cwd=$(pwd)
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
|
||||||
#add the databases, users and grant permissions to them
|
#add the databases, users and grant permissions to them
|
||||||
sudo -u postgres psql -d fusionpbx -c "DROP SCHEMA public cascade;";
|
#sudo -u postgres psql -d fusionpbx -c "DROP SCHEMA public cascade;";
|
||||||
sudo -u postgres psql -d fusionpbx -c "CREATE SCHEMA public;";
|
#sudo -u postgres psql -d fusionpbx -c "CREATE SCHEMA public;";
|
||||||
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
|
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
|
||||||
sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
|
sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
|
||||||
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$password';"
|
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$password';"
|
||||||
@@ -71,7 +59,4 @@ sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpb
|
|||||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
|
||||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
|
||||||
#ALTER USER fusionpbx WITH PASSWORD 'newpassword';
|
#ALTER USER fusionpbx WITH PASSWORD 'newpassword';
|
||||||
cd $cwd
|
|
||||||
|
|
||||||
#set the ip address
|
|
||||||
#server_address=$(hostname -I)
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
#configure system service
|
#configure system service
|
||||||
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
|
ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli
|
||||||
cp switch/rc.d.freeswitch /usr/local/etc/rc.d/freeswitch
|
cp rc.d.freeswitch /usr/local/etc/rc.d/freeswitch
|
||||||
chmod u-w,ugo+x /usr/local/etc/rc.d/freeswitch
|
chmod u-w,ugo+x /usr/local/etc/rc.d/freeswitch
|
||||||
|
|
||||||
#enable the service
|
#enable the service
|
||||||
|
|||||||
Reference in New Issue
Block a user