Add systemd service file and remove legacy SysV initscript (#717227)
Signed-off-by: Adam Tkac <atkac@redhat.com>
This commit is contained in:
parent
6db666fe0e
commit
9956c17c57
@ -1,6 +1,6 @@
|
|||||||
Name: tigervnc
|
Name: tigervnc
|
||||||
Version: 1.0.90
|
Version: 1.0.90
|
||||||
Release: 5%{?dist}
|
Release: 6%{?dist}
|
||||||
Summary: A TigerVNC remote display system
|
Summary: A TigerVNC remote display system
|
||||||
|
|
||||||
Group: User Interface/Desktops
|
Group: User Interface/Desktops
|
||||||
@ -8,7 +8,7 @@ License: GPLv2+
|
|||||||
URL: http://www.tigervnc.com
|
URL: http://www.tigervnc.com
|
||||||
|
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
Source1: vncserver.init
|
Source1: vncserver.service
|
||||||
Source2: vncserver.sysconfig
|
Source2: vncserver.sysconfig
|
||||||
Source6: vncviewer.desktop
|
Source6: vncviewer.desktop
|
||||||
Source7: xserver110.patch
|
Source7: xserver110.patch
|
||||||
@ -23,13 +23,15 @@ BuildRequires: mesa-libGL-devel, libXinerama-devel, ImageMagick
|
|||||||
BuildRequires: freetype-devel, libXdmcp-devel
|
BuildRequires: freetype-devel, libXdmcp-devel
|
||||||
BuildRequires: desktop-file-utils, java-1.5.0-gcj-devel
|
BuildRequires: desktop-file-utils, java-1.5.0-gcj-devel
|
||||||
BuildRequires: libjpeg-turbo-devel, gnutls-devel, pam-devel
|
BuildRequires: libjpeg-turbo-devel, gnutls-devel, pam-devel
|
||||||
|
BuildRequires: systemd-units
|
||||||
|
|
||||||
%ifarch %ix86 x86_64
|
%ifarch %ix86 x86_64
|
||||||
BuildRequires: nasm
|
BuildRequires: nasm
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
Requires(post): coreutils
|
Requires(post): systemd-units systemd-sysv chkconfig coreutils
|
||||||
Requires(postun):coreutils
|
Requires(preun):systemd-units
|
||||||
|
Requires(postun):systemd-units coreutils
|
||||||
Requires: hicolor-icon-theme
|
Requires: hicolor-icon-theme
|
||||||
Requires: tigervnc-license
|
Requires: tigervnc-license
|
||||||
|
|
||||||
@ -202,9 +204,10 @@ pushd unix/xserver/hw/vnc
|
|||||||
make install DESTDIR=$RPM_BUILD_ROOT
|
make install DESTDIR=$RPM_BUILD_ROOT
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Install Xvnc as service
|
# Install systemd unit file
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_initddir}
|
mkdir -p %{buildroot}%{_unitdir}
|
||||||
install -m755 %{SOURCE1} $RPM_BUILD_ROOT%{_initddir}/vncserver
|
install -m644 %{SOURCE1} %{buildroot}%{_unitdir}/vncserver@.service
|
||||||
|
rm -rf %{buildroot}%{_initrddir}
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
|
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
|
||||||
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/vncservers
|
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/vncservers
|
||||||
@ -255,19 +258,25 @@ if [ -x %{_bindir}/gtk-update-icon-cache ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
%post server
|
%post server
|
||||||
/sbin/chkconfig --add vncserver
|
/bin/systemctl daemon-reload > /dev/null 2>&1
|
||||||
|
|
||||||
%preun server
|
%preun server
|
||||||
if [ "$1" -eq 0 ]; then
|
if [ "$1" -eq 0 ]; then
|
||||||
/sbin/service vncserver stop > /dev/null 2>&1
|
/bin/systemctl --no-reload vncserver.service > /dev/null 2>&1
|
||||||
/sbin/chkconfig --del vncserver
|
/bin/systemctl stop vncserver.service > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%postun server
|
%postun server
|
||||||
if [ "$1" -ge "1" ]; then
|
if [ "$1" -ge "1" ]; then
|
||||||
/sbin/service vncserver condrestart > /dev/null 2>&1 || :
|
/bin/systemctl try-restart vncserver.service > /dev/null 2>&1
|
||||||
fi
|
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
|
%files -f %{name}.lang
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%doc unix/README
|
%doc unix/README
|
||||||
@ -279,7 +288,7 @@ fi
|
|||||||
%files server
|
%files server
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%config(noreplace) %{_sysconfdir}/sysconfig/vncservers
|
%config(noreplace) %{_sysconfdir}/sysconfig/vncservers
|
||||||
%{_initddir}/vncserver
|
%{_unitdir}/vncserver@.service
|
||||||
%{_bindir}/x0vncserver
|
%{_bindir}/x0vncserver
|
||||||
%{_bindir}/vncserver
|
%{_bindir}/vncserver
|
||||||
%{_mandir}/man1/vncserver.1*
|
%{_mandir}/man1/vncserver.1*
|
||||||
@ -309,6 +318,9 @@ fi
|
|||||||
%doc LICENCE.TXT
|
%doc LICENCE.TXT
|
||||||
|
|
||||||
%changelog
|
%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
|
* Tue May 12 2011 Adam Tkac <atkac redhat com> - 1.0.90-5
|
||||||
- make Xvnc buildable against X.Org 1.11
|
- make Xvnc buildable against X.Org 1.11
|
||||||
|
|
||||||
|
149
vncserver.init
149
vncserver.init
@ -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"
|
|
||||||
|
|
42
vncserver.service
Normal file
42
vncserver.service
Normal file
@ -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@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
|
@ -1,30 +1 @@
|
|||||||
# The VNCSERVERS variable is a list of display:user pairs.
|
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service
|
||||||
#
|
|
||||||
# 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"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user