[bacula2] Systemd migration.

Jon Ciesla limb at fedoraproject.org
Tue Nov 22 15:56:53 UTC 2011


commit d3c9f0b393ae2149235ef2b3041f884050b84e47
Author: Jon Ciesla <limb at jcomserv.net>
Date:   Tue Nov 22 09:55:43 2011 -0600

    Systemd migration.

 bacula2-fd.service |   11 ++++++++++
 bacula2.spec       |   53 ++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 52 insertions(+), 12 deletions(-)
---
diff --git a/bacula2-fd.service b/bacula2-fd.service
new file mode 100644
index 0000000..decaf95
--- /dev/null
+++ b/bacula2-fd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Bacula2 Backup Client
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/bacula-fd.9102.pid
+ExecStart=/usr/sbin/bacula2-fd -c /etc/bacula2/bacula-fd.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bacula2.spec b/bacula2.spec
index f77b8ff..dddba5e 100644
--- a/bacula2.spec
+++ b/bacula2.spec
@@ -4,12 +4,13 @@
 Summary: Backup client for bacula version 2 server
 Name: bacula2
 Version: 2.4.4
-Release: 7%{?dist}
+Release: 8%{?dist}
 # See LICENSE for details
 License: GPLv2 with exceptions
 Group: System Environment/Daemons
 Source0: http://downloads.sf.net/bacula/bacula-%{version}.tar.gz
-Source7: bacula2-fd.init
+#Source7: bacula2-fd.init
+Source8: bacula2-fd.service
 Patch0:	bacula2-2.4.4-utf8.patch
 Patch1: bacula2-config.patch
 Patch2: bacula2-3.0.2-openssl.patch
@@ -19,7 +20,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: openssl-devel, perl
 BuildRequires: libacl-devel, zlib-devel, python-devel, 
 BuildRequires: libstdc++-devel, libxml2-devel, pkgconfig
-BuildRequires: glibc-devel, sed
+BuildRequires: glibc-devel, sed, systemd-units
 # This is actually tcp_wrappers-devel but I don't want to deviate from the main
 # Fedora/EPEL packages without good reason.
 BuildRequires: /usr/include/tcpd.h
@@ -38,10 +39,15 @@ The bacula2 packages are clients suitable for use with a bacula version
 Summary: Bacula backup client
 Group: System Environment/Daemons
 Requires: bacula2-common = %{version}-%{release}
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+#Requires(post): /sbin/chkconfig
+#Requires(preun): /sbin/chkconfig
+#Requires(preun): /sbin/service
+#Requires(postun): /sbin/service
+Requires(post): systemd-units
+Requires(post): systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+
 
 %description client
 Bacula is a set of programs that allow you to manage the backup, recovery,
@@ -118,7 +124,8 @@ make install DESTDIR=%{buildroot}
 mkdir -p %{buildroot}%{_bindir}
 
 # Initscript
-install -m 755 -D %{SOURCE7}  %{buildroot}%{_initrddir}/bacula2-fd
+#install -m 755 -D %{SOURCE7}  %{buildroot}%{_initrddir}/bacula2-fd
+install -m 755 -D %{SOURCE8}  %{buildroot}%{_unitdir}/bacula2-fd.service
 
 # Create the spool directory (bacula user's home directory)
 mkdir -p %{buildroot}%{_localstatedir}/spool/bacula2
@@ -158,15 +165,33 @@ exit 0
 
 %preun client
 if [ $1 = 0 ]; then
-	/sbin/service bacula2-fd stop &>/dev/null || :
-	/sbin/chkconfig --del bacula2-fd
+#	/sbin/service bacula2-fd stop &>/dev/null || :
+#	/sbin/chkconfig --del bacula2-fd
+	# Package removal, not upgrade
+	/bin/systemctl --no-reload disable bacula2-fd.service > /dev/null 2>&1 || :
+	/bin/systemctl stop bacula2-fd.service > /dev/null 2>&1 || :
+
 fi
 
 %postun client
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
 if [ "$1" -ge "1" ]; then
-	/sbin/service bacula2-fd condrestart &>/dev/null || :
+#	/sbin/service bacula2-fd condrestart &>/dev/null || :
+	# Package upgrade, not uninstall
+	/bin/systemctl try-restart bacula2-fd.service >/dev/null 2>&1 || :
 fi
 
+%triggerun -- bacula2-client < 2.4.4-8
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply httpd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save bacula2-fd >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del bacula2-fd >/dev/null 2>&1 || :
+/bin/systemctl try-restart bacula2-fd.service >/dev/null 2>&1 || :
+
+
 %files common
 %defattr(-,root,root,-)
 %doc AUTHORS ChangeLog COPYING LICENSE README SUPPORT VERIFYING examples/
@@ -176,12 +201,16 @@ fi
 %files client
 %defattr(-,root,root,-)
 %{_sbindir}/bacula2-fd
-%{_initrddir}/bacula2-fd
+#%{_initrddir}/bacula2-fd
+%{_unitdir}/bacula2-fd.service
 %config(noreplace) %{_sysconfdir}/bacula2/bacula-fd.conf
 %dir %{_localstatedir}/spool/bacula2/
 %{_mandir}/man8/bacula2-fd.8*
 
 %changelog
+* Tue Nov 22 2011 Jon Ciesla <limb at jcomserv.net> 2.4.4-8
+- Migrated to systemd, BZ 754475.
+
 * Mon Feb 07 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.4.4-7
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list