[bacula/f16] convert to systemd

Tom Callaway spot at fedoraproject.org
Thu Sep 8 16:31:20 UTC 2011


commit a64ae85506c210b356e50e56c72b6c9189350935
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Thu Sep 8 12:31:08 2011 -0400

    convert to systemd

 bacula-checkconf   |   17 ++++++++
 bacula-dir.service |   17 ++++++++
 bacula-fd.service  |   18 ++++++++
 bacula-sd.service  |   17 ++++++++
 bacula.spec        |  117 +++++++++++++++++++++-------------------------------
 5 files changed, 116 insertions(+), 70 deletions(-)
---
diff --git a/bacula-checkconf b/bacula-checkconf
new file mode 100644
index 0000000..d9a8bb7
--- /dev/null
+++ b/bacula-checkconf
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Check if we still have our @@PLACEHOLDERS@@ in the config.
+# If yes, refuse to start, the user has never touched the config.
+
+if [ $# -ne 1 ]; then
+    echo "Usage: $0 [configfile]"
+    exit 1
+fi
+grep -q '^[^#].*_PASSWORD@@' $1
+if [ $? -eq 0 ]; then
+    echo "Error: Default password in config"
+    exit 6
+fi
+
+exit 0
+
diff --git a/bacula-dir.service b/bacula-dir.service
new file mode 100644
index 0000000..2ec1dee
--- /dev/null
+++ b/bacula-dir.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Bacula-Director, the Backup-server
+Requires=syslog.target network.target
+After=network.target
+
+[Service]
+Environment=CONFIG=/etc/bacula/bacula-dir.conf
+Environment=DIR_USER=bacula
+Environment=DIR_GROUP=bacula
+EnvironmentFile=-/etc/sysconfig/bacula-dir
+ExecStartPre=/usr/sbin/bacula-checkconf $CONFIG
+ExecStart=/usr/sbin/bacula-dir -f -c $CONFIG -u $DIR_USER -g $DIR_GROUP
+StandardOutput=syslog
+Restart=restart-always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bacula-fd.service b/bacula-fd.service
new file mode 100644
index 0000000..f2d8ac4
--- /dev/null
+++ b/bacula-fd.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Bacula-FileDaemon, a Backup-client
+Requires=syslog.target network.target
+After=network.target
+
+[Service]
+Environment=CONFIG=/etc/bacula/bacula-fd.conf
+Environment=FD_USER=root
+Environment=FD_GROUP=root
+EnvironmentFile=-/etc/sysconfig/bacula-fd
+ExecStartPre=/usr/sbin/bacula-checkconf $CONFIG
+ExecStart=/usr/sbin/bacula-fd -f -c $CONFIG -u $FD_USER -g $FD_GROUP
+IOSchedulingClass=idle
+StandardOutput=syslog
+Restart=restart-always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bacula-sd.service b/bacula-sd.service
new file mode 100644
index 0000000..4aec055
--- /dev/null
+++ b/bacula-sd.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Bacula-StorageDaemon, the storage-server
+Requires=syslog.target network.target
+After=network.target
+
+[Service]
+Environment=CONFIG=/etc/bacula/bacula-sd.conf
+Environment=SD_USER=bacula
+Environment=SD_GROUP=disk
+EnvironmentFile=-/etc/sysconfig/bacula-sd
+ExecStartPre=/usr/sbin/bacula-checkconf $CONFIG
+ExecStart=/usr/sbin/bacula-sd -f -c $CONFIG -u $SD_USER -g $SD_GROUP
+StandardOutput=syslog
+Restart=restart-always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bacula.spec b/bacula.spec
index 169aee7..745dc65 100644
--- a/bacula.spec
+++ b/bacula.spec
@@ -8,7 +8,7 @@
 Summary: Cross platform network backup for Linux, Unix, Mac and Windows
 Name: bacula
 Version: 5.0.3
-Release: 9%{?dist}
+Release: 10%{?dist}
 # See LICENSE for details
 License: GPLv2 with exceptions
 Group: System Environment/Daemons
@@ -19,17 +19,16 @@ Source1: http://download.sourceforge.net/bacula/bacula-docs-%{docs_version}.tar.
 Source4: bacula-wxconsole.desktop
 Source5: bacula-traymonitor.desktop
 Source6: bacula.logrotate
-Source7: bacula-fd.init
-Source8: bacula-dir.init
-Source9: bacula-sd.init
+Source7: bacula-fd.service
+Source8: bacula-dir.service
+Source9: bacula-sd.service
 #Source10: http://download.sourceforge.net/bacula/bacula-gui-%{gui_version}.tar.gz
 #Source11: bacula-web.apache
 Source12: bacula-bat.desktop
 Source13: bacula-traymonitor.console_apps
 Source14: bacula-wxconsole.console_apps
-Source15: bacula-fd.sysconfig
-Source16: bacula-dir.sysconfig
-Source17: bacula-sd.sysconfig
+Source15: bacula-checkconf
+
 #Patch0: bacula-director-configuration.patch
 Patch1: bacula-config.patch
 #Patch2: bacula-wxconsole.patch
@@ -66,6 +65,7 @@ BuildRequires: desktop-file-utils, python-devel, sqlite-devel, sed,
 BuildRequires: libacl-devel, latex2html, tetex-latex, tetex, ghostscript
 BuildRequires: dvipdfm, qwt-devel
 BuildRequires: tcp_wrappers-devel
+BuildRequires: systemd-units
 
 %description
 Bacula is a set of programs that allow you to manage the backup,
@@ -135,6 +135,7 @@ Requires: bacula-common = %{version}-%{release}
 Requires: logwatch
 Requires(pre): fedora-usermgmt
 Requires(postun): fedora-usermgmt
+Requires(post): systemd-sysv
 
 %description director-common
 Bacula is a set of programs that allow you to manage the backup,
@@ -152,10 +153,7 @@ bacula-director-sqlite or bacula-director-postgresql.
 Summary: Bacula backup client
 Group: System Environment/Daemons
 Requires: bacula-common = %{version}-%{release}
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+Requires(post): systemd-sysv
 
 %description client
 Bacula is a set of programs that allow you to manage the backup,
@@ -171,6 +169,7 @@ Summary: Common Bacula storage daemon files
 Group: System Environment/Daemons
 Requires: bacula-storage = %{version}-%{release}
 Requires: bacula-common = %{version}-%{release}
+Requires(post): systemd-sysv
 
 %description storage-common
 Bacula is a set of programs that allow you to manage the backup,
@@ -615,17 +614,12 @@ install -m 755 -D bacula-sqlite/scripts/logwatch/applybaculadate %{buildroot}%{_
 install -m 644 -D bacula-sqlite/scripts/logwatch/logfile.bacula.conf %{buildroot}%{_sysconfdir}/logwatch/conf/logfiles/bacula.conf
 install -m 644 -D bacula-sqlite/scripts/logwatch/services.bacula.conf %{buildroot}%{_sysconfdir}/logwatch/conf/services/bacula.conf
 
-
-# Initscripts
-install -m 755 -D %{SOURCE7}  %{buildroot}%{_initrddir}/bacula-fd
-install -m 755 -D %{SOURCE8}  %{buildroot}%{_initrddir}/bacula-dir
-install -m 755 -D %{SOURCE9}  %{buildroot}%{_initrddir}/bacula-sd
-
-
-# Sysconfig
-install -m 644 -D %{SOURCE15}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-fd
-install -m 644 -D %{SOURCE16}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-dir
-install -m 644 -D %{SOURCE17}  %{buildroot}%{_sysconfdir}/sysconfig/bacula-sd
+# Systemd unit files
+mkdir -p ${buildroot}%{_unitdir}
+install -m 755 -D %{SOURCE7}  %{buildroot}%{_unitdir}/bacula-fd.service
+install -m 755 -D %{SOURCE8}  %{buildroot}%{_unitdir}/bacula-dir.service
+install -m 755 -D %{SOURCE9}  %{buildroot}%{_unitdir}/bacula-sd.service
+install -m 755 -D %{SOURCE15} %{buildroot}%{_sbindir}/bacula-checkconf
 
 
 # Wipe backup files from the multiple make install calls
@@ -748,55 +742,37 @@ if [ "$1" = 0 ]; then
 	/usr/sbin/alternatives --remove bacula-sd /usr/sbin/bcopy.postgresql
 fi
 
-%post client
-/sbin/chkconfig --add bacula-fd
-
-
-%preun client
-if [ "$1" = 0 ]; then
-	/sbin/service bacula-fd stop >/dev/null 2>&1 || :
-	/sbin/chkconfig --del bacula-fd
-fi
+%triggerun client -- bacula-client < 5.0.3-10
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply bacula-fd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save bacula-fd >/dev/null 2>&1 ||:
 
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del bacula-fd >/dev/null 2>&1 || :
+/bin/systemctl try-restart bacula-fd.service >/dev/null 2>&1 || :
 
-%postun client
-if [ "$1" -ge "1" ]; then
-	/sbin/service bacula-fd condrestart >/dev/null 2>&1 || :
-fi
 
+%triggerun director-common -- bacula-director-common < 5.0.3-10
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply bacula-dir
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save bacula-dir >/dev/null 2>&1 ||:
 
-%post director-common
-/sbin/chkconfig --add bacula-dir
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del bacula-dir >/dev/null 2>&1 || :
+/bin/systemctl try-restart bacula-dir.service >/dev/null 2>&1 || :
 
 
-%preun director-common
-if [ "$1" = 0 ]; then
-	/sbin/service bacula-dir stop >/dev/null 2>&1 || :
-	/sbin/chkconfig --del bacula-dir
-fi
+%triggerun storage-common -- bacula-storage-common < 5.0.3-10 
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply bacula-sd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save bacula-sd >/dev/null 2>&1 ||:
 
-
-%postun director-common
-if [ "$1" -ge "1" ]; then
-	/sbin/service bacula-dir condrestart >/dev/null 2>&1 || :
-fi
-
-
-%post storage-common
-/sbin/chkconfig --add bacula-sd
-
-
-%preun storage-common
-if [ "$1" = 0 ]; then
-	/sbin/service bacula-sd stop >/dev/null 2>&1 || :
-	/sbin/chkconfig --del bacula-sd
-fi
-
-
-%postun storage-common
-if [ "$1" -ge "1" ]; then
-	/sbin/service bacula-sd condrestart >/dev/null 2>&1 || :
-fi
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del bacula-sd >/dev/null 2>&1 || :
+/bin/systemctl try-restart bacula-sd.service >/dev/null 2>&1 || :
 
 
 %files common
@@ -821,13 +797,13 @@ fi
 /usr/libexec/bacula/mtx-changer.conf
 %{_libexecdir}/bacula/bacula_config
 %{_libexecdir}/bacula/btraceback.mdb
+%{_sbindir}/bacula-checkconf
 
 %files client
 %defattr(-,root,root,-)
 %{_sbindir}/bacula-fd
-%{_initrddir}/bacula-fd
+%{_unitdir}/bacula-fd.service
 %config(noreplace) %{_sysconfdir}/bacula/bacula-fd.conf
-%config(noreplace) %{_sysconfdir}/sysconfig/bacula-fd
 %{_mandir}/man8/bacula-fd.8*
 
 
@@ -882,10 +858,9 @@ fi
 %config(noreplace) %{_sysconfdir}/bacula/query.sql
 %config %{_sysconfdir}/logwatch/conf/logfiles/bacula.conf
 %config %{_sysconfdir}/logwatch/conf/services/bacula.conf
-%config(noreplace) %{_sysconfdir}/sysconfig/bacula-dir
 %{_sysconfdir}/logwatch/scripts/services/bacula
 %{_sysconfdir}/logwatch/scripts/shared/applybaculadate
-%{_initrddir}/bacula-dir
+%{_unitdir}/bacula-dir.service
 %{_sbindir}/bregex
 %{_sbindir}/bwild
 %{_mandir}/man8/dbcheck.8*
@@ -959,8 +934,7 @@ fi
 %{_sbindir}/bls
 %{_sbindir}/btape
 %config(noreplace) %{_sysconfdir}/bacula/bacula-sd.conf
-%config(noreplace) %{_sysconfdir}/sysconfig/bacula-sd
-%{_initrddir}/bacula-sd
+%{_unitdir}/bacula-sd.service
 %{_libexecdir}/bacula/disk-changer
 %{_libexecdir}/bacula/dvd-handler
 %{_libexecdir}/bacula/mtx-changer
@@ -1026,6 +1000,9 @@ fi
 
 
 %changelog
+* Thu Sep  8 2011 Tom Callaway <spot at fedoraproject.org> - 5.0.3-10 
+- convert to systemd
+
 * Wed Mar 23 2011 Dan Horák <dan at danny.cz> - 5.0.3-9
 - rebuilt for mysql 5.5.10 (soname bump in libmysqlclient)
 


More information about the scm-commits mailing list