From: Pierre Ossman Date: Fri, 22 Dec 2017 09:35:29 +0000 (+0100) Subject: Always install systemd services X-Git-Tag: v1.10.90~40^2~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=df25ae41194eb85a48ccfabd7cb7d2c338ff4300;p=tigervnc.git Always install systemd services It is the most common init system these days so it should not be hidden in the contrib/ directory. This also removes all old SysV files from the contrib packages. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e715f26c..f6742e7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,12 +33,15 @@ set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share") 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() diff --git a/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.service b/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.service deleted file mode 100644 index 86a8a910..00000000 --- a/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.service +++ /dev/null @@ -1,94 +0,0 @@ -#!/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 diff --git a/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.sysconfig b/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.sysconfig deleted file mode 100644 index d18d0f14..00000000 --- a/contrib/packages/deb/ubuntu-bionic/debian/local/vncserver.sysconfig +++ /dev/null @@ -1,19 +0,0 @@ -# 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" diff --git a/contrib/packages/deb/ubuntu-bionic/debian/rules b/contrib/packages/deb/ubuntu-bionic/debian/rules index e60413d3..ff6ff18e 100644 --- a/contrib/packages/deb/ubuntu-bionic/debian/rules +++ b/contrib/packages/deb/ubuntu-bionic/debian/rules @@ -57,7 +57,8 @@ config-stamp: xorg-source-stamp 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; \ @@ -187,11 +188,6 @@ install: build $(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 \ diff --git a/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.service b/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.service deleted file mode 100644 index 86a8a910..00000000 --- a/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.service +++ /dev/null @@ -1,94 +0,0 @@ -#!/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 diff --git a/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.sysconfig b/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.sysconfig deleted file mode 100644 index d18d0f14..00000000 --- a/contrib/packages/deb/ubuntu-xenial/debian/local/vncserver.sysconfig +++ /dev/null @@ -1,19 +0,0 @@ -# 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" diff --git a/contrib/packages/deb/ubuntu-xenial/debian/rules b/contrib/packages/deb/ubuntu-xenial/debian/rules index 7fbde337..35bc2d08 100644 --- a/contrib/packages/deb/ubuntu-xenial/debian/rules +++ b/contrib/packages/deb/ubuntu-xenial/debian/rules @@ -58,7 +58,8 @@ config-stamp: xorg-source-stamp 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; \ @@ -188,11 +189,6 @@ install: build $(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 \ diff --git a/contrib/packages/rpm/el7/SOURCES/vncserver.service b/contrib/packages/rpm/el7/SOURCES/vncserver.service deleted file mode 100644 index 4cec744c..00000000 --- a/contrib/packages/rpm/el7/SOURCES/vncserver.service +++ /dev/null @@ -1,45 +0,0 @@ -# The vncserver service unit file -# -# Quick HowTo: -# 1. Copy this file to /etc/systemd/system/vncserver@.service -# 2. Edit and vncserver parameters appropriately -# ("runuser -l -c /usr/bin/vncserver %i -arg1 -arg2") -# 3. Run `systemctl daemon-reload` -# 4. Run `systemctl enable vncserver@:.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 -c "/usr/bin/vncserver %i" -PIDFile=/home//.vnc/%H%i.pid -ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' - -[Install] -WantedBy=multi-user.target diff --git a/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig b/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig deleted file mode 100644 index 4d0489b4..00000000 --- a/contrib/packages/rpm/el7/SOURCES/vncserver.sysconfig +++ /dev/null @@ -1 +0,0 @@ -# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service diff --git a/contrib/packages/rpm/el7/SPECS/tigervnc.spec b/contrib/packages/rpm/el7/SPECS/tigervnc.spec index 110497e1..215d1dae 100644 --- a/contrib/packages/rpm/el7/SPECS/tigervnc.spec +++ b/contrib/packages/rpm/el7/SPECS/tigervnc.spec @@ -9,8 +9,6 @@ Packager: Brian P. Hinz 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) @@ -188,14 +186,6 @@ pushd unix/xserver/hw/vnc 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 @@ -223,19 +213,6 @@ if [ -x %{_bindir}/gtk-update-icon-cache ]; then %{_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 @@ -245,7 +222,6 @@ fi %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 diff --git a/contrib/systemd/user/vncserver@.service b/contrib/systemd/user/vncserver@.service deleted file mode 100644 index 7797504b..00000000 --- a/contrib/systemd/user/vncserver@.service +++ /dev/null @@ -1,26 +0,0 @@ -# -# /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@:.service` -# `systemctl --user enable vncserver@:.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 diff --git a/unix/vncserver/CMakeLists.txt b/unix/vncserver/CMakeLists.txt index 66917866..e048aaf8 100644 --- a/unix/vncserver/CMakeLists.txt +++ b/unix/vncserver/CMakeLists.txt @@ -1,3 +1,9 @@ +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() diff --git a/unix/vncserver/vncserver@.service.in b/unix/vncserver/vncserver@.service.in new file mode 100644 index 00000000..07f1e517 --- /dev/null +++ b/unix/vncserver/vncserver@.service.in @@ -0,0 +1,45 @@ +# The vncserver service unit file +# +# Quick HowTo: +# 1. Copy this file to /etc/systemd/system/vncserver@.service +# 2. Edit and vncserver parameters appropriately +# ("runuser -l -c /usr/bin/vncserver %i -arg1 -arg2") +# 3. Run `systemctl daemon-reload` +# 4. Run `systemctl enable vncserver@:.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 -c "@BIN_DIR@/vncserver %i" +PIDFile=/home//.vnc/%H%i.pid +ExecStop=/bin/sh -c '@BIN_DIR@/vncserver -kill %i > /dev/null 2>&1 || :' + +[Install] +WantedBy=multi-user.target