[anyterm] Remove SysV script, add systemd service file.

abo abo at fedoraproject.org
Fri Jun 1 22:18:28 UTC 2012


commit 313c7954dedda759ebe1146f9263772534aea1d5
Author: Alexander Boström <abo at root.snowtree.se>
Date:   Tue May 22 11:31:58 2012 +0200

    Remove SysV script, add systemd service file.

 anyterm.service |   14 ++++++++++++++
 anyterm.spec    |   48 ++++++++++++++++++++++++++++++++----------------
 2 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/anyterm.service b/anyterm.service
new file mode 100644
index 0000000..68acd49
--- /dev/null
+++ b/anyterm.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Anyterm Web Based Terminal Emulator
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/anytermd.pid
+ExecStart=/usr/sbin/anytermd -c /usr/libexec/anyterm/anyterm-cmd -s UTF8 --user anyterm --port 81 --local-only
+RemainAfterExit=yes
+PrivateTmp=true
+PrivateNetwork=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/anyterm.spec b/anyterm.spec
index 689259e..0c590ee 100644
--- a/anyterm.spec
+++ b/anyterm.spec
@@ -1,6 +1,6 @@
 Name: anyterm
 Version: 1.1.29
-Release: 11%{?dist}
+Release: 12%{?dist}
 Summary: A web-based terminal emulator
 
 Group: Applications/Internet
@@ -9,9 +9,8 @@ URL: http://anyterm.org
 
 Source0: http://anyterm.org/download/anyterm-1.1.29.tbz2
 Source1: anyterm-cmd
-Source2: anytermd.init
-Source3: anytermd.sysconfig
 Source4: anyterm.conf
+Source5: anyterm.service
 
 # http://anyterm.org/1.1/install.html#secid2252601
 Patch0: anyterm-change-url-prefix.patch
@@ -23,11 +22,13 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 BuildRequires: boost-devel  
 BuildRequires: zlib-devel
 BuildRequires: prelink
+BuildRequires: systemd-units
 Requires(pre): shadow-utils
-Requires(post): chkconfig
-Requires(preun): chkconfig
-Requires(preun): initscripts
-Requires(postun): initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+Requires(post): systemd-sysv
+
 
 %package httpd
 Summary: Httpd proxy configuration for anyterm
@@ -65,9 +66,8 @@ execstack -c anytermd
 %{__install} -Dp -m0755 anytermd %{buildroot}%{_sbindir}/anytermd
 %{__install} -Dp -m0644 anytermd.1.gz %{buildroot}%{_mandir}/man1/anytermd.1.gz
 %{__install} -Dp -m0755 %{SOURCE1} %{buildroot}%{_libexecdir}/%{name}/anyterm-cmd
-%{__install} -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/anyterm
-%{__install} -Dp -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/anyterm
 %{__install} -Dp -m0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/httpd/conf.d/anyterm.conf
+%{__install} -Dp -m0644 %{SOURCE5} %{buildroot}%{_unitdir}/anyterm.service
 
 %{__mkdir} -p %{buildroot}%{_datadir}/anyterm/
 for f in browser/*.{html,css,js,png,gif}; do
@@ -88,23 +88,36 @@ getent passwd anyterm > /dev/null || \
 exit 0
 
 %post
-# adds the proper /etc/rc*.d links for the script
-/sbin/chkconfig --add anyterm
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
 
 %preun
-if [ $1 = 0 ] ; then
-    /sbin/service anyterm stop >/dev/null 2>&1
-    /sbin/chkconfig --del anyterm
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable anyterm.service > /dev/null 2>&1 || :
+    /bin/systemctl stop anyterm.service > /dev/null 2>&1 || :
+
+%postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart anyterm.service >/dev/null 2>&1 || :
 fi
 
+%triggerun -- anyterm < 1.1.29-12
+/usr/bin/systemd-sysv-convert --save anyterm >/dev/null 2>&1 ||:
+/sbin/chkconfig --del anyterm >/dev/null 2>&1 || :
+/bin/systemctl try-restart anyterm.service >/dev/null 2>&1 || :
+
 %files
 %defattr(-,root,root,-)
 %{_sbindir}/anytermd
 %{_libexecdir}/anyterm/
 %{_mandir}/man1/anytermd.1.gz
-%{_initrddir}/anyterm
 %{_datadir}/anyterm/
-%config(noreplace) %{_sysconfdir}/sysconfig/anyterm
+%{_unitdir}/anyterm.service
 %doc LICENSE
 
 %files httpd
@@ -112,6 +125,9 @@ fi
 %config(noreplace) %{_sysconfdir}/httpd/conf.d/anyterm.conf
 
 %changelog
+* Tue May 22 2012 Alexander Boström <abo at root.snowtree.se> - 1.1.29-12
+- Remove SysV script, add systemd service file.
+
 * Tue Feb 28 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.1.29-11
 - Rebuilt for c++ ABI breakage
 


More information about the scm-commits mailing list