some untested code for the source install - source installation is broken in Debian installation script and I have not debugged the problem. Focusing on the packaged version first.

This commit is contained in:
smwalter 2017-04-27 17:55:13 +09:00
parent fd85a99ae0
commit 4ddb305297
6 changed files with 155 additions and 123 deletions

View File

@ -4,10 +4,19 @@ echo "Installing the FreeSWITCH source"
DEBIAN_FRONTEND=none APT_LISTCHANGES_FRONTEND=none apt-get install -y -q 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 -q ntp unzip libpq-dev memcached libshout3-dev libvpx-dev libmpg123-dev libmp3lame-dev
# E: Unable to locate package libyuv-dev
# E: Unable to locate package libbroadvoice-dev
# E: Unable to locate package libcodec2-dev
# E: Unable to locate package libflite-dev
# E: Unable to locate package libg7221-dev
# E: Unable to locate package libilbc-dev
# E: Unable to locate package libmongoc-dev
# E: Unable to locate package libsilk-dev
apt-get update && apt-get install -y -q 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
apt-get update && apt-get upgrade
apt-get -q update && apt-get upgrade -y -q
apt-get install -y -q 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
@ -52,5 +61,6 @@ cd $CWD
#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
cp "$(dirname $0)/source/etc.default.freeswitch.source /etc/default/freeswitch
cp "$(dirname $0)/source/freeswitch.init" /etc/init.d/freeswitch
chmod a+x /etc/init.d/freeswitch
cp "$(dirname $0)/source/etc.default.freeswitch /etc/default/freeswitch

View File

@ -1,10 +1,6 @@
#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
cp "$(dirname $0)/source/freeswitch.init" /etc/init.d/freeswitch
cp "$(dirname $0)/source/etc.default.freeswitch" /etc/default/freeswitch
update-rc.d freeswitch enable
service freeswitch restart
# re-write for sysvinit
# remember to restart freeswitch at the end
echo "Please configure the sysvinit start up script from the source dir and contribute code here. Thank you."
echo "Please configure the sysvinit start up script from the source dir, test, and contribute code. Thank you."

View File

@ -2,3 +2,7 @@
FS_USER="www-data"
FS_GROUP="www-data"
DAEMON_OPTS="-nonat -ncwait -u www-data -g www-data -run /var/run/freeswitch"
# this is the packaged version. But since the source install does not work. I've not tested any of this.
# /etc/default/freeswitch
#DAEMON_OPTS="-nonat"

View File

@ -0,0 +1,133 @@
#!/bin/sh
### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
### BEGIN INIT INFO
# Provides: freeswitch
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Should-Start: postgresql mysql memcached mongodb
# Should-Stop: postgresql mysql memcached mongodb
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: FreeSWITCH Softswitch
# Description: FreeSWITCH Softswitch
### END INIT INFO
# Author: Travis Cross <tc@traviscross.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=freeswitch
NAME=freeswitch
DAEMON=/usr/bin/freeswitch
USER=freeswitch
DAEMON_ARGS="-u $USER -ncwait"
CONFDIR=/etc/$NAME
RUNDIR=/var/run/$NAME
PIDFILE=$RUNDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
WORKDIR=/var/log/$NAME
[ -x $DAEMON ] || exit 0
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start() {
if ! [ -f $CONFDIR/freeswitch.xml ]; then
echo "$NAME is not configured so not starting.">&2
echo "Please add configuration under /etc/freeswitch">&2
echo "e.g. Install freeswitch-conf-vanilla, then:">&2
echo "cp -a /usr/share/freeswitch/conf/vanilla /etc/freeswitch">&2
return 3
fi
# Directory in /var/run may disappear on reboot (e.g. when tmpfs used for /var/run).
mkdir -p $RUNDIR
chown -R $USER: $RUNDIR
chmod -R ug=rwX,o= $RUNDIR
start-stop-daemon --start --quiet \
--pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
--test > /dev/null \
|| return 1
ulimit -s 240
start-stop-daemon --start --quiet \
--pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
--chdir $WORKDIR -- $DAEMON_ARGS $DAEMON_OPTS \
|| return 2
return 0
}
stop_fs() {
start-stop-daemon --stop --quiet \
--pidfile $PIDFILE --name $NAME --user $USER \
--retry=TERM/30/KILL/5
}
stop_fs_children() {
start-stop-daemon --stop --quiet \
--exec $DAEMON \
--oknodo --retry=0/30/KILL/5
}
do_stop() {
stop_fs
RETVAL="$?"
[ "$RETVAL" -eq 2 ] && return 2
stop_fs_children
[ "$?" -eq 2 ] && return 2
rm -f $PIDFILE
return "$RETVAL"
}
do_reload() {
start-stop-daemon --stop --quiet \
--pidfile $PIDFILE --name $NAME --user $USER \
--signal HUP
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
reload|force-reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1|*) log_end_msg 1 ;;
esac
;;
*) log_end_msg 1 ;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
exit 0

View File

@ -1,56 +0,0 @@
;;;;; Author: Travis Cross <tc@traviscross.com>
[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=infinity
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

View File

@ -1,55 +0,0 @@
;;;;; Author: Travis Cross <tc@traviscross.com>
[Unit]
Description=freeswitch
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 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
User=root
Group=daemon
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
LimitSTACK=240K
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