Module: kamailio
Branch: 5.8
Commit: d01fbe59b386ad025466bd13d71495f4c765f85d
URL:
https://github.com/kamailio/kamailio/commit/d01fbe59b386ad025466bd13d71495f…
Author: Sergey Safarov <s.safarov(a)anycast-lb.net>
Committer: Sergey Safarov <s.safarov(a)anycast-lb.net>
Date: 2024-12-06T18:14:00+02:00
pkg/kamailio/obs: added systemd template to start multiple kamailio services
GH#3904
(cherry picked from commit b4ec854c0822a61790ea4fa1bc6387cddce4cf35)
---
Added: pkg/kamailio/obs/kamailio@.service
Modified: pkg/kamailio/obs/kamailio.service
Modified: pkg/kamailio/obs/kamailio.spec
---
Diff:
https://github.com/kamailio/kamailio/commit/d01fbe59b386ad025466bd13d71495f…
Patch:
https://github.com/kamailio/kamailio/commit/d01fbe59b386ad025466bd13d71495f…
---
diff --git a/pkg/kamailio/obs/kamailio.service b/pkg/kamailio/obs/kamailio.service
index 14a2e580890..0c4fbc49caf 100644
--- a/pkg/kamailio/obs/kamailio.service
+++ b/pkg/kamailio/obs/kamailio.service
@@ -1,5 +1,6 @@
[Unit]
Description=Kamailio - the Open Source SIP Server
+Documentation=man:kamailio(8)
Wants=network-online.target
After=network-online.target
diff --git a/pkg/kamailio/obs/kamailio.spec b/pkg/kamailio/obs/kamailio.spec
index 423f7f9f3de..e889b0df375 100644
--- a/pkg/kamailio/obs/kamailio.spec
+++ b/pkg/kamailio/obs/kamailio.spec
@@ -1200,6 +1200,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
@@ -1449,6 +1450,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
@@ -1680,6 +1682,7 @@ fi
%dir %attr(-,kamailio,kamailio) %{_var}/run/kamailio
%else
%{_unitdir}/kamailio.service
+%{_unitdir}/kamailio@.service
%{_tmpfilesdir}/kamailio.conf
%endif
diff --git a/pkg/kamailio/obs/kamailio@.service b/pkg/kamailio/obs/kamailio@.service
new file mode 100644
index 00000000000..44a4c02a5a1
--- /dev/null
+++ b/pkg/kamailio/obs/kamailio@.service
@@ -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