diff --git a/debian/install.sh b/debian/install.sh index c22757f..be22334 100755 --- a/debian/install.sh +++ b/debian/install.sh @@ -43,32 +43,83 @@ if [ $HELP = true ]; then exit; fi -if [ $CPU_CHECK = true ]; then - #check what the CPU is - OS_bits=$(uname -m) - OS_arch=$(uname -m) - CPU_bits='i686' - if [ $(grep -o -w 'lm' /proc/cpuinfo) = 'lm' ]; then - CPU_bits='x86_64' +if [ $CPU_CHECK = true ] && [ $USE_SWITCH_SOURCE = false ]; then + #check what the CPU and OS are + OS_test=$(uname -m) + CPU_arch='unknown' + OS_bits='unknown' + CPU_bits='unknown' + if [ $OS_test = 'armv7l' ]; then + OS_bits='32' + CPU_bits='32' + # RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time + CPU_arch='arm' + elif [ $OS_test = 'armv8l' ]; then + # We currently have no test case for armv8l + OS_bits='unknown' + CPU_bits='64' + CPU_arch='arm' + elif [ $OS_test = 'i386' ]; then + OS_bits='32' + if [ "$(grep -o -w 'lm' /proc/cpuinfo)" = 'lm' ]; then + CPU_bits='64' + else + CPU_bits='32' + fi + CPU_arch='x86' + elif [ $OS_test = 'i686' ]; then + OS_bits='32' + if [ $(grep -o -w 'lm' /proc/cpuinfo) = 'lm' ]; then + CPU_bits='64' + else + CPU_bits='32' + fi + CPU_arch='x86' + elif [ $OS_test = 'x86_64' ]; then + OS_bits='64' + if [ $(grep -o -w 'lm' /proc/cpuinfo) = 'lm' ]; then + CPU_bits='64' + else + CPU_bits='32' + fi + CPU_arch='x86' fi - if [ $USE_SWITCH_SOURCE = false ]; then - if [ $OS_arch = 'armv7l' ]; then - if [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = false && OS_bits = 'i686' ]; then + if [ $CPU_arch = 'arm' ]; then + if [ $OS_bits = '32' ]; then + if [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = false ]; then error "You are using a 32bit arm OS this is unsupported" warning " please rerun with either --use-switch-package-unofficial-arm or --use-switch-source" exit 3 + else + verbose "Correct CPU/OS detected, using unofficial arm repo" fi + elif [ $OS_bits = '64' ]; then + error "You are using a 64bit arm OS this is unsupported" + warning " please rerun with --use-switch-source" + exit 3 else - if [ $OS_bits = 'i686' ]; then - error "You are using a 32bit OS this is unsupported" - if [ $CPU_bits = 'x86_64' ]; then - error "Your CPU is 64bit you should consider reinstalling with a 64bit OS" - fi - warning " please rerun with --use-switch-source" - exit 3 - fi + error "Unknown OS_bits $OS_bits this is unsupported" + warning " please rerun with --use-switch-source" + exit 3 fi + elif [ $CPU_arch = 'x86' ]; then + if [ $OS_bits = '32' ]; then + error "You are using a 32bit OS this is unsupported" + if [ $CPU_bits = '64' ]; then + warning " Your CPU is 64bit you should consider reinstalling with a 64bit OS" + fi + warning " please rerun with --use-switch-source" + exit 3 + elif [ $OS_bits = '64' ]; then + verbose "Correct CPU/OS detected" + else + error "Unknown OS_bits $OS_bits this is unsupported" + warning " please rerun with --use-switch-source" + exit 3 + fi + else + error "You are using a unsupported architecture $CPU_arch" fi fi @@ -88,6 +139,9 @@ resources/fusionpbx.sh #NGINX web server resources/nginx.sh +#PHP +resources/php.sh + #Fail2ban resources/fail2ban.sh @@ -98,7 +152,16 @@ if [ $USE_SWITCH_SOURCE = true ]; then else resources/switch/source-release.sh fi + + #copy the switch conf files to /etc/freeswitch + resources/switch/conf-copy.sh + + #set the file permissions resources/switch/source-permissions.sh + + #systemd service + resources/switch/source-systemd.sh + else if [ $USE_SWITCH_MASTER = true ]; then if [ $USE_SWITCH_PACKAGE_ALL = true ]; then @@ -113,7 +176,16 @@ else resources/switch/package-release.sh fi fi + + #copy the switch conf files to /etc/freeswitch + resources/switch/conf-copy.sh + + #set the file permissions resources/switch/package-permissions.sh + + #systemd service + resources/switch/package-systemd.sh + fi #Postgres diff --git a/debian/resources/fail2ban/freeswitch-ip.conf b/debian/resources/fail2ban/freeswitch-ip.conf index bb5222d..3fee3b6 100644 --- a/debian/resources/fail2ban/freeswitch-ip.conf +++ b/debian/resources/fail2ban/freeswitch-ip.conf @@ -11,7 +11,7 @@ # Values: TEXT # #2014-12-01 00:47:54.331821 [WARNING] sofia_reg.c:2752 Can't find user [1000@xxx.xxx.xxx.xxx] from 62.210.151.162 -failregex = \[WARNING\] sofia_reg.c:2752 Can't find user \[.*@\d+.\d+.\d+.\d+\] from +failregex = \[WARNING\] sofia_reg.c:\d+ Can't find user \[.*@\d+.\d+.\d+.\d+\] from # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. diff --git a/debian/resources/nginx/fusionpbx b/debian/resources/nginx/fusionpbx index bb44bd5..c324778 100644 --- a/debian/resources/nginx/fusionpbx +++ b/debian/resources/nginx/fusionpbx @@ -5,7 +5,7 @@ server{ access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; - client_max_body_size 25M; + client_max_body_size 80M; client_body_buffer_size 128k; location / { @@ -82,7 +82,7 @@ server { access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; - client_max_body_size 25M; + client_max_body_size 80M; client_body_buffer_size 128k; location / { @@ -159,7 +159,7 @@ server { access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; - client_max_body_size 25M; + client_max_body_size 80M; client_body_buffer_size 128k; location / { diff --git a/debian/resources/php.sh b/debian/resources/php.sh new file mode 100644 index 0000000..d284d71 --- /dev/null +++ b/debian/resources/php.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +#send a message +echo "Configure PHP" + +#update config if source is being used +sed 's#post_max_size = .*#post_max_size = 80M#g' -i /etc/php5/fpm/php.ini +sed 's#upload_max_filesize = .*#upload_max_filesize = 80M#g' -i /etc/php5/fpm/php.ini + +#restart php5-fpm +#systemd +/bin/systemctl restart php5-fpm + +#init.d +#/usr/sbin/service php5-fpm restart diff --git a/debian/resources/switch/conf-copy.sh b/debian/resources/switch/conf-copy.sh new file mode 100644 index 0000000..8d910a8 --- /dev/null +++ b/debian/resources/switch/conf-copy.sh @@ -0,0 +1,3 @@ +mv /etc/freeswitch /etc/freeswitch.orig +mkdir /etc/freeswitch +cp -R /var/www/fusionpbx/resources/templates/conf/* /etc/freeswitch diff --git a/debian/resources/switch/package-all.sh b/debian/resources/switch/package-all.sh index 1c0f660..a21042b 100755 --- a/debian/resources/switch/package-all.sh +++ b/debian/resources/switch/package-all.sh @@ -3,7 +3,7 @@ #initialize variable encase we are called directly [ -z $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM ] && USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=false -apt-get update && apt-get install -y --force-yes curl memcached haveged +apt-get update && apt-get install -y --force-yes ntp curl memcached haveged arch=$(uname -m) if [ $arch = 'armv7l' ] && [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = true ]; then echo "deb http://repo.sip247.com/debian/freeswitch-stable-armhf/ jessie main" > /etc/apt/sources.list.d/freeswitch.list diff --git a/debian/resources/switch/package-master-all.sh b/debian/resources/switch/package-master-all.sh index 49e2a7f..5bd4cd8 100755 --- a/debian/resources/switch/package-master-all.sh +++ b/debian/resources/switch/package-master-all.sh @@ -1,9 +1,9 @@ #!/bin/sh -apt-get update && apt-get install -y --force-yes curl memcached haveged +apt-get update && apt-get install -y --force-yes ntp curl memcached haveged curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list echo "deb http://files.freeswitch.org/repo/deb/debian-unstable/ jessie main" >> /etc/apt/sources.list.d/freeswitch.list apt-get update && apt-get install -y --force-yes freeswitch-meta-all freeswitch-all-dbg gdb - -#make sure that postgresql is started before starting freeswitch -sed -i /lib/systemd/system/freeswitch.service -e s:'local-fs.target:local-fs.target postgresql.service:' + +#make sure that postgresql is started before starting freeswitch +sed -i /lib/systemd/system/freeswitch.service -e s:'local-fs.target:local-fs.target postgresql.service:' diff --git a/debian/resources/switch/package-master.sh b/debian/resources/switch/package-master.sh index f3f3c44..20b3ea7 100755 --- a/debian/resources/switch/package-master.sh +++ b/debian/resources/switch/package-master.sh @@ -4,8 +4,8 @@ curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | ap echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list echo "deb http://files.freeswitch.org/repo/deb/debian-unstable/ jessie main" >> /etc/apt/sources.list.d/freeswitch.list apt-get update -apt-get install -y --force-yes gdb -apt-get install -y --force-yes freeswitch-meta-bare freeswitch-conf-vanilla freeswitch-systemd freeswitch-mod-commands freeswitch-meta-codecs freeswitch-mod-console freeswitch-mod-logfile freeswitch-mod-distributor +apt-get install -y --force-yes ntp gdb +apt-get install -y --force-yes freeswitch-meta-bare freeswitch-conf-vanilla freeswitch-mod-commands freeswitch-meta-codecs freeswitch-mod-console freeswitch-mod-logfile freeswitch-mod-distributor apt-get install -y --force-yes freeswitch-lang-en freeswitch-mod-say-en freeswitch-sounds-en-us-callie freeswitch-music-default apt-get install -y --force-yes freeswitch-mod-enum freeswitch-mod-cdr-csv freeswitch-mod-event-socket freeswitch-mod-sofia freeswitch-mod-sofia-dbg freeswitch-mod-loopback apt-get install -y --force-yes freeswitch-mod-conference freeswitch-mod-db freeswitch-mod-dptools freeswitch-mod-expr freeswitch-mod-fifo libyuv-dev freeswitch-mod-httapi @@ -14,6 +14,6 @@ apt-get install -y --force-yes freeswitch-mod-sndfile freeswitch-mod-native-file apt-get install -y --force-yes freeswitch-mod-xml-cdr freeswitch-mod-verto freeswitch-mod-callcenter freeswitch-mod-rtc freeswitch-mod-png freeswitch-mod-json-cdr freeswitch-mod-shout apt-get install -y --force-yes freeswitch-mod-skypopen freeswitch-mod-skypopen-dbg freeswitch-mod-sms freeswitch-mod-sms-dbg freeswitch-mod-cidlookup freeswitch-mod-memcache apt-get install -y --force-yes freeswitch-mod-imagick freeswitch-mod-tts-commandline freeswitch-mod-directory freeswitch-mod-flite - -#make sure that postgresql is started before starting freeswitch -sed -i /lib/systemd/system/freeswitch.service -e s:'local-fs.target:local-fs.target postgresql.service:' + +#make sure that postgresql is started before starting freeswitch +sed -i /lib/systemd/system/freeswitch.service -e s:'local-fs.target:local-fs.target postgresql.service:' diff --git a/debian/resources/switch/package-permissions.sh b/debian/resources/switch/package-permissions.sh index 534db12..e3cb17c 100755 --- a/debian/resources/switch/package-permissions.sh +++ b/debian/resources/switch/package-permissions.sh @@ -1,21 +1,6 @@ -#add users to the groups -usermod -a -G freeswitch www-data -usermod -a -G www-data freeswitch - -#setup owner and group, permissions and sticky -chown -R freeswitch:freeswitch /var/lib/freeswitch -chmod -R ug+rw /var/lib/freeswitch -find /var/lib/freeswitch -type d -exec chmod 2770 {} \; - -mkdir /usr/share/freeswitch/scripts -chown -R freeswitch:freeswitch /usr/share/freeswitch -chmod -R ug+rw /usr/share/freeswitch -find /usr/share/freeswitch -type d -exec chmod 2770 {} \; - -chown -R freeswitch:freeswitch /etc/freeswitch -chmod -R ug+rw /etc/freeswitch -find /etc/freeswitch -type d -exec chmod 2770 {} \; - -chown -R freeswitch:freeswitch /var/log/freeswitch -chmod -R ug+rw /var/log/freeswitch -find /var/log/freeswitch -type d -exec chmod 2770 {} \; +#default permissions +chown -R www-data:www-data /etc/freeswitch +chown -R www-data:www-data /var/lib/freeswitch +chown -R www-data:www-data /usr/share/freeswitch +chown -R www-data:www-data /var/log/freeswitch +chown -R www-data:www-data /var/run/freeswitch diff --git a/debian/resources/switch/package-release.sh b/debian/resources/switch/package-release.sh index 5242099..e98f2e6 100755 --- a/debian/resources/switch/package-release.sh +++ b/debian/resources/switch/package-release.sh @@ -12,8 +12,8 @@ else curl http://files.freeswitch.org/repo/deb/freeswitch-1.6/key.gpg | apt-key add - fi apt-get update -apt-get install -y --force-yes gdb -apt-get install -y --force-yes freeswitch-meta-bare freeswitch-conf-vanilla freeswitch-systemd freeswitch-mod-commands freeswitch-meta-codecs freeswitch-mod-console freeswitch-mod-logfile freeswitch-mod-distributor +apt-get install -y --force-yes gdb ntp +apt-get install -y --force-yes freeswitch-meta-bare freeswitch-conf-vanilla freeswitch-mod-commands freeswitch-meta-codecs freeswitch-mod-console freeswitch-mod-logfile freeswitch-mod-distributor apt-get install -y --force-yes freeswitch-lang-en freeswitch-mod-say-en freeswitch-sounds-en-us-callie freeswitch-music-default apt-get install -y --force-yes freeswitch-mod-enum freeswitch-mod-cdr-csv freeswitch-mod-event-socket freeswitch-mod-sofia freeswitch-mod-sofia-dbg freeswitch-mod-loopback apt-get install -y --force-yes freeswitch-mod-conference freeswitch-mod-db freeswitch-mod-dptools freeswitch-mod-expr freeswitch-mod-fifo libyuv-dev freeswitch-mod-httapi diff --git a/debian/resources/switch/package-systemd.sh b/debian/resources/switch/package-systemd.sh new file mode 100644 index 0000000..5213f5b --- /dev/null +++ b/debian/resources/switch/package-systemd.sh @@ -0,0 +1,7 @@ +apt-get remove -y --force-yes freeswitch-systemd +cp "$(dirname $0)/source/freeswitch.service.package" /lib/systemd/system/freeswitch.service +cp "$(dirname $0)/source/etc.default.freeswitch" /etc/default/freeswitch +systemctl enable freeswitch +systemctl unmask freeswitch.service +systemctl daemon-reload +systemctl start freeswitch diff --git a/debian/resources/switch/source-master.sh b/debian/resources/switch/source-master.sh new file mode 100755 index 0000000..69bf69d --- /dev/null +++ b/debian/resources/switch/source-master.sh @@ -0,0 +1,38 @@ +#!/bin/sh +echo "Installing the FreeSWITCH source" +DEBIAN_FRONTEND=none APT_LISTCHANGES_FRONTEND=none apt-get install -y --force-yes ntpdate libapache2-mod-log-sql-ssl libfreetype6-dev git-buildpackage doxygen yasm nasm gdb git build-essential automake autoconf 'libtool-bin|libtool' python uuid-dev zlib1g-dev 'libjpeg8-dev|libjpeg62-turbo-dev' libncurses5-dev libssl-dev libpcre3-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libspeexdsp-dev libsqlite3-dev perl libgdbm-dev libdb-dev bison libvlc-dev libvlccore-dev vlc-nox pkg-config ccache libpng-dev libvpx-dev libyuv-dev libopenal-dev libbroadvoice-dev libcodec2-dev libflite-dev libg7221-dev libilbc-dev libmongoc-dev libsilk-dev libsoundtouch-dev libmagickcore-dev liblua5.2-dev libopus-dev libsndfile-dev libopencv-dev libavformat-dev libx264-dev erlang-dev libldap2-dev libmemcached-dev libperl-dev portaudio19-dev python-dev libsnmp-dev libyaml-dev libmp4v2-dev +apt-get install -y --force-yes unzip libpq-dev memcached libshout3-dev libvpx-dev libmpg123-dev libmp3lame-dev + +apt-get update && apt-get install -y --force-yes ntp curl haveged +curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - +echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list +echo "deb http://files.freeswitch.org/repo/deb/debian-unstable/ jessie main" > /etc/apt/sources.list.d/freeswitch.list +apt-get update && apt-get upgrade +apt-get install -y --force-yes freeswitch-video-deps-most + +git clone https://freeswitch.org/stash/scm/fs/freeswitch.git /usr/src/freeswitch +cd /usr/src/freeswitch + +sed -i /usr/src/freeswitch/modules.conf -e s:'#applications/mod_avmd:applications/mod_avmd:' +sed -i /usr/src/freeswitch/modules.conf -e s:'#applications/mod_callcenter:applications/mod_callcenter:' +sed -i /usr/src/freeswitch/modules.conf -e s:'#applications/mod_cidlookup:applications/mod_cidlookup:' +sed -i /usr/src/freeswitch/modules.conf -e s:'#applications/mod_memcache:applications/mod_memcache:' +sed -i /usr/src/freeswitch/modules.conf -e s:'#applications/mod_curl:applications/mod_curl:' +sed -i /usr/src/freeswitch/modules.conf -e s:'#formats/mod_shout:formats/mod_shout:' +./bootstrap.sh -j +#./configure --prefix=/usr/local/freeswitch --enable-core-pgsql-support --enable-system-lua --disable-fhs +./configure --prefix=/usr/local/freeswitch --enable-core-pgsql-support --disable-fhs + +#make mod_shout-install +make +rm -rf /usr/local/freeswitch/{lib,mod,bin}/* +make install +make sounds-install moh-install +make hd-sounds-install hd-moh-install +make cd-sounds-install cd-moh-install + +useradd freeswitch + +#configure system service +ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli +cp "$(dirname $0)/source/freeswitch.service" /lib/systemd/system/freeswitch.service diff --git a/debian/resources/switch/source-permissions.sh b/debian/resources/switch/source-permissions.sh index 05676f6..829349e 100755 --- a/debian/resources/switch/source-permissions.sh +++ b/debian/resources/switch/source-permissions.sh @@ -1,8 +1,4 @@ -#add users to the groups -usermod -a -G freeswitch www-data -usermod -a -G www-data freeswitch - #setup owner and group, permissions and sticky -chown -R freeswitch:freeswitch /usr/local/freeswitch +chown -R www-data:www-data /usr/local/freeswitch chmod -R ug+rw /usr/local/freeswitch find /usr/local/freeswitch -type d -exec chmod 2770 {} \; diff --git a/debian/resources/switch/source-release.sh b/debian/resources/switch/source-release.sh index 3eb521c..65da808 100755 --- a/debian/resources/switch/source-release.sh +++ b/debian/resources/switch/source-release.sh @@ -1,7 +1,7 @@ #!/bin/sh echo "Installing the FreeSWITCH source" DEBIAN_FRONTEND=none APT_LISTCHANGES_FRONTEND=none apt-get install -y --force-yes ntpdate libapache2-mod-log-sql-ssl libfreetype6-dev git-buildpackage doxygen yasm nasm gdb git build-essential automake autoconf 'libtool-bin|libtool' python uuid-dev zlib1g-dev 'libjpeg8-dev|libjpeg62-turbo-dev' libncurses5-dev libssl-dev libpcre3-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libspeexdsp-dev libsqlite3-dev perl libgdbm-dev libdb-dev bison libvlc-dev libvlccore-dev vlc-nox pkg-config ccache libpng-dev libvpx-dev libyuv-dev libopenal-dev libbroadvoice-dev libcodec2-dev libflite-dev libg7221-dev libilbc-dev libmongoc-dev libsilk-dev libsoundtouch-dev libmagickcore-dev liblua5.2-dev libopus-dev libsndfile-dev libopencv-dev libavformat-dev libx264-dev erlang-dev libldap2-dev libmemcached-dev libperl-dev portaudio19-dev python-dev libsnmp-dev libyaml-dev libmp4v2-dev -apt-get install -y --force-yes unzip libpq-dev memcached libshout3-dev libvpx-dev libmpg123-dev libmp3lame-dev +apt-get install -y --force-yes ntp unzip libpq-dev memcached libshout3-dev libvpx-dev libmpg123-dev libmp3lame-dev apt-get update && apt-get install -y --force-yes curl haveged curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add - @@ -9,12 +9,18 @@ echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /e apt-get update && apt-get upgrade apt-get install -y --force-yes freeswitch-video-deps-most +#we are about to move out of the executing directory so we need to preserve it to return after we are done +CWD=$(pwd) #git clone https://freeswitch.org/stash/scm/fs/freeswitch.git /usr/src/freeswitch #git clone -b v1.6 https://freeswitch.org/stash/scm/fs/freeswitch.git /usr/src/freeswitch -cd /usr/src && wget http://files.freeswitch.org/freeswitch-releases/freeswitch-1.6.9.zip -unzip freeswitch-1.6.9.zip +SWITCH_MAJOR=$(git ls-remote --heads https://freeswitch.org/stash/scm/fs/freeswitch.git "v*" | cut -d/ -f 3 | grep -P '^v\d+\.\d+' | sort | tail -n 1| cut -dv -f2) +SWITCH_VERSION=$(git ls-remote --tags https://freeswitch.org/stash/scm/fs/freeswitch.git v$SWITCH_MAJOR.* | cut -d/ -f3 | sort | tail -n1 | cut -dv -f2) +echo "Using version $SWITCH_VERSION" +cd /usr/src +wget http://files.freeswitch.org/freeswitch-releases/freeswitch-$SWITCH_VERSION.zip +unzip freeswitch-$SWITCH_VERSION.zip rm -R freeswitch -cp -R freeswitch-1.6.9 freeswitch +mv freeswitch-$SWITCH_VERSION freeswitch cd freeswitch #./bootstrap.sh -j @@ -35,8 +41,12 @@ make sounds-install moh-install make hd-sounds-install hd-moh-install make cd-sounds-install cd-moh-install +#return to the executing directory +cd $CWD + useradd freeswitch #configure system service ln -s /usr/local/freeswitch/bin/fs_cli /usr/bin/fs_cli -cp "$(dirname $0)/source/freeswitch.service" /lib/systemd/system/freeswitch.service \ No newline at end of file +cp "$(dirname $0)/source/freeswitch.service" /lib/systemd/system/freeswitch.service +cp "$(dirname $0)/source/etc.default.freeswitch.source /etc/default/freeswitch diff --git a/debian/resources/switch/source-systemd.sh b/debian/resources/switch/source-systemd.sh new file mode 100644 index 0000000..dc34e3d --- /dev/null +++ b/debian/resources/switch/source-systemd.sh @@ -0,0 +1,5 @@ +cp "$(dirname $0)/source/freeswitch.service.source" /lib/systemd/system/freeswitch.service +cp "$(dirname $0)/source/etc.default.freeswitch" /etc/default/freeswitch +systemctl enable freeswitch +systemctl unmask freeswitch.service +systemctl daemon-reload diff --git a/debian/resources/switch/source/etc.default.freeswitch b/debian/resources/switch/source/etc.default.freeswitch new file mode 100644 index 0000000..456983a --- /dev/null +++ b/debian/resources/switch/source/etc.default.freeswitch @@ -0,0 +1,4 @@ +# /etc/default/freeswitch +FS_USER="www-data" +FS_GROUP="www-data" +DAEMON_OPTS="-nonat -ncwait -u www-data -g www-data -run /var/run/freeswitch" diff --git a/debian/resources/switch/source/freeswitch.service.package b/debian/resources/switch/source/freeswitch.service.package new file mode 100644 index 0000000..148cf85 --- /dev/null +++ b/debian/resources/switch/source/freeswitch.service.package @@ -0,0 +1,56 @@ +;;;;; Author: Travis Cross + +[Unit] +Description=freeswitch +After=syslog.target network.target local-fs.target postgresql.service + +[Service] +; service +Type=forking +PIDFile=/run/freeswitch/freeswitch.pid +Environment="DAEMON_OPTS=-nonat" +EnvironmentFile=-/etc/default/freeswitch +ExecStartPre=/bin/mkdir -p /var/run/freeswitch/ +ExecStartPre=/bin/chown -R www-data:www-data /var/run/freeswitch/ +ExecStart=/usr/bin/freeswitch -u www-data -g www-data -ncwait $DAEMON_OPTS +TimeoutSec=45s +Restart=always +; exec +User=root +Group=daemon +LimitCORE=infinity +LimitNOFILE=100000 +LimitNPROC=60000 +LimitSTACK=250000 +LimitRTPRIO=infinity +LimitRTTIME=7000000 +IOSchedulingClass=realtime +IOSchedulingPriority=2 +CPUSchedulingPolicy=rr +CPUSchedulingPriority=89 +UMask=0007 + +; alternatives which you can enforce by placing a unit drop-in into +; /etc/systemd/system/freeswitch.service.d/*.conf: +; +; User=freeswitch +; Group=freeswitch +; ExecStart= +; ExecStart=/usr/bin/freeswitch -ncwait -nonat -rp +; +; empty ExecStart is required to flush the list. +; +; if your filesystem supports extended attributes, execute +; setcap 'cap_net_bind_service,cap_sys_nice=+ep' /usr/bin/freeswitch +; this will also allow socket binding on low ports +; +; otherwise, remove the -rp option from ExecStart and +; add these lines to give real-time priority to the process: +; +; PermissionsStartOnly=true +; ExecStartPost=/bin/chrt -f -p 1 $MAINPID +; +; execute "systemctl daemon-reload" after editing the unit files. + +[Install] +WantedBy=multi-user.target diff --git a/debian/resources/switch/source/freeswitch.service b/debian/resources/switch/source/freeswitch.service.source similarity index 84% rename from debian/resources/switch/source/freeswitch.service rename to debian/resources/switch/source/freeswitch.service.source index ae08231..827e353 100644 --- a/debian/resources/switch/source/freeswitch.service +++ b/debian/resources/switch/source/freeswitch.service.source @@ -2,15 +2,16 @@ [Unit] Description=freeswitch -After=syslog.target network.target local-fs.target postgresql.service - +After=syslog.target network.target local-fs.target postgresql.service haveged.service + [Service] ; service Type=forking PIDFile=/run/freeswitch/freeswitch.pid Environment="DAEMON_OPTS=-nonat" EnvironmentFile=-/etc/default/freeswitch -ExecStart=/usr/local/freeswitch/bin/freeswitch -u freeswitch -g freeswitch -ncwait $DAEMON_OPTS +ExecStart=/usr/local/freeswitch/bin/freeswitch -u www-data -g www-data -ncwait $DAEMON_OPTS +;ExecStart=/usr/local/freeswitch/bin/freeswitch -u freeswitch -g freeswitch -ncwait $DAEMON_OPTS TimeoutSec=45s Restart=always ; exec @@ -51,4 +52,4 @@ UMask=0007 ; execute "systemctl daemon-reload" after editing the unit files. [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/install.sh b/install.sh index 51cdf81..a2c6ee9 100644 --- a/install.sh +++ b/install.sh @@ -45,6 +45,7 @@ chmod +x $0 #Os/Distro Check os_check=$(lsb_release -is) +real_os=$os_check check_major_release=$(lsb_release -rs | cut -d. -f1) os_unsupported () { @@ -54,6 +55,10 @@ os_unsupported () { exit 2; } +if [ $os_check = 'Raspbian' ]; then + echo "${yellow}Detected Raspbian, using Debian for compatibility${normal}" + os_check="Debian" +fi if [ $os_check = 'Debian' ]; then if [ $check_major_release -ge 8 ]; then verbose "Removing the CD image from /etc/apt/sources.list" @@ -73,7 +78,7 @@ if [ $os_check = 'Debian' ]; then cd /usr/src/fusionpbx-install.sh/debian ./install.sh $@ else - error "Although you are running Debian we require version >= 8" + error "Although you are running $real_os we require version >= 8" os_unsupported fi else