diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /x11-misc/virtualgl/files |
reinit the tree, so we can have metadata
Diffstat (limited to 'x11-misc/virtualgl/files')
-rw-r--r-- | x11-misc/virtualgl/files/vgl-helper.sh | 39 | ||||
-rw-r--r-- | x11-misc/virtualgl/files/vgl.confd-r2 | 27 | ||||
-rw-r--r-- | x11-misc/virtualgl/files/vgl.initd-r3 | 45 | ||||
-rw-r--r-- | x11-misc/virtualgl/files/vgl.service | 13 |
4 files changed, 124 insertions, 0 deletions
diff --git a/x11-misc/virtualgl/files/vgl-helper.sh b/x11-misc/virtualgl/files/vgl-helper.sh new file mode 100644 index 000000000000..805409284862 --- /dev/null +++ b/x11-misc/virtualgl/files/vgl-helper.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +. /etc/vgl.conf + +vgl_start() { + truncate --size=0 /var/lib/VirtualGL/vgl_xauth_key + + set_xauth + # Check if XAUTHORITY was set successfully, if not wait up to + # 60 seconds to allow X start. + tries=120 + while [ ${tries} -gt 0 ]; do + tries=$((tries - 1)) + if [ -z "${XAUTHORITY}" ]; then + sleep 0.5 + set_xauth + continue + elif [ ! -e "${XAUTHORITY}" ]; then + sleep 0.5 + # fall through, file not existing yet + fi + break + done + + xauth -f /var/lib/VirtualGL/vgl_xauth_key add $DISPLAY . \ + $(xauth -f $XAUTHORITY list | awk '{print $3;exit}') && \ + chmod 644 /var/lib/VirtualGL/vgl_xauth_key +} + +vgl_stop() { + rm -f /var/lib/VirtualGL/vgl_xauth_key +} + + +if [ "${1}" = "start" ]; then + vgl_start +elif [ "${1}" = "stop" ]; then + vgl_stop +fi diff --git a/x11-misc/virtualgl/files/vgl.confd-r2 b/x11-misc/virtualgl/files/vgl.confd-r2 new file mode 100644 index 000000000000..a0cf7c5f2fde --- /dev/null +++ b/x11-misc/virtualgl/files/vgl.confd-r2 @@ -0,0 +1,27 @@ +# /etc/conf.d/vgl + +DISPLAY="${DISPLAY:-:0}" + +# Make it a function in case we have to repeat it in init script later +set_xauth() { + +# common case (works in almost all tested environments (except of lightdm)): +XAUTHORITY="$(ps wwax -C X,Xorg -o args= --sort=-stime | grep -m 1 -o '\B[-]auth\s*/var\S*' | cut -d ' ' -f 2)" + +# kdm and some others: +# XAUTHORITY="$(find /var/run/xauth/A${DISPLAY}-*|tail -n1)" + +# gdm: +# XAUTHORITY="/var/gdm/${DISPLAY}.Xauth" + +# slim: +# XAUTHORITY="/var/run/slim.auth" + +# lightdm: +# XAUTHORITY="/var/run/lightdm/root/${DISPLAY}" + +# lxdm: +# XAUTHORITY="/var/run/lxdm/lxdm-${DISPLAY}.auth" + +} +set_xauth diff --git a/x11-misc/virtualgl/files/vgl.initd-r3 b/x11-misc/virtualgl/files/vgl.initd-r3 new file mode 100644 index 000000000000..951d73287d23 --- /dev/null +++ b/x11-misc/virtualgl/files/vgl.initd-r3 @@ -0,0 +1,45 @@ +#!/sbin/openrc-run +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# TODO: description="*" and other OpenRC 0.9+ candies + +depend() { + need xdm + after sshd +} + +start() { + ebegin "Starting VirtualGL" + truncate --size=0 /var/lib/VirtualGL/vgl_xauth_key + + set_xauth + + if [ -z "$XAUTHORITY" ]; then + + einfo "Waiting for xauthority..." + + # wait for xauth file + while true; do + set_xauth + + if [ -e "$XAUTHORITY" ]; then + break; + fi + + sleep 1 + done + fi + + + xauth -f /var/lib/VirtualGL/vgl_xauth_key add $DISPLAY . $(xauth -f $XAUTHORITY list | awk '{print $3;exit}') && \ + chmod 644 /var/lib/VirtualGL/vgl_xauth_key + eend $? +} + +stop() { + ebegin "Stopping VirtualGL" + [ -f /var/lib/VirtualGL/vgl_xauth_key ] && \ + rm /var/lib/VirtualGL/vgl_xauth_key + eend $? +} diff --git a/x11-misc/virtualgl/files/vgl.service b/x11-misc/virtualgl/files/vgl.service new file mode 100644 index 000000000000..a001e8a1d2f1 --- /dev/null +++ b/x11-misc/virtualgl/files/vgl.service @@ -0,0 +1,13 @@ +[Unit] +Description=VirtualGL service +After=display-manager.service + +[Service] +RemainAfterExit=yes +PIDFile=/var/run/named/named.pid +ExecStart=/usr/libexec/vgl-helper.sh start +ExecStop=/usr/libexec/vgl-helper.sh stop + +[Install] +WantedBy=multi-user.target + |