[tigervnc] Add systemd service file and remove legacy SysV initscript (#717227)

Adam Tkac atkac at fedoraproject.org
Thu Jul 28 10:41:52 UTC 2011


commit 9956c17c57d2ce920b8f8f9985c05a0ceebde20a
Author: Adam Tkac <atkac at redhat.com>
Date:   Thu Jul 28 12:40:44 2011 +0200

    Add systemd service file and remove legacy SysV initscript (#717227)
    
    Signed-off-by: Adam Tkac <atkac at redhat.com>

 tigervnc.spec       |   36 ++++++++----
 vncserver.init      |  149 ---------------------------------------------------
 vncserver.service   |   42 ++++++++++++++
 vncserver.sysconfig |   31 +----------
 4 files changed, 67 insertions(+), 191 deletions(-)
---
diff --git a/tigervnc.spec b/tigervnc.spec
index 9686c83..da7b17d 100644
--- a/tigervnc.spec
+++ b/tigervnc.spec
@@ -1,6 +1,6 @@
 Name:		tigervnc
 Version:	1.0.90
-Release:	5%{?dist}
+Release:	6%{?dist}
 Summary:	A TigerVNC remote display system
 
 Group:		User Interface/Desktops
@@ -8,7 +8,7 @@ License:	GPLv2+
 URL:		http://www.tigervnc.com
 
 Source0:	%{name}-%{version}.tar.gz
-Source1:	vncserver.init
+Source1:	vncserver.service
 Source2:	vncserver.sysconfig
 Source6:	vncviewer.desktop
 Source7:	xserver110.patch
@@ -23,13 +23,15 @@ BuildRequires:	mesa-libGL-devel, libXinerama-devel, ImageMagick
 BuildRequires:  freetype-devel, libXdmcp-devel
 BuildRequires:	desktop-file-utils, java-1.5.0-gcj-devel
 BuildRequires:	libjpeg-turbo-devel, gnutls-devel, pam-devel
+BuildRequires:	systemd-units
 
 %ifarch %ix86 x86_64
 BuildRequires: nasm
 %endif
 
-Requires(post):	coreutils
-Requires(postun):coreutils
+Requires(post):	systemd-units systemd-sysv chkconfig coreutils
+Requires(preun):systemd-units
+Requires(postun):systemd-units coreutils
 Requires:	hicolor-icon-theme
 Requires:	tigervnc-license
 
@@ -202,9 +204,10 @@ pushd unix/xserver/hw/vnc
 make install DESTDIR=$RPM_BUILD_ROOT
 popd
 
-# Install Xvnc as service
-mkdir -p $RPM_BUILD_ROOT%{_initddir}
-install -m755 %{SOURCE1} $RPM_BUILD_ROOT%{_initddir}/vncserver
+# Install systemd unit file
+mkdir -p %{buildroot}%{_unitdir}
+install -m644 %{SOURCE1} %{buildroot}%{_unitdir}/vncserver at .service
+rm -rf %{buildroot}%{_initrddir}
 
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
 install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/vncservers
@@ -255,19 +258,25 @@ if [ -x %{_bindir}/gtk-update-icon-cache ]; then
 fi
 
 %post server
-/sbin/chkconfig --add vncserver
+/bin/systemctl daemon-reload > /dev/null 2>&1
 
 %preun server
 if [ "$1" -eq 0 ]; then
-	/sbin/service vncserver stop > /dev/null 2>&1
-	/sbin/chkconfig --del vncserver
+	/bin/systemctl --no-reload vncserver.service > /dev/null 2>&1
+	/bin/systemctl stop vncserver.service > /dev/null 2>&1
 fi
 
 %postun server
 if [ "$1" -ge "1" ]; then
-	/sbin/service vncserver condrestart > /dev/null 2>&1 || :
+	/bin/systemctl try-restart vncserver.service > /dev/null 2>&1
 fi
 
+%triggerun -- tigervnc-server < 1.0.90-6
+%{_bindir}/systemd-sysv-convert --save vncserver >/dev/null 2>&1 ||:
+/bin/systemctl enable vncserver.service >/dev/null 2>&1
+/sbin/chkconfig --del vncserver >/dev/null 2>&1 || :
+/bin/systemctl try-restart vncserver.service >/dev/null 2>&1 || :
+
 %files -f %{name}.lang
 %defattr(-,root,root,-)
 %doc unix/README
@@ -279,7 +288,7 @@ fi
 %files server
 %defattr(-,root,root,-)
 %config(noreplace) %{_sysconfdir}/sysconfig/vncservers
-%{_initddir}/vncserver
+%{_unitdir}/vncserver at .service
 %{_bindir}/x0vncserver
 %{_bindir}/vncserver
 %{_mandir}/man1/vncserver.1*
@@ -309,6 +318,9 @@ fi
 %doc LICENCE.TXT
 
 %changelog
+* Thu Jul 28 2011 Adam Tkac <atkac redhat com> - 1.0.90-6
+- add systemd service file and remove legacy SysV initscript (#717227)
+
 * Tue May 12 2011 Adam Tkac <atkac redhat com> - 1.0.90-5
 - make Xvnc buildable against X.Org 1.11
 
diff --git a/vncserver.service b/vncserver.service
new file mode 100644
index 0000000..03b1449
--- /dev/null
+++ b/vncserver.service
@@ -0,0 +1,42 @@
+# The vncserver service unit file
+#
+# Quick HowTo:
+# 1. Copy this file to /etc/systemd/system/vncserver@:<display>.service
+# 2. Edit "User" and "ExecStart" variables appropriately
+# 	(ExecStart should be "/usr/bin/vncserver %i -arg1 -arg2")
+# 3. Run `systemctl daemon-reload`
+#
+# DO NOT RUN THIS SERVICE if your local area network is
+# untrusted!  For a secure way of using VNC, you should
+# limit connections to the local host and then tunnel from
+# the machine you want to view VNC on (host A) to the machine
+# whose VNC output you want to view (host B)
+#
+# [user at hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
+#
+# this will open a connection on port 590N of your hostA to hostB's port 590M
+# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
+# See the ssh man page for details on port forwarding)
+#
+# You can then point a VNC client on hostA at vncdisplay N of localhost and with
+# the help of ssh, you end up seeing what hostB makes available on port 590M
+#
+# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
+#
+# Use "-localhost" to prevent remote VNC clients connecting except when
+# doing so through a secure tunnel.  See the "-via" option in the
+# `man vncviewer' manual page.
+
+
+[Unit]
+Description=Remote desktop service (VNC)
+After=syslog.target network.target
+
+[Service]
+Type=forking
+User=root
+ExecStart=/usr/bin/vncserver %i
+ExecStop=/usr/bin/vncserver -kill %i
+
+[Install]
+WantedBy=multi-user.target
diff --git a/vncserver.sysconfig b/vncserver.sysconfig
index bc0b22d..4d0489b 100644
--- a/vncserver.sysconfig
+++ b/vncserver.sysconfig
@@ -1,30 +1 @@
-# The VNCSERVERS variable is a list of display:user pairs.
-#
-# Uncomment the lines below to start a VNC server on display :2
-# as my 'myusername' (adjust this to your own).  You will also
-# need to set a VNC password; run 'man vncpasswd' to see how
-# to do that.  
-#
-# DO NOT RUN THIS SERVICE if your local area network is
-# untrusted!  For a secure way of using VNC, you should
-# limit connections to the local host and then tunnel from
-# the machine you want to view VNC on (host A) to the machine
-# whose VNC output you want to view (host B)
-#
-# [user at hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
-#
-# this will open a connection on port 590N of your hostA to hostB's port 590M
-# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
-# See the ssh man page for details on port forwarding)
-#
-# You can then point a VNC client on hostA at vncdisplay N of localhost and with
-# the help of ssh, you end up seeing what hostB makes available on port 590M
-
-# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
-
-# Use "-localhost" to prevent remote VNC clients connecting except when
-# doing so through a secure tunnel.  See the "-via" option in the
-# `man vncviewer' manual page.
-
-# VNCSERVERS="2:myusername"
-# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
+# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver at .service


More information about the scm-commits mailing list