blob: 187b3c7296b4fe69c8279f9cbd4d00957f7ca5d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/sbin/openrc-run
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License, v2 or later
# shellcheck shell=sh
depend() {
need net
}
checkconfig() {
if [ -n "${DISPLAYS}" ]; then
if [ "$1" = "start" ]; then
for user in $DISPLAYS; do
# bug #690046
if ! runuser -l "${user%%:*}" -c "[ -f ~/.vnc/passwd ]"; then
eerror "There are no passwords defined for user ${user%%:*}."
return 1
elif [ -e "/tmp/.X11-unix/X${user##*:}" ]; then
eerror "Display :${user##*:} appears to be already in use because of /tmp/.X11-unix/X${user##*:}"
eerror "Remove this file if there is no X server for :${user##*:}"
return 1
elif [ -e "/tmp/.X${user##*:}-lock" ]; then
eerror "Display :${user##*:} appears to be already in use because of /tmp/.X${user##*:}-lock"
eerror "Remove this file if there is no X server for :${user##*:}"
return 1
elif ! grep -E "^[^#]*:${user##*:}=${user%%:*}" /etc/tigervnc/vncserver.users > /dev/null 2>&1; then
eerror "User ${user%%:*} is not defined for display :${user##*:} in /etc/tigervnc/vncserver.users"
return 1
fi
done
fi
return 0
else
# here it is intended for $DISPLAYS to not expand
# shellcheck disable=SC2016
eerror 'Please define $DISPLAYS in /etc/conf.d/tigervnc'
return 1
fi
}
start() {
checkconfig start || return 1
ebegin "Starting TigerVNC server"
for user in $DISPLAYS; do
[ -n "${TIGERVNC_XSESSION_FILE}" ] && export TIGERVNC_XSESSION_FILE
/usr/libexec/vncsession-start ":${user##*:}" >/dev/null 2>&1
done
eend $?
}
stop() {
checkconfig stop || return 2
ebegin "Stopping TigerVNC server"
for user in $DISPLAYS; do
# vncserver no longer provides a `-kill` option
# killing vncsession does not work, we have to kill Xvnc
# run pstree to see exactly what's going on
sessionpid=$(cat /run/vncsession-:"${user##*:}".pid)
serverpid=$(pstree -p "$sessionpid" | grep Xvnc | sed -e 's/^.*Xvnc(//
s/).*$//')
kill "$serverpid" >/dev/null 2>&1
done
# Do not fail if a server is missing
/bin/true
eend $?
}
restart() {
svc_stop
svc_start
}
|