FS-8194 FS-7910 FS-7937 systemd service improvements

freeswitch-systemd.freeswitch.service:
* starting the daemon as root and switchig to freeswitch user
* respecting the options in /etc/default/freeswitch
* RuntimeDirectory parameter is replaced with a tmpfiles.d entry
  because /run/freeswitch has to be owned by freeswitch user
* instructions how to start it as non-root

debian/freeswitch-systemd.freeswitch.tmpfile:
* this defines the PID directory with correct permissions

debian/bootstrap.sh, debian/rules:
* proper handling of freeswitch.service
* deleted debian/freeswitch-systemd.install because it caused an error
  in dh_install because it's run before dh_installinit
* renamed: freeswitch-sysvinit.freeswitch.default -> freeswitch-systemd.freeswitch.default
  because sysvinit support will eventually die out

debian/freeswitch.postinst:
* run "systemctl enable freeswitch" if systemctl is available

CAVEAT: only one option is supported in /etc/default/freeswitch because the
variable ${DAEMON_OPTS} is expanded as a single token. This will be fixed
as soon as freeswitch-sysvinit is removed from freeswitch-all.
v1.6
Stanislav Sinyagin 7 years ago
parent a5a3561b2b
commit b2bcc8b2dd
  1. 10
      debian/bootstrap.sh
  2. 0
      debian/freeswitch-systemd.freeswitch.default
  3. 32
      debian/freeswitch-systemd.freeswitch.service
  4. 1
      debian/freeswitch-systemd.freeswitch.tmpfile
  5. 1
      debian/freeswitch-systemd.install
  6. 3
      debian/freeswitch.postinst
  7. 3
      debian/rules

@ -1324,8 +1324,14 @@ for x in postinst postrm preinst prerm; do
cp -a freeswitch.$x freeswitch-all.$x
done
cp -a freeswitch-doc.docs freeswitch-all.docs
#cp -a freeswitch-systemd.freeswitch.service freeswitch-all.freeswitch.service
cp -a freeswitch-sysvinit.freeswitch.default freeswitch-all.freeswitch.default
cp -a freeswitch-systemd.freeswitch.service freeswitch-all.freeswitch.service
cp -a freeswitch-systemd.freeswitch.tmpfile freeswitch-all.freeswitch.tmpfile
cp -a freeswitch-systemd.freeswitch.default freeswitch-all.freeswitch.default
cp -a freeswitch-systemd.freeswitch.default freeswitch-sysvinit.freeswitch.default
# TODO: FS-7928 need to add a condition and skip this for jessie and onward
cp -a freeswitch-sysvinit.freeswitch.init freeswitch-all.freeswitch.init
echo "Generating additional lintian overrides..." >&2

@ -8,14 +8,14 @@ After=syslog.target network.target local-fs.target
; service
Type=forking
PIDFile=/run/freeswitch/freeswitch.pid
ExecStart=/usr/bin/freeswitch -ncwait -nonat
Environment="DAEMON_OPTS=-nonat"
EnvironmentFile=-/etc/default/freeswitch
ExecStart=/usr/bin/freeswitch -u freeswitch -g freeswitch -ncwait ${DAEMON_OPTS}
TimeoutSec=45s
Restart=always
; exec
RuntimeDirectory=freeswitch
RuntimeDirectoryMode=0755
User=freeswitch
Group=freeswitch
User=root
Group=daemon
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
@ -28,5 +28,27 @@ 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

@ -0,0 +1 @@
d /var/run/freeswitch 0755 freeswitch freeswitch - -

@ -1 +0,0 @@
/lib/systemd/system/freeswitch.service

@ -37,6 +37,9 @@ case "$1" in
mkdir -p /etc/freeswitch/tls/
chown freeswitch:freeswitch /etc/freeswitch/tls
fi
if [ -x /bin/systemctl -a x`systemctl is-enabled freeswitch` != "xenabled" ]; then
systemctl enable freeswitch
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;

3
debian/rules vendored

@ -98,12 +98,11 @@ override_dh_strip:
override_dh_auto_install:
dh_auto_install
dh_auto_install -- -C libs/esl pymod-install
mkdir -p debian/tmp/lib/systemd/system
install -m0644 debian/freeswitch-systemd.freeswitch.service debian/tmp/lib/systemd/system/freeswitch.service
rm -f debian/tmp/usr/share/freeswitch/grammar/model/communicator/COPYING
override_dh_installinit:
dh_installinit -pfreeswitch-sysvinit --name=freeswitch
dh_installinit -pfreeswitch-systemd --name=freeswitch
dh_installinit -pfreeswitch-all --name=freeswitch
override_dh_makeshlibs:

Loading…
Cancel
Save