[kannel] Migrate to systemd.
Jon Ciesla
limb at fedoraproject.org
Thu May 10 20:01:58 UTC 2012
commit dd990e3d0cdc1f0cddaf7e013385f5a2e140dbdf
Author: Jon Ciesla <limburgher at gmail.com>
Date: Thu May 10 15:01:46 2012 -0500
Migrate to systemd.
kannel-bearerbox.service | 11 ++++++++
kannel-smsbox.service | 12 +++++++++
kannel-wapbox.service | 12 +++++++++
kannel.spec | 59 ++++++++++++++++++++++++++++++++++++---------
4 files changed, 82 insertions(+), 12 deletions(-)
---
diff --git a/kannel-bearerbox.service b/kannel-bearerbox.service
new file mode 100644
index 0000000..c8b4da0
--- /dev/null
+++ b/kannel-bearerbox.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Kannel Bearerbox
+After=local-fs.target remote-fs.target network.target
+
+[Service]
+User=kannel
+Type=forking
+ExecStart=/usr/sbin/start-stop-kannel --start --background --exec /usr/sbin/bearerbox /etc/kannel.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/kannel-smsbox.service b/kannel-smsbox.service
new file mode 100644
index 0000000..f7a74d9
--- /dev/null
+++ b/kannel-smsbox.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kannel SMSbox
+Requires=kannel-bearerbox.service
+After=local-fs.target remote-fs.target network.target kannel-bearerbox.service
+
+[Service]
+User=kannel
+Type=forking
+ExecStart=/usr/sbin/start-stop-kannel --start --background --exec /usr/sbin/smsbox /etc/kannel.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/kannel-wapbox.service b/kannel-wapbox.service
new file mode 100644
index 0000000..4b6835d
--- /dev/null
+++ b/kannel-wapbox.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kannel Wapbox
+Requires=kannel-bearerbox.service
+After=local-fs.target remote-fs.target network.target kannel-bearerbox.service
+
+[Service]
+User=kannel
+Type=forking
+ExecStart=/usr/sbin/start-stop-kannel --start --background --exec /usr/sbin/wapbox /etc/kannel.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/kannel.spec b/kannel.spec
index 680f589..1f431ef 100644
--- a/kannel.spec
+++ b/kannel.spec
@@ -1,15 +1,17 @@
Summary: WAP and SMS gateway
Name: kannel
Version: 1.4.3
-Release: 7%{?dist}
+Release: 8%{?dist}
License: BSD
Group: System Environment/Daemons
URL: http://www.kannel.org/
Source0: http://www.kannel.org/download/%{version}/gateway-%{version}.tar.bz2
Source1: kannel.logrotate
-Source2: kannel.init
+Source2: kannel-bearerbox.service
Source3: kannel.conf
Source4: gw-config
+Source5: kannel-wapbox.service
+Source6: kannel-smsbox.service
# TODO: a corresponding configure.in patch could be upstreamable?
Patch0: gateway-1.4.3-ssldetect.patch
Patch1: gateway-1.4.1-typesh.patch
@@ -22,6 +24,11 @@ BuildRequires: sqlite-devel
# For the docs...
BuildRequires: jadetex, tetex-dvips, docbook-dtds, docbook-style-dsssl
BuildRequires: ImageMagick, transfig
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# For triggerun
+Requires(post): systemd-sysv
%description
The Kannel Open Source WAP and SMS gateway works as both an SMS gateway, for
@@ -93,8 +100,10 @@ This package contains documentation for the Kannel WAP and SMS gateway.
%{__install} -m 0755 test/{fakesmsc,fakewap} %{buildroot}%{_bindir}/
# Logrotate entry
%{__install} -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/kannel
-# Init script
-%{__install} -D -m 0755 %{SOURCE2} %{buildroot}%{_sysconfdir}/rc.d/init.d/kannel
+# Unit files
+%{__install} -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/kannel-bearerbox.service
+%{__install} -D -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/kannel-wapbox.service
+%{__install} -D -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/kannel-smsbox.service
# Default configuration file
%{__install} -D -m 0640 %{SOURCE3} %{buildroot}%{_sysconfdir}/kannel.conf
# Empty log directory
@@ -120,27 +129,50 @@ This package contains documentation for the Kannel WAP and SMS gateway.
-d %{_var}/lib/kannel kannel &>/dev/null || :
%post
-/sbin/chkconfig --add kannel
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
%preun
-if [ $1 -eq 0 ]; then
- # Last removal, stop service and remove it
- /sbin/service kannel stop &>/dev/null || :
- /sbin/chkconfig --del kannel
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable kannel-bearerbox.service > /dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable kannel-wapbox.service > /dev/null 2>&1 || :
+ /bin/systemctl --no-reload disable kannel-smsbox.service > /dev/null 2>&1 || :
+ /bin/systemctl stop kannel-bearerbox.service > /dev/null 2>&1 || :
+ /bin/systemctl stop kannel-wapbox.service > /dev/null 2>&1 || :
+ /bin/systemctl stop kannel-smsbox.service > /dev/null 2>&1 || :
fi
%postun
-if [ $1 -ge 1 ]; then
- /sbin/service kannel condrestart &>/dev/null || :
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart kannel-bearerbox.service >/dev/null 2>&1 || :
+ /bin/systemctl try-restart kannel-wapbox.service >/dev/null 2>&1 || :
+ /bin/systemctl try-restart kannel-smsbox.service >/dev/null 2>&1 || :
fi
+%triggerun -- kannel < 1.4.3-8
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply kannel
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save kannel >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del kannel >/dev/null 2>&1 || :
+/bin/systemctl try-restart kannel-bearerbox.service >/dev/null 2>&1 || :
+/bin/systemctl try-restart kannel-wapbox.service >/dev/null 2>&1 || :
+/bin/systemctl try-restart kannel-smsbox.service >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog NEWS README STATUS
%attr(0640,kannel,kannel) %config(noreplace) %{_sysconfdir}/kannel.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/kannel
-%{_sysconfdir}/rc.d/init.d/kannel
+%{_unitdir}/kannel-*box.service
%{_bindir}/fakesmsc
%{_bindir}/fakewap
%{_bindir}/mtbatch
@@ -164,6 +196,9 @@ fi
%changelog
+* Thu May 10 2012 Jon Ciesla <limburgher at gmail.com> - 1.4.3-8
+- Migrate to systemd, BZ 789714.
+
* Fri Feb 10 2012 Petr Pisar <ppisar at redhat.com> - 1.4.3-7
- Rebuild against PCRE 8.30
More information about the scm-commits
mailing list