[crossfire] Systemd migration.
Jon Ciesla
limb at fedoraproject.org
Tue Jan 31 18:48:09 UTC 2012
commit 0bbb12e80064905abbdc1fa548dcb6ca80cef8d9
Author: Jon Ciesla <limburgher at gmail.com>
Date: Tue Jan 31 12:47:58 2012 -0600
Systemd migration.
crossfire.service | 12 +++++++++
crossfire.spec | 69 ++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 65 insertions(+), 16 deletions(-)
---
diff --git a/crossfire.service b/crossfire.service
new file mode 100644
index 0000000..80567a0
--- /dev/null
+++ b/crossfire.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Crossfire Multi-Player Network Game Server
+After=network.target
+
+[Service]
+User=crossfire
+Type=forking
+PIDFile=/run/crossfire.pid
+ExecStart=/usr/bin/crossfire -detach -log /var/log/crossfire/crossfire.log
+
+[Install]
+WantedBy=multi-user.target
diff --git a/crossfire.spec b/crossfire.spec
index 35b3b6a..e6585fa 100644
--- a/crossfire.spec
+++ b/crossfire.spec
@@ -8,7 +8,7 @@
Name: crossfire
Version: 1.60.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Server for hosting crossfire games
Group: Amusements/Games
# All files GPLv2+ except server/daemon.c which also has MIT attributions
@@ -16,7 +16,7 @@ License: GPLv2+ and MIT
URL: http://crossfire.real-time.com
Source0: http://downloads.sourceforge.net/crossfire/%{name}-%{version}.tar.gz
Source1: http://downloads.sourceforge.net/crossfire/%{name}-%{version}.arch.tar.gz
-Source2: crossfire.init
+Source2: crossfire.service
Source3: crossfire.sysconfig
Source4: crossfire.logrotate
Source5: crossfire.te
@@ -36,11 +36,16 @@ BuildRequires: libXaw-devel
BuildRequires: python-devel
Requires: %{name}-plugins
-Requires(post): /sbin/chkconfig
-Requires(post): /sbin/service
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+#Requires(post): /sbin/chkconfig
+#Requires(post): /sbin/service
+#Requires(preun): /sbin/chkconfig
+#Requires(preun): /sbin/service
+#Requires(postun): /sbin/service
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+Requires(post): systemd-sysv
+
%description
Crossfire is a highly graphical role-playing adventure game with
@@ -104,7 +109,7 @@ logwatch scripts for the Crossfire game server
%prep
%setup -q
%setup -q -a 1
-#%patch0 -p0
+#%%patch0 -p0
%patch1 -p0
mkdir SELinux
cp %{SOURCE5} %{SOURCE6} %{SOURCE7} SELinux
@@ -153,7 +158,8 @@ tar xf %{name}-images.tar -C $RPM_BUILD_ROOT/%{_datadir}/%{name}-client
# Nuke the installation instructions for the image archive.
rm $RPM_BUILD_ROOT/%{_datadir}/%{name}-client/README
-install -pD -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/crossfire
+#install -pD -m 0755 %%{SOURCE2} $RPM_BUILD_ROOT%%{_initrddir}/crossfire
+install -pD -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/crossfire.service
# Move some rarely-used binaries out of /usr/bin and into a
# tools directory.
@@ -223,7 +229,12 @@ useradd -r -g crossfire -d %{_datadir}/%{name} -s /sbin/nologin \
exit 0
%post
-/sbin/chkconfig --add crossfire
+#/sbin/chkconfig --add crossfire
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
%post selinux
# Install SELinux policy modules
@@ -237,11 +248,17 @@ done
/sbin/service %{name} condrestart > /dev/null 2>&1 || :
%preun
-if [ "$1" -le "0" ]; then
- /sbin/service crossfire stop > /dev/null 2>&1
- /sbin/chkconfig --del crossfire
+#if [ "$1" -le "0" ]; then
+# /sbin/service crossfire stop > /dev/null 2>&1
+# /sbin/chkconfig --del crossfire
+#fi
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable crossfire.service > /dev/null 2>&1 || :
+ /bin/systemctl stop crossfire.service > /dev/null 2>&1 || :
fi
+
%preun selinux
if [ "$1" -lt "1" ] ; then
# Disable the policy and restart the daemon
@@ -256,10 +273,16 @@ if [ "$1" -lt "1" ] ; then
fi
%postun
-if [ "$1" -ge "1" ]; then
- /sbin/service crossfire condrestart >/dev/null 2>&1
+#if [ "$1" -ge "1" ]; then
+# /sbin/service crossfire condrestart >/dev/null 2>&1
+#fi
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart crossfire.service >/dev/null 2>&1 || :
fi
+
%postun selinux
if [ "$1" -ge "1" ] ; then
# Replace the module if it is already loaded. semodule -u also
@@ -269,6 +292,16 @@ if [ "$1" -ge "1" ] ; then
done
fi
+%triggerun -- crossfire < 1.60.0-2
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply crossfire
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save crossfire >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del crossfire >/dev/null 2>&1 || :
+/bin/systemctl try-restart crossfire.service >/dev/null 2>&1 || :
+
%clean
@@ -299,7 +332,8 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_mandir}/man6/*
-%{_initrddir}/%{name}
+#%%{_initrddir}/%%{name}
+%{_unitdir}/%{name}.service
%doc README NEWS DEVELOPERS AUTHORS COPYING
%files doc
@@ -333,6 +367,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Tue Jan 31 2012 Jon Ciesla <limburgher at gmail.com> - 1.60.0-2
+- Migrate to systemd, BZ 771752.
+
* Wed Jan 11 2012 Jon Ciesla <limburgher at gmail.com> - 1.60.0-1
- New upstream.
More information about the scm-commits
mailing list