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@.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@.service %{_bindir}/x0vncserver %{_bindir}/vncserver %{_mandir}/man1/vncserver.1* @@ -309,6 +318,9 @@ fi %doc LICENCE.TXT %changelog +* Thu Jul 28 2011 Adam Tkac - 1.0.90-6 +- add systemd service file and remove legacy SysV initscript (#717227) + * Tue May 12 2011 Adam Tkac - 1.0.90-5 - make Xvnc buildable against X.Org 1.11 diff --git a/vncserver.init b/vncserver.init deleted file mode 100644 index 304f0d8..0000000 --- a/vncserver.init +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash -# -# chkconfig: - 91 35 -# description: Starts and stops vncserver. \ -# used to provide remote X administration services. - -### BEGIN INIT INFO -# Provides: vncserver -# Required-Start: $network $named -# Required-Stop: $network $named -# Default-Start: -# Default-Stop: 0 1 2 3 4 5 6 -# Short-Description: start|stop|restart|try-restart|status|force-reload vncserver -# Description: control vncserver which exports your desktop -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -[ -r /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers - -prog=$"VNC server" - -RETVAL=0 - -start() { - [ "$EUID" != "0" ] && exit 4 - - # Source networking configuration. - . /etc/sysconfig/network - - # Check that networking is up. - [ ${NETWORKING} = "no" ] && exit 1 - - [ -x /usr/bin/vncserver ] || exit 5 - [ -x /usr/bin/Xvnc ] || exit 5 - - echo -n $"Starting $prog: " - RETVAL=0 - if [ ! -d /tmp/.X11-unix ] - then - mkdir -m 1777 /tmp/.X11-unix || : - restorecon /tmp/.X11-unix 2>/dev/null || : - fi - - for display in ${VNCSERVERS} - do - SERVS=1 - echo -n "${display} " - DISP="${display%%:*}" - USER="${display##*:}" - VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" - runuser -l ${USER} -c "cd ~${USER} && [ -r .vnc/passwd ] && \ - vncserver :${DISP} ${VNCUSERARGS}" > /dev/null 2>&1 - RETVAL=$? - [ "$RETVAL" -eq 0 ] || break - done - if [ -z "$SERVS" ]; then - echo -n "no displays configured " - failure - RETVAL=6 - else - if [ "$RETVAL" -eq 0 ]; then - success $"vncserver startup" - touch /var/lock/subsys/Xvnc - touch /var/lock/subsys/vncserver - else - failure $"vncserver start" - fi - fi - echo - -# As written in https://bugzilla.redhat.com/show_bug.cgi?id=523974 (LSB -# compliance) start of already running service is OK. - [ "$RETVAL" -eq 98 ] && RETVAL=0 - - return "$RETVAL" -} - -stop() { - [ "$EUID" != "0" ] && exit 4 - - echo -n $"Shutting down $prog: " - - status Xvnc > /dev/null 2>&1 - RETVAL=$? - - # 3 means service is already stopped - if ! [ "$RETVAL" -eq 3 ]; then - for display in ${VNCSERVERS}; do - echo -n "${display} " - export USER="${display##*:}" - runuser ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1 - done - RETVAL=$? - else - let RETVAL=0 - fi - - [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \ - failure $"vncserver shutdown" - echo - [ "$RETVAL" -eq 0 ] && (rm -f /var/lock/subsys/Xvnc ; rm -f /var/lock/subsys/vncserver) - return "$RETVAL" -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|force-reload) - stop - sleep 3 - start - ;; - condrestart) -# https://bugzilla.redhat.com/show_bug.cgi?id=508367 -# echo "condrestart is obsolete, use try-restart instead" - if [ -e /var/lock/subsys/Xvnc ]; then - stop - sleep 3 - start - fi - ;; - try-restart) - if [ -e /var/lock/subsys/Xvnc ]; then - stop - sleep 3 - start - fi - ;; - status) - status Xvnc - RETVAL=$? - ;; - reload) - exit 3 - ;; - *) - echo $"Usage: $0 {start|stop|restart|try-restart|status|force-reload}" - exit 2 -esac - -exit "$RETVAL" - 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@:.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@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@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@.service