blob: e433b095fe315c3a96e6ff0f38939ee0815c14dc (
plain) (
tree)
|
|
#!/bin/bash
# This script launches the real vmchooser (vmchooser.real)
# It's here to pass the XML URL, coming from
# /opt/openslx/config, as well as the pool filter (if any)
. /opt/openslx/config
unset MEM URL ERRMSG EXTRA TAB HW_MBRAM HW_ID44
declare -a EXTRA
if [ -n "$SLX_VMCHOOSER_BASE_URL" ]; then
URL="$SLX_VMCHOOSER_BASE_URL"
elif [ -n "$SLX_PXE_SERVER_IP" ]; then
URL="http://$SLX_PXE_SERVER_IP/vmchooser/"
else
slxlog "virt-vmchooser" "vmchooser: Could not determine URL to fetch VM list from! (need SLX_VMCHOOSER_BASE_URL)"
ERRMSG="Keine URL zum Abrufen der verfügbaren Veranstaltungen definiert. Versuchen Sie, den Computer neu zu starten und wenden Sie sich an den Support, wenn das Problem weiterhin besteht."
/opt/openslx/cups/printergui --error "$ERRMSG" || notify-send "Fehler" "$ERRMSG"
fi
URLS_CONF="/opt/openslx/vmchooser/config/resource_urls.conf"
if [ -s "$URLS_CONF" ]; then
. "$URLS_CONF"
[ -n "$url_list" ] && EXTRA+=( "--url-list" "$url_list" )
[ -n "$url_news" ] && EXTRA+=( "--url-news" "$url_news" )
[ -n "$url_help" ] && EXTRA+=( "--url-help" "$url_help" )
fi
[ -s "/run/openslx/hwinfo" ] && . "/run/openslx/hwinfo"
if [ -z "$HW_MBRAM" ]; then
MEM=$(grep -m1 '^MemTotal:' /proc/meminfo | awk '{print $2}')
HW_MBRAM=$(( MEM / 1024 ))
fi
# No/small ID44 = penalty to available ram
if [ -n "$HW_ID44" ] && ! [ "$HW_ID44" -gt 9000 ]; then # Use negation so NaN -> TRUE
HW_MBRAM=$(( ( HW_MBRAM * 3 ) / 4 ))
fi
if [[ "$SLX_VMCHOOSER_TAB" =~ ^[012]$ ]]; then
TAB="$SLX_VMCHOOSER_TAB"
elif (( HW_MBRAM < 5000 )); then # Check RAM size; if it's not that much, default to the native linux sessions
TAB=0
# Only force if we have a "real" desktop
name=
for i in xfce xfce4 kde KDE plasma kde5; do
i="/usr/share/xsessions/${i}.desktop"
[ -f "$i" ] || continue
name="$( grep -oP '(?<=^Name=).*' "$i" )"
break
done
if [ -n "$name" ]; then
EXTRA+=( "--force-tab" "--default" "$name" )
fi
else
TAB=2
fi
[ -n "$SLX_VMCHOOSER_TEMPLATES" ] && EXTRA+=( "--template-mode" "$SLX_VMCHOOSER_TEMPLATES" )
[ -n "$SLX_VMCHOOSER_FORLOCATION" ] && EXTRA+=( "--location-mode" "$SLX_VMCHOOSER_FORLOCATION" )
[ "$HW_KVM" != "ENABLED" ] && EXTRA+=( "--no-vtx" )
if [ -n "$SLX_EXAM" ]; then
EXTRA+=( "--exam-mode" )
elif [ -n "$SLX_AUTOSTART_UUID" ]; then
SLX_EXAM_START="$SLX_AUTOSTART_UUID"
fi
if [ -z "$SLX_NO_PVS" ]; then
EXTRA+=( "--pvs" )
if [ "$SLX_PVS_DEFAULT" = "ON" ] || [ "$SLX_PVS_HYBRID" = "yes" ]; then
# Config option says checked by default, or this is hybrid manager
EXTRA+=( "--pvs-checked" )
elif grep -q -F -x -e "tutorIP=$SLX_PXE_CLIENT_IP" -e "tutorIP=$SLX_DHCP_CLIENT_IP" "/opt/openslx/pvs2/pvs2.ini"; then
# This IP is a tutor, also autoconnect
EXTRA+=( "--pvs-checked" )
fi
fi
if [ -z "${SLX_AUTOLOGIN%OFF}" ] && [ -n "$SLX_VMCHOOSER_TIMEOUT" ] && [ "$SLX_VMCHOOSER_TIMEOUT" -gt 0 ]; then
EXTRA+=( "--autoquit" "$SLX_VMCHOOSER_TIMEOUT" )
fi
# Delay autologin a bit to prevent the old vm process still cleaning up while trying to
# set up a new one -- this might lead to OOM errors
if /opt/openslx/lightdm/is-autologin-enabled; then
[ -s "/tmp/another-autologin" ] && sleep 5
touch "/tmp/another-autologin"
fi
if [ -n "$SLX_LOCATIONS" ]; then
EXTRA+=( "--locations" "$SLX_LOCATIONS" )
fi
if [ -n "$SLX_SCREEN_SAVER_TIMEOUT" ]; then
EXTRA+=( "--allow-screensaver-disable" )
fi
if [ -s "/run/user/$(id -u)/cow-token" ]; then
EXTRA+=( "--cow-token" "$( cat "/run/user/$(id -u)/cow-token" )" )
fi
set +x
exec vmchooser.real "$@" --url "$URL" --fullscreen --tab "$TAB" --start-uuid "$SLX_EXAM_START" "${EXTRA[@]}"
|