[thttpd] convert to systemd

Tom Callaway spot at fedoraproject.org
Tue Sep 20 18:33:22 UTC 2011


commit 7e9db878901ca21c3abfd1a23a89ed0c656ae1e0
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Tue Sep 20 14:32:58 2011 -0400

    convert to systemd

 thttpd.service |   12 ++++++++++++
 thttpd.spec    |   54 +++++++++++++++++++++++++++++++++---------------------
 2 files changed, 45 insertions(+), 21 deletions(-)
---
diff --git a/thttpd.service b/thttpd.service
new file mode 100644
index 0000000..ef03b4e
--- /dev/null
+++ b/thttpd.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Tiny/Turbo/Throttling Web Server
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/thttpd
+EnvironmentFile=-/etc/sysconfig/thttpd
+ExecStart=/usr/sbin/thttpd -C /etc/thttpd.conf
+
+[Install]
+WantedBy=multi-user.target
diff --git a/thttpd.spec b/thttpd.spec
index ae7b511..123e390 100644
--- a/thttpd.spec
+++ b/thttpd.spec
@@ -4,24 +4,25 @@
 Summary: Tiny, turbo, throttleable lightweight http server
 Name: thttpd
 Version: 2.25b
-Release: 24%{?dist}
+Release: 25%{?dist}
 License: BSD
 Group: System Environment/Daemons
 URL: http://www.acme.com/software/thttpd/
 Source0: http://www.acme.com/software/thttpd/thttpd-%{version}.tar.gz
-Source1: thttpd.init
+Source1: thttpd.service
 Source2: thttpd.logrotate
 Source10: index.html
 Source11: thttpd_powered_3.png
 Patch0: thttpd-2.25b-CVE-2005-3124.patch
 Patch1: thttpd-2.25b-fixes.patch
 Patch2: thttpd-2.25b-getline.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 Requires: system-logos >= 7.92.1
+BuildRequires: systemd-units
 Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd
-Requires(post): /sbin/chkconfig
-Requires(preun): /sbin/service, /sbin/chkconfig
-Requires(postun): /sbin/service
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 
 %description
 Thttpd is a very compact no-frills httpd serving daemon that can handle
@@ -63,15 +64,14 @@ done
 
 
 %install
-%{__rm} -rf %{buildroot}
-
 # Prepare required directories
 %{__mkdir_p} %{buildroot}%{webroot}
 %{__mkdir_p} %{buildroot}%{_mandir}/man{1,8}
 %{__mkdir_p} %{buildroot}%{_sbindir}
+%{__mkdir_p} %{buildroot}%{_unitdir}
 
 # Install init script and logrotate entry
-%{__install} -Dpm 0755 %{SOURCE1} %{buildroot}%{_sysconfdir}/rc.d/init.d/thttpd
+%{__install} -Dpm 0644 %{SOURCE1} %{buildroot}%{_unitdir}/
 %{__install} -Dpm 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/thttpd
 
 # Main install (list SUBDIRS to exclude "cgi-src")
@@ -115,9 +115,6 @@ pidfile=/var/run/thttpd.pid
 EOF
 
 
-%clean
-%{__rm} -rf %{buildroot}
-
 
 %pre
 /usr/sbin/groupadd -r www &>/dev/null || :
@@ -125,26 +122,38 @@ EOF
     -d %{webroot} -M -r -g www thttpd &>/dev/null || :
 
 %post
-if [ $1 -eq 1 ]; then
-    /sbin/chkconfig --add thttpd
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
 fi
 
 %preun
-if [ $1 -eq 0 ]; then
-    /sbin/service thttpd stop &>/dev/null || :
-    /sbin/chkconfig --del thttpd
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable thttpd.service > /dev/null 2>&1 || :
+    /bin/systemctl stop thttpd.service > /dev/null 2>&1 || :
 fi
 
 %postun
-if [ $1 -ge 1 ]; then
-    /sbin/service thttpd condrestart &>/dev/null || :
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart thttpd.service >/dev/null 2>&1 || :
 fi
 
+%triggerun -- thttpd < 2.25b-25
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply thttpd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save thttpd >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del thttpd >/dev/null 2>&1 || :
+/bin/systemctl try-restart thttpd.service >/dev/null 2>&1 || :
 
 %files
-%defattr(-,root,root,-)
 %doc README TODO
-%{_sysconfdir}/rc.d/init.d/thttpd
+%{_unitdir}/thttpd.service
 %config(noreplace) %{_sysconfdir}/logrotate.d/thttpd
 %config(noreplace) %{_sysconfdir}/thttpd.conf
 %{_bindir}/thtpasswd
@@ -166,6 +175,9 @@ fi
 
 
 %changelog
+* Tue Sep 20 2011 Tom Callaway <spot at fedoraproject.org> - 2.25b-25
+- convert to systemd
+
 * Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.25b-24
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list