[packages/tigervnc] - added systemd native service generator and vncserver target - rel 5
baggins
baggins at pld-linux.org
Fri Aug 16 21:03:08 CEST 2013
commit 9f5ab5d27ccaf491a99db59601af9ef8eb1f4b76
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Fri Aug 16 21:02:28 2013 +0200
- added systemd native service generator and vncserver target
- rel 5
tigervnc.spec | 29 ++++++++++++++++++++++++++-
vncserver-service-generator | 49 +++++++++++++++++++++++++++++++++++++++++++++
vncserver.sysconfig | 6 ++++++
vncserver.target | 7 +++++++
4 files changed, 90 insertions(+), 1 deletion(-)
---
diff --git a/tigervnc.spec b/tigervnc.spec
index 966c6a3..f2c97dd 100644
--- a/tigervnc.spec
+++ b/tigervnc.spec
@@ -4,7 +4,7 @@ Summary: A TigerVNC remote display system
Summary(pl.UTF-8): System zdalnego dostępu TigerVNC
Name: tigervnc
Version: 1.3.0
-Release: 4
+Release: 5
License: GPL v2
Group: X11/Applications/Networking
Source0: http://download.sourceforge.net/tigervnc/%{name}-%{version}.tar.bz2
@@ -12,6 +12,8 @@ Source0: http://download.sourceforge.net/tigervnc/%{name}-%{version}.tar.bz2
Source1: %{name}.desktop
Source2: vncserver.init
Source3: vncserver.sysconfig
+Source4: vncserver.target
+Source5: vncserver-service-generator
Patch0: %{name}-cookie.patch
Patch1: %{name}-ldnow.patch
Patch2: %{name}-rh102434.patch
@@ -48,6 +50,7 @@ BuildRequires: pam-devel
BuildRequires: perl-base
BuildRequires: pixman-devel >= 0.16.0
BuildRequires: pkgconfig >= 1:0.19
+BuildRequires: rpmbuild(macros) >= 1.647
BuildRequires: xorg-app-mkfontscale
BuildRequires: xorg-font-font-util >= 1.1
BuildRequires: xorg-lib-libX11-devel
@@ -122,12 +125,14 @@ Summary: VNC X server - TigerVNC version
Summary(pl.UTF-8): X serwer VNC - wersja TigerVNC
Group: X11/Applications/Networking
Requires(post,preun): /sbin/chkconfig
+Requires(post,preun,postun): systemd-units >= 38
Requires: xorg-app-rgb
# for vncpasswd tool
Requires: %{name}-utils = %{version}-%{release}
# for mcookie
Requires: util-linux
Requires: libjpeg-turbo
+Requires: systemd-units >= 38
Requires: xkeyboard-config
Requires: xorg-app-xauth
Requires: xorg-app-xkbcomp
@@ -271,6 +276,11 @@ install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
install %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/vncserver
install %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/vncserver
+install -d $RPM_BUILD_ROOT{%{systemdunitdir},/lib/systemd/system-generators}
+install -p %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/vncserver.target
+install -p %{SOURCE5} $RPM_BUILD_ROOT/lib/systemd/system-generators/vncserver-service-generator
+ln -s /dev/null $RPM_BUILD_ROOT%{systemdunitdir}/vncserver.service
+
%{__rm} -r $RPM_BUILD_ROOT%{_docdir}
%find_lang %{name}
@@ -289,12 +299,26 @@ rm -rf $RPM_BUILD_ROOT
%post server
/sbin/chkconfig --add vncserver
%service vncserver restart "VNC server"
+NORESTART=1
+%systemd_post vncserver.target
%preun server
if [ "$1" = "0" ]; then
%service vncserver stop
/sbin/chkconfig --del vncserver
fi
+%systemd_preun vncserver.target
+
+%postun server
+%systemd_reload
+
+%triggerpostun server -- tigervnc-server < 1.3.0-5
+[ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
+[ ${RPM_ENABLE_SYSTEMD_SERVICE:-yes} = no ] && return 1
+export SYSTEMD_LOG_LEVEL=warning SYSTEMD_LOG_TARGET=syslog
+if [ "$(echo /etc/rc.d/rc[0-6].d/S[0-9][0-9]vncserver)" != "/etc/rc.d/rc[0-6].d/S[0-9][0-9]vncserver" ]; then
+ /bin/systemctl --quiet enable vncserver.target || :
+fi
%files -f %{name}.lang
%defattr(644,root,root,755)
@@ -311,6 +335,9 @@ fi
%attr(755,root,root) %{_bindir}/x0vncserver
%attr(754,root,root) /etc/rc.d/init.d/vncserver
%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/vncserver
+%attr(755,root,root) /lib/systemd/system-generators/vncserver-service-generator
+%{systemdunitdir}/vncserver.target
+%{systemdunitdir}/vncserver.service
%{_mandir}/man1/Xvnc.1*
%{_mandir}/man1/vncserver.1*
%{_mandir}/man1/x0vncserver.1*
diff --git a/vncserver-service-generator b/vncserver-service-generator
new file mode 100755
index 0000000..cdb5b42
--- /dev/null
+++ b/vncserver-service-generator
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+destunitdir=${1:-/tmp}
+
+# Do nothing if vncserver target is disabled
+[ -e /etc/systemd/system/multi-user.target.wants/vncserver.target ] || exit 0
+
+VNCSERVERS=""
+[ -f /etc/sysconfig/vncserver ] && . /etc/sysconfig/vncserver
+
+if [ -d $destunitdir/vncserver.target.wants ]; then
+ rm -f $destunitdir/vncserver.target.wants/vncserver@*.service
+else
+ mkdir -p $destunitdir/vncserver.target.wants
+fi
+
+for display in $VNCSERVERS; do
+ DISP="${display%%:*}"
+ USER="${display##*:}"
+ if [ "x$USER" == "xroot" ]; then
+ echo "-- Do not run vncserver as root!"
+ continue
+ fi
+ VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
+ if [ ! id $USER >/dev/null 2>&1 ]; then
+ echo "-- User $USER does not exists!"
+ continue
+ fi
+ USERHOME=$(eval "echo ~$USER")
+ if [ ! -f "$USERHOME/.vnc/passwd" ]; then
+ echo "-- No password file found for user $USER!"
+ continue
+ fi
+ cat >$destunitdir/vncserver.target.wants/vncserver@$DISP.service <<EOF
+[Unit]
+Description=Remote desktop service (VNC) on display %i
+Requires=vncserver.target
+After=vncserver.target
+PropagateReloadFrom=vncserver.target
+
+[Service]
+Type=simple
+ExecStart=/sbin/runuser -l $USER -c "/usr/bin/vncserver -fg :%i $VNCUSERARGS"
+ExecStop=/sbin/runuser -l $USER -c "/usr/bin/vncserver -kill :%i"
+
+[Install]
+WantedBy=vncserver.target
+EOF
+done
diff --git a/vncserver.sysconfig b/vncserver.sysconfig
index 8c50905..af9f9b4 100644
--- a/vncserver.sysconfig
+++ b/vncserver.sysconfig
@@ -13,5 +13,11 @@
# doing so through a secure tunnel. See the "-via" option in the
# 'man vncviewer' manual page.
+# On systems running systemd after updating the list below you have to
+# restart systemd to regenerate vncserver at DISPLAY.service services
+# (systemctl --system daemon-reload), stop and start vncserver.target when
+# removing elements from list or restart vncserver.target when only adding
+# elements (systemctl stop vncserver.target / systemctl restart vncserver.target).
+
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
diff --git a/vncserver.target b/vncserver.target
new file mode 100644
index 0000000..340c623
--- /dev/null
+++ b/vncserver.target
@@ -0,0 +1,7 @@
+[Unit]
+Description=Start VNC server daemons
+After=network.target
+Wants=network.target
+
+[Install]
+WantedBy=multi-user.target
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/tigervnc.git/commitdiff/9f5ab5d27ccaf491a99db59601af9ef8eb1f4b76
More information about the pld-cvs-commit
mailing list