fusionpbx-install.sh/freebsd/resources/nginx.sh

57 lines
1.5 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#includes
. ./config.sh
. ./colors.sh
2017-06-24 19:38:09 +02:00
#install php
. ./php.sh
2017-04-01 23:34:06 +02:00
#send a message
verbose "Installing the web server"
#install nginx
pkg install --yes nginx
#enable nginx
echo 'nginx_enable="YES"' >> /etc/rc.conf
2017-04-01 23:34:06 +02:00
#enable fusionpbx nginx config
2017-03-26 22:07:55 +02:00
mv /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf-orig
cp nginx/nginx.conf /usr/local/etc/nginx
mkdir -p /usr/local/etc/nginx/conf.d
2017-03-27 10:28:40 +02:00
mkdir -p /usr/local/etc/nginx/sites-available/
mkdir -p /usr/local/etc/nginx/sites-enabled/
cp nginx/fusionpbx.conf /usr/local/etc/nginx/sites-available/fusionpbx
ln -s /usr/local/etc/nginx/sites-available/fusionpbx /usr/local/etc/nginx/sites-enabled/fusionpbx
2017-06-24 10:05:49 +02:00
#get the primary interface name
if [ .$interface_name = .'auto' ]; then
interface_name=$(ifconfig -l | awk '{print $1}')
if [ .$interface_name = .'lo0' ]; then
interface_name=$(ifconfig -l | awk '{print $2}')
fi
fi
2017-06-24 17:23:08 +02:00
#get the ip address
local_ip_v4=$(ifconfig $interface_name | grep 'inet ' | awk '{print $2}')
2017-04-03 05:35:59 +02:00
#set the IP= address
2017-06-24 17:23:08 +02:00
common_name=$local_ip_v4
2017-04-03 05:35:59 +02:00
#self signed certificate
2017-06-24 16:27:31 +02:00
/usr/bin/openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 \
2017-04-03 05:35:59 +02:00
-subj "/C=US/ST=Online/L=SelfSigned/O=FusionPBX/CN=$common_name" \
-keyout /usr/local/etc/nginx/server.key -out /usr/local/etc/nginx/server.crt
#add the letsencrypt directory
mkdir -p /var/www/letsencrypt/
#restart php fpm and nginx
service php-fpm restart
service nginx restart