Skip to content

Commit

Permalink
pkg/kamailio/obs: added systemd template to start multiple kamailio s…
Browse files Browse the repository at this point in the history
…ervices

GH#3904
  • Loading branch information
sergey-safarov committed Dec 6, 2024
1 parent 11df362 commit b4ec854
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/kamailio/obs/kamailio.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[Unit]
Description=Kamailio - the Open Source SIP Server
Documentation=man:kamailio(8)
Wants=network-online.target
After=network-online.target

Expand Down
3 changes: 3 additions & 0 deletions pkg/kamailio/obs/kamailio.spec
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ sed -i -e 's/python3/python2/' utils/kamctl/dbtextdb/dbtextdb.py
# on latest dist need to add --atexit=no for Kamailio options. More details GH #2616
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} >= 8
sed -i -e 's|/usr/sbin/kamailio|/usr/sbin/kamailio --atexit=no|' pkg/kamailio/obs/kamailio.service
sed -i -e 's|/usr/sbin/kamailio|/usr/sbin/kamailio --atexit=no|' pkg/kamailio/obs/kamailio@.service
%endif


Expand Down Expand Up @@ -1436,6 +1437,7 @@ install -m755 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.init \
# systemd
install -d %{buildroot}%{_unitdir}
install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.service %{buildroot}%{_unitdir}/kamailio.service
install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio@.service %{buildroot}%{_unitdir}/kamailio@.service
install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/sipcapture.service %{buildroot}%{_unitdir}/sipcapture.service
install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/kamailio.tmpfiles %{buildroot}%{_tmpfilesdir}/kamailio.conf
install -Dpm 0644 pkg/kamailio/%{dist_name}/%{dist_version}/sipcapture.tmpfiles %{buildroot}%{_tmpfilesdir}/sipcapture.conf
Expand Down Expand Up @@ -1666,6 +1668,7 @@ fi
%dir %attr(-,kamailio,kamailio) %{_var}/run/kamailio
%else
%{_unitdir}/kamailio.service
%{_unitdir}/kamailio@.service
%{_tmpfilesdir}/kamailio.conf
%endif

Expand Down
28 changes: 28 additions & 0 deletions pkg/kamailio/obs/kamailio@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Unit]
Description=Kamailio - the Open Source SIP Server (instance %i)
Documentation=man:kamailio(8)
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=kamailio
Group=kamailio
Environment='CFGFILE=/etc/kamailio/kamailio-%i.cfg'
Environment='SHM_MEMORY=64'
Environment='PKG_MEMORY=8'
EnvironmentFile=-/etc/sysconfig/kamailio-%i
EnvironmentFile=-/etc/sysconfig/kamailio-%i.d/*
# PIDFile requires a full absolute path
PIDFile=/run/kamailio-%i/kamailio.pid
# ExecStart requires a full absolute path
ExecStart=/usr/sbin/kamailio -DD -P /run/kamailio-%i/kamailio.pid -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -Y /run/kamailio-%i
Restart=on-failure
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio-%i
RuntimeDirectoryMode=0770

[Install]
WantedBy=multi-user.target

0 comments on commit b4ec854

Please sign in to comment.