set(MAN_DIR "${DATA_DIR}/man")
set(LOCALE_DIR "${DATA_DIR}/locale")
set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${VERSION}")
+set(UNIT_DIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/system")
if(WIN32)
set(BIN_DIR "${CMAKE_INSTALL_PREFIX}")
set(DOC_DIR "${CMAKE_INSTALL_PREFIX}")
endif()
+option(INSTALL_SYSTEMD_UNITS "Install TigerVNC systemd units" ON)
+
if(MSVC)
message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use MinGW")
endif()
+++ /dev/null
-#!/bin/bash
-#
-# Init file for TigerVNC Server
-#
-# chkconfig: - 91 35
-# description: TigerVNC remote X administration daemon.
-#
-# processname: Xvnc
-
-### BEGIN INIT INFO
-# Provides: vncservers
-# Required-Start: networking
-# Required-Stop: networking
-# Default-Start:
-# Default-Stop: 0 1 2 3 4 5 6
-# Short-Description: Starts and stops vncserver
-# Description: Used to provide remote X administration services.
-### END INIT INFO
-
-# Source function library.
-. /lib/lsb/init-functions
-
-### Default variables
-SYSCONFIG="/etc/default/vncservers"
-VNCSERVERS=""
-
-### Read configuration
-[ -r "$SYSCONFIG" ] && . "$SYSCONFIG"
-
-RETVAL=0
-prog=$"VNC server"
-
-start() {
- echo -n $"Starting $prog: "
- ulimit -S -c 0 >/dev/null 2>&1
- for display in ${VNCSERVERS}; do
- echo -n "${display} "
- if [ -r $(eval echo ~${display##*:})/.vnc/passwd ]; then
- unset BASH_ENV ENV
- log_begin_msg "Starting VNC Server for user ${display##*:}:"
- su ${display##*:} -c "cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*} ${VNCSERVERARGS[${display%:*}]}"
- RETVAL="$?"
- if [ "$RETVAL" -ne 0 ]; then
- log_end_msg 1
- break
- else
- log_end_msg 0
- fi
- else
- log_begin_msg "Not starting VNC Server for user ${display##*:}.\n File \"~${display##*:}/.vnc/passwd\" not found.\n Create a password file for the VNC server with vncpasswd"
- log_end_msg 1
- fi
- done
- echo
- [ "$RETVAL" -eq 0 ] && touch "/var/lock/vncserver"
- return $RETVAL
-}
-
-stop() {
- echo -n $"Shutting down $desc: "
- for display in ${VNCSERVERS}; do
- echo -n "${display} "
- unset BASH_ENV ENV
- log_begin_msg "Shutting down VNC Server for user ${display##*:}: "
- su ${display##*:} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
- RETVAL="$?"
- [ "$RETVAL" -eq 0 ] && log_end_msg 0 || log_end_msg 1
- done
- echo
- [ "$RETVAL" -eq 0 ] && rm -f "/var/lock/vncserver"
- return $RETVAL
-}
-
-restart() {
- stop
- start
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- RETVAL=1
-esac
-
-exit $RETVAL
+++ /dev/null
-# 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, see this URL:
-# http://kbase.redhat.com/faq/docs/DOC-7028
-
-# 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"
cmake -G"Unix Makefiles" \
-DBUILD_STATIC=off \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
- -DSYSCONF_DIR:PATH=/etc
+ -DSYSCONF_DIR:PATH=/etc \
+ -DUNIT_DIR:PATH=/lib/systemd/system
(cd unix/xserver; \
export PIXMANINCDIR=/usr/include/pixman-1; \
autoreconf -fiv; \
$(CURDIR)/debian/tigervncserver/usr/share/man/man1/Xtigervnc.1
# delete development files
rm -f $(CURDIR)/debian/tigervncserver/usr/lib/xorg/modules/extensions/libvnc.la
- # install server service
- install -o root -g root -m 755 -D $(CURDIR)/debian/local/vncserver.service \
- $(CURDIR)/debian/tigervncserver/etc/init.d/vncserver
- install -o root -g root -m 644 -D $(CURDIR)/debian/local/vncserver.sysconfig \
- $(CURDIR)/debian/tigervncserver/etc/default/vncservers
# move viewer files to viewer package, rename on the fly
mkdir -p $(CURDIR)/debian/xtigervncviewer/usr/bin
mv $(CURDIR)/debian/tigervncserver/usr/bin/vncviewer \
+++ /dev/null
-#!/bin/bash
-#
-# Init file for TigerVNC Server
-#
-# chkconfig: - 91 35
-# description: TigerVNC remote X administration daemon.
-#
-# processname: Xvnc
-
-### BEGIN INIT INFO
-# Provides: vncservers
-# Required-Start: networking
-# Required-Stop: networking
-# Default-Start:
-# Default-Stop: 0 1 2 3 4 5 6
-# Short-Description: Starts and stops vncserver
-# Description: Used to provide remote X administration services.
-### END INIT INFO
-
-# Source function library.
-. /lib/lsb/init-functions
-
-### Default variables
-SYSCONFIG="/etc/default/vncservers"
-VNCSERVERS=""
-
-### Read configuration
-[ -r "$SYSCONFIG" ] && . "$SYSCONFIG"
-
-RETVAL=0
-prog=$"VNC server"
-
-start() {
- echo -n $"Starting $prog: "
- ulimit -S -c 0 >/dev/null 2>&1
- for display in ${VNCSERVERS}; do
- echo -n "${display} "
- if [ -r $(eval echo ~${display##*:})/.vnc/passwd ]; then
- unset BASH_ENV ENV
- log_begin_msg "Starting VNC Server for user ${display##*:}:"
- su ${display##*:} -c "cd ~${display##*:} && [ -f .vnc/passwd ] && vncserver :${display%%:*} ${VNCSERVERARGS[${display%:*}]}"
- RETVAL="$?"
- if [ "$RETVAL" -ne 0 ]; then
- log_end_msg 1
- break
- else
- log_end_msg 0
- fi
- else
- log_begin_msg "Not starting VNC Server for user ${display##*:}.\n File \"~${display##*:}/.vnc/passwd\" not found.\n Create a password file for the VNC server with vncpasswd"
- log_end_msg 1
- fi
- done
- echo
- [ "$RETVAL" -eq 0 ] && touch "/var/lock/vncserver"
- return $RETVAL
-}
-
-stop() {
- echo -n $"Shutting down $desc: "
- for display in ${VNCSERVERS}; do
- echo -n "${display} "
- unset BASH_ENV ENV
- log_begin_msg "Shutting down VNC Server for user ${display##*:}: "
- su ${display##*:} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
- RETVAL="$?"
- [ "$RETVAL" -eq 0 ] && log_end_msg 0 || log_end_msg 1
- done
- echo
- [ "$RETVAL" -eq 0 ] && rm -f "/var/lock/vncserver"
- return $RETVAL
-}
-
-restart() {
- stop
- start
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- restart
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- RETVAL=1
-esac
-
-exit $RETVAL
+++ /dev/null
-# 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, see this URL:
-# http://kbase.redhat.com/faq/docs/DOC-7028
-
-# 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"
cmake -G"Unix Makefiles" \
-DBUILD_STATIC=off \
-DCMAKE_INSTALL_PREFIX:PATH=/usr \
- -DSYSCONF_DIR:PATH=/etc
+ -DSYSCONF_DIR:PATH=/etc \
+ -DUNIT_DIR:PATH=/lib/systemd/system
(cd unix/xserver; \
export PIXMANINCDIR=/usr/include/pixman-1; \
autoreconf -fiv; \
$(CURDIR)/debian/tigervncserver/usr/share/man/man1/Xtigervnc.1
# delete development files
rm -f $(CURDIR)/debian/tigervncserver/usr/lib/xorg/modules/extensions/libvnc.la
- # install server service
- install -o root -g root -m 755 -D $(CURDIR)/debian/local/vncserver.service \
- $(CURDIR)/debian/tigervncserver/etc/init.d/vncserver
- install -o root -g root -m 644 -D $(CURDIR)/debian/local/vncserver.sysconfig \
- $(CURDIR)/debian/tigervncserver/etc/default/vncservers
# move viewer files to viewer package, rename on the fly
mkdir -p $(CURDIR)/debian/xtigervncviewer/usr/bin
mv $(CURDIR)/debian/tigervncserver/usr/bin/vncviewer \
+++ /dev/null
-# The vncserver service unit file
-#
-# Quick HowTo:
-# 1. Copy this file to /etc/systemd/system/vncserver@.service
-# 2. Edit <USER> and vncserver parameters appropriately
-# ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
-# 3. Run `systemctl daemon-reload`
-# 4. Run `systemctl enable vncserver@:<display>.service`
-#
-# 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
-# Clean any existing files in /tmp/.X11-unix environment
-ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
-ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
-PIDFile=/home/<USER>/.vnc/%H%i.pid
-ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
-
-[Install]
-WantedBy=multi-user.target
+++ /dev/null
-# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service
URL: http://www.tigervnc.com
Source0: %{name}-%{version}%{?snap:-%{snap}}.tar.bz2
-Source1: vncserver.service
-Source2: vncserver.sysconfig
Source3: 10-libvnc.conf
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
make install DESTDIR=$RPM_BUILD_ROOT
popd
-# 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
-
%find_lang %{name} %{name}.lang
# remove unwanted files
%{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor || :
fi
-%post server
-%systemd_post vncserver.service
-
-%triggerun -- tigervnc-server < 1.0.90-6
-%{_bindir}/systemd-sysv-convert --save vncserver >/dev/null 2>&1 ||:
-/sbin/chkconfig --del vncserver >/dev/null 2>&1 || :
-
-%preun server
-%systemd_preun vncserver.service
-
-%postun server
-%systemd_postun
-
%files -f %{name}.lang
%defattr(-,root,root,-)
%doc %{_docdir}/%{name}-%{version}/README.rst
%files server
%defattr(-,root,root,-)
-%config(noreplace) %{_sysconfdir}/sysconfig/vncservers
%config(noreplace) %{_sysconfdir}/tigervnc/vncserver-config-defaults
%config(noreplace) %{_sysconfdir}/tigervnc/vncserver-config-mandatory
%{_unitdir}/vncserver@.service
+++ /dev/null
-#
-# /usr/lib/systemd/user/vncserver@.service
-#
-# 1. Switches for vncserver should be entered in ~/.vnc/config rather than
-# hard-coded into this unit file. See the vncserver(1) manpage.
-#
-# 2. Users wishing for the server to continue running after the owner logs
-# out MUST enable 'linger' with loginctl like this:
-# `loginctl enable-linger username`
-#
-# 3. The server can be enabled and started like this once configured:
-# `systemctl --user start vncserver@:<display>.service`
-# `systemctl --user enable vncserver@:<display>.service`
-
-[Unit]
-Description=Remote desktop service (VNC)
-After=syslog.target network.target
-
-[Service]
-Type=forking
-ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
-ExecStart=/usr/bin/vncserver %i
-ExecStop=/usr/bin/vncserver -kill %i
-
-[Install]
-WantedBy=default.target
+configure_file(vncserver@.service.in vncserver@.service @ONLY)
+
install(PROGRAMS vncserver DESTINATION ${BIN_DIR})
install(FILES vncserver.man DESTINATION ${MAN_DIR}/man1 RENAME vncserver.1)
install(FILES vncserver-config-defaults vncserver-config-mandatory DESTINATION ${SYSCONF_DIR}/tigervnc)
+
+if(INSTALL_SYSTEMD_UNITS)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vncserver@.service DESTINATION ${UNIT_DIR})
+endif()
--- /dev/null
+# The vncserver service unit file
+#
+# Quick HowTo:
+# 1. Copy this file to /etc/systemd/system/vncserver@.service
+# 2. Edit <USER> and vncserver parameters appropriately
+# ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
+# 3. Run `systemctl daemon-reload`
+# 4. Run `systemctl enable vncserver@:<display>.service`
+#
+# 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
+# Clean any existing files in /tmp/.X11-unix environment
+ExecStartPre=/bin/sh -c '@BIN_DIR@/vncserver -kill %i > /dev/null 2>&1 || :'
+ExecStart=/usr/sbin/runuser -l <USER> -c "@BIN_DIR@/vncserver %i"
+PIDFile=/home/<USER>/.vnc/%H%i.pid
+ExecStop=/bin/sh -c '@BIN_DIR@/vncserver -kill %i > /dev/null 2>&1 || :'
+
+[Install]
+WantedBy=multi-user.target