Module: kamailio
Branch: 6.0
Commit: c42fb5b9bd4efd2db240c97a6c7044701696098c
URL: 
https://github.com/kamailio/kamailio/commit/c42fb5b9bd4efd2db240c97a6c7044701696098c

Author: Sergey Safarov <[email protected]>
Committer: Sergey Safarov <[email protected]>
Date: 2026-01-05T13:36:40+02:00

pkg/kamailio: fixed systemd unit file inititlization

(cherry picked from commit e221ef539d16570840f004c397909441bac58cce)

---

Added: pkg/kamailio/obs/kamailio.preset
Modified: pkg/kamailio/obs/kamailio.spec

---

Diff:  
https://github.com/kamailio/kamailio/commit/c42fb5b9bd4efd2db240c97a6c7044701696098c.diff
Patch: 
https://github.com/kamailio/kamailio/commit/c42fb5b9bd4efd2db240c97a6c7044701696098c.patch

---

diff --git a/pkg/kamailio/obs/kamailio.preset b/pkg/kamailio/obs/kamailio.preset
new file mode 100644
index 00000000000..25ab2dd2250
--- /dev/null
+++ b/pkg/kamailio/obs/kamailio.preset
@@ -0,0 +1 @@
+enable kamailio.service
diff --git a/pkg/kamailio/obs/kamailio.spec b/pkg/kamailio/obs/kamailio.spec
index 7b17b3a6f45..c171db0d1d2 100644
--- a/pkg/kamailio/obs/kamailio.spec
+++ b/pkg/kamailio/obs/kamailio.spec
@@ -216,6 +216,7 @@ Conflicts:  kamailio-xmlrpc < %ver, kamailio-xmpp < %ver
 Conflicts:  kamailio-uuid < %ver
 Requires:  systemd
 BuildRequires:  systemd-devel
+BuildRequires:  systemd-rpm-macros
 BuildRequires: bison
 BuildRequires: cmake
 BuildRequires: flex
@@ -1215,9 +1216,7 @@ kazoo \
 %endif
 lcr \
 ldap \
-%if "%{?_unitdir}" != ""
 log_systemd \
-%endif
 lost \
 %if %{with lwsc}
 lwsc \
@@ -1271,9 +1270,7 @@ sctp \
 siprepo \
 slack \
 snmpstats \
-%if "%{?_unitdir}" != ""
 systemdops \
-%endif
 tls \
 %if %{with wolfssl}
 tls_wolfssl \
@@ -1314,6 +1311,7 @@ rm -f 
%{buildroot}%{_sysconfdir}/kamailio/pi_framework.xml.sample
 install -d %{buildroot}%{_sharedstatedir}/kamailio
 
 install -d %{buildroot}%{_unitdir}
+install -Dpm 0644 pkg/kamailio/obs/kamailio.preset 
%{buildroot}%{_presetdir}/kamailio.preset
 install -Dpm 0644 pkg/kamailio/obs/kamailio.service 
%{buildroot}%{_unitdir}/kamailio.service
 install -Dpm 0644 pkg/kamailio/obs/[email protected] 
%{buildroot}%{_unitdir}/[email protected]
 install -Dpm 0644 pkg/kamailio/obs/kamailio.tmpfiles 
%{buildroot}%{_tmpfilesdir}/kamailio.conf
@@ -1355,28 +1353,15 @@ rm -rf %{buildroot}
 
 
 %post
-%if "%{?_unitdir}" == ""
-/sbin/chkconfig --add kamailio
-%else
-%tmpfiles_create kamailio.conf
-/usr/bin/systemctl -q enable kamailio.service
-%endif
+%tmpfiles_create %{name}.conf
+%systemd_post %{name}.service
 
 
 %preun
-if [ $1 = 0 ]; then
-%if "%{?_unitdir}" == ""
-    /sbin/service kamailio stop > /dev/null 2>&1
-    /sbin/chkconfig --del kamailio
-%else
-    %{?systemd_preun kamailio.service}
-%endif
-fi
+%systemd_preun %{name}.service
 
-%if "%{?_unitdir}" == ""
 %postun
-%{?systemd_postun kamailio.service}
-%endif
+%systemd_postun %{name}.service
 
 %files
 %defattr(-,root,root)
@@ -1513,10 +1498,8 @@ fi
 %doc %{_docdir}/kamailio/modules/README.statsc
 %doc %{_docdir}/kamailio/modules/README.topos
 %doc %{_docdir}/kamailio/modules/README.cfgt
-%if "%{?_unitdir}" != ""
 %doc %{_docdir}/kamailio/modules/README.log_systemd
 %doc %{_docdir}/kamailio/modules/README.systemdops
-%endif
 
 %dir %attr(-,kamailio,kamailio) %{_sysconfdir}/kamailio
 %config(noreplace) %{_sysconfdir}/kamailio/dictionary.kamailio
@@ -1530,14 +1513,10 @@ fi
 %else
 %config %{_sysconfdir}/sysconfig/kamailio
 %endif
-%if "%{?_unitdir}" == ""
-%config %{_sysconfdir}/rc.d/init.d/*
-%dir %attr(-,kamailio,kamailio) %{_var}/run/kamailio
-%else
 %{_unitdir}/kamailio.service
 %{_unitdir}/[email protected]
+%{_presetdir}/kamailio.preset
 %{_tmpfilesdir}/kamailio.conf
-%endif
 
 %dir %{_libdir}/kamailio
 
@@ -1670,10 +1649,8 @@ fi
 %{_libdir}/kamailio/modules/topos.so
 %{_libdir}/kamailio/modules/topos_htable.so
 %{_libdir}/kamailio/modules/cfgt.so
-%if "%{?_unitdir}" != ""
 %{_libdir}/kamailio/modules/log_systemd.so
 %{_libdir}/kamailio/modules/systemdops.so
-%endif
 
 %{_sbindir}/kamailio
 %{_sbindir}/kamctl

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to