diff options
Diffstat (limited to 'remote/modules')
14 files changed, 123 insertions, 120 deletions
diff --git a/remote/modules/busybox/openslx-busybox-config b/remote/modules/busybox/openslx-busybox-config index ee5e99ee..00a008d7 100644 --- a/remote/modules/busybox/openslx-busybox-config +++ b/remote/modules/busybox/openslx-busybox-config @@ -39,7 +39,7 @@ CONFIG_LAST_SUPPORTED_WCHAR=767 CONFIG_LONG_OPTS=y CONFIG_FEATURE_DEVPTS=y # CONFIG_FEATURE_CLEAN_UP is not set -# CONFIG_FEATURE_UTMP is not set +CONFIG_FEATURE_UTMP=y # CONFIG_FEATURE_WTMP is not set CONFIG_FEATURE_PIDFILE=y CONFIG_PID_FILE_PATH="/var/run" diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats index 6c0b667b..ce910a2b 100755 --- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats +++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats @@ -198,6 +198,8 @@ for DELAY in 1 1 0; do ${START}-59/5 * * * * root /opt/openslx/scripts/cron-system_usage_update EOF + touch "/etc/cron.d" # Sometimes, aufs doesn't update the mtime of dirs when creating files, + # so cron would not rescan the cron directory exit 0 fi sleep "$DELAY" diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script index 9a9bdf1c..b7617940 100755 --- a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script +++ b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script @@ -29,7 +29,7 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then if [ -n "$DISPLAY" ]; then # Seems to be x11 IDLE= - export XAUTHORITY=$(ps a | grep -v grep | grep -o -- '-auth.*$' | awk '{print $2}') + export XAUTHORITY=$(ps a | grep " $DISPLAY " | grep -o -- '-auth.*$' | grep -m1 -v grep | awk '{print $2}') [ -n "$XAUTHORITY" ] && [ -f "$XAUTHORITY" ] && IDLE=$(xprintidle) # Now that we have DISPLAY and XAUTHORITY set, xprintidle should work if [ -z "$IDLE" ]; then @@ -95,7 +95,7 @@ if [ -n "${SLX_SHUTDOWN_TIMEOUT}" ] && [ "${SLX_SHUTDOWN_TIMEOUT}" -gt 0 ] && [ [ "$IDLE" -gt "$NOW" ] && IDLE="$NOW" IDLE=$(( $NOW - $IDLE )) if [ "$IDLE" -gt "$SLX_SHUTDOWN_TIMEOUT" ]; then - poweroff -nf # TODO: Do proper shutdown once it works reliably + poweroff fi fi @@ -122,7 +122,7 @@ if [ -n "$SLX_SHUTDOWN_SCHEDULE" -o -n "$SLX_REBOOT_SCHEDULE" ] && [ ! -e "$CRON [ -z "$HOUR$MINUTE" ] && invalid_time && continue [ "$HOUR" -lt 0 -o "$HOUR" -gt 23 ] && invalid_time && continue [ "$MINUTE" -lt 0 -o "$MINUTE" -gt 59 ] && invalid_time && continue - echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_poweroff" >> "$CRONFILE" + echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_action poweroff" >> "$CRONFILE" done # do it again for SLX_REBOOT_SCHEDULE for time in $SLX_REBOOT_SCHEDULE; do @@ -131,11 +131,8 @@ if [ -n "$SLX_SHUTDOWN_SCHEDULE" -o -n "$SLX_REBOOT_SCHEDULE" ] && [ ! -e "$CRON [ -z "$HOUR$MINUTE" ] && invalid_time && continue [ "$HOUR" -lt 0 -o "$HOUR" -gt 23 ] && invalid_time && continue [ "$MINUTE" -lt 0 -o "$MINUTE" -gt 59 ] && invalid_time && continue - echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_reboot" >> "$CRONFILE" + echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_action reboot" >> "$CRONFILE" done - ( - sleep 20 - systemctl restart cron - ) & + touch "/etc/cron.d" # Aufs bug where it won't update dir mtime when creating the file within fi diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action new file mode 100755 index 00000000..6ef6969c --- /dev/null +++ b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action @@ -0,0 +1,77 @@ +#!/bin/ash + +if [ "$(whoami)" != "root" ]; then + echo "Only root can call this" + exit 1 +fi + +if [ $# -ne 1 ]; then + echo "$0 <reboot|poweroff>" + exit 1 +fi + +MODE=$1 + +if [ "$MODE" != "reboot" ] && [ "$MODE" != "poweroff" ]; then + slxlog "idleaction-failed-call" "Invalid call to idleaction-scheduled_action. Mode '$MODE' unknown." + exit 1 +fi + +NUM=$(who | wc -l) +[ "$NUM" = "0" ] && $MODE # Easy way out - machine is idle + +# Someone logged in +for MINUTES in 5 X X X X X X X 3 X X X 2 X X X 1 X X X; do + NUM=$(who | wc -l) + [ "$NUM" = "0" ] && break + if [ "$MINUTES" != "X" ]; then + USERS=0 + if [ "$MODE" = "reboot" ]; then + MESSAGE="Das System wird in $MINUTES Minute(n) neugestartet, bitte beenden Sie Ihre Sitzung. +The system will reboot in $MINUTES minute(s). Please save your work and end the session." + else + MESSAGE="Dieser Rechner wird in $MINUTES Minute(n) abgeschaltet, bitte beenden Sie Ihre Sitzung. +The system will power off in $MINUTES minute(s). Please save your work and end the session." + fi + for d in $(who | awk '{print $2}' | sort -u); do + if [ "${d:0:1}" = ":" ]; then + # X11 + export DISPLAY=$d + export XAUTHORITY=$(ps a | grep " $DISPLAY " | grep -o -- '-auth.*$' | grep -m1 -v grep | awk '{print $2}') + # TODO: Don't look... We need to pick a proper util for this + /opt/openslx/cups/printergui --error "$MESSAGE" & + unset DISPLAY XAUTHORITY + USERS=$(( $USERS + 1 )) + elif [ "${d:0:3}" = "tty" ]; then + # Regular tty + cat > "/dev/$d" <<-EOF + * + *************************** + $MESSAGE + *************************** + * + EOF + USERS=$(( $USERS + 1 )) + elif [ "${d:0:3}" = "pts" ]; then + # pts - xterm or ssh session + cat > "/dev/pts/${d:3}" <<-EOF + * + *************************** + $MESSAGE + *************************** + * + EOF + USERS=$(( $USERS + 1 )) + fi + done + FILE=$(mktemp) + who > "$FILE" + slxlog "idleaction-busy" "Postponed $MODE ($MINUTES minutes max.) - $USERS user(s) still active" + sleep 1 + rm -- "$FILE" + fi + sleep 15 +done + +$MODE + diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_poweroff b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_poweroff deleted file mode 100755 index 5b5acda2..00000000 --- a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_poweroff +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/ash - -# TODO: Warn user, wait 5 minutes, etc... - -poweroff -nf - diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot deleted file mode 100755 index fa3adf65..00000000 --- a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/ash - -# TODO: Warn user, wait 5 minutes, etc... - -echo 'b' > /proc/sysrq-trigger - diff --git a/remote/modules/kdm-theme-bwlp/data/etc/kde4/kdm/kdmrc b/remote/modules/kdm-theme-bwlp/data/etc/kde4/kdm/kdmrc index 0b283d2a..e1f9f357 100644 --- a/remote/modules/kdm-theme-bwlp/data/etc/kde4/kdm/kdmrc +++ b/remote/modules/kdm-theme-bwlp/data/etc/kde4/kdm/kdmrc @@ -46,8 +46,8 @@ Startup=/etc/X11/Xstartup [Shutdown] AllowFifo=false -HaltCmd=/usr/bin/systemctl -ff poweroff -RebootCmd=/usr/bin/systemctl -ff reboot +HaltCmd=/usr/bin/systemctl poweroff +RebootCmd=/usr/bin/systemctl reboot [Xdmcp] Enable=false diff --git a/remote/modules/kdm/data/etc/kde4/kdm/kdmrc b/remote/modules/kdm/data/etc/kde4/kdm/kdmrc index f7e7be86..5f9f9e39 100644 --- a/remote/modules/kdm/data/etc/kde4/kdm/kdmrc +++ b/remote/modules/kdm/data/etc/kde4/kdm/kdmrc @@ -44,8 +44,8 @@ Startup=/etc/X11/Xstartup [Shutdown] AllowFifo=false -HaltCmd=/usr/bin/systemctl -ff poweroff -RebootCmd=/usr/bin/systemctl -ff reboot +HaltCmd=/usr/bin/systemctl poweroff +RebootCmd=/usr/bin/systemctl reboot [Xdmcp] Enable=false diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store index 4559e1e3..9d478918 100755 --- a/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store +++ b/remote/modules/run-virt/data/opt/openslx/scripts/systemd-mount_vm_store @@ -2,7 +2,7 @@ . /opt/openslx/config || exit 1 -[ -z "$SLX_VM_NFS" ] && slxlog "mount-vmstore-missing" "No SLX_VM_NFS given in /opt/openslx/config!" && exit 1 +[ -z "$SLX_VM_NFS" ] && exit 0 # create target directory mkdir -p /mnt/vmstore diff --git a/remote/modules/vmchooser2/data/opt/openslx/bin/vmchooser b/remote/modules/vmchooser2/data/opt/openslx/bin/vmchooser index 4f30f447..a99207ff 100755 --- a/remote/modules/vmchooser2/data/opt/openslx/bin/vmchooser +++ b/remote/modules/vmchooser2/data/opt/openslx/bin/vmchooser @@ -16,7 +16,7 @@ else fi MEM=$(grep -m1 '^MemTotal:' /proc/meminfo | awk '{print $2}') -if [ -n "$SLX_VMCHOOSER_TAB" ] && [ "$SLX_VMCHOOSER_TAB" -ge 0 -a "$SLX_VMCHOOSER_TAB" -le 2 ]; then +if [ -n "$SLX_VMCHOOSER_TAB" ] && [ "$SLX_VMCHOOSER_TAB" -ge 0 -a "$SLX_VMCHOOSER_TAB" -le 2 ] 2>/dev/null; then TAB="$SLX_VMCHOOSER_TAB" elif [ "$MEM" -lt 3000000 ]; then # Check RAM size; if it's not that much, default to the native linux sessions TAB=0 @@ -24,9 +24,13 @@ else TAB=2 fi -if [ -n "$SLX_VM_POOL_FILTER" ]; then - exec vmchooser.real "$@" --url "$URL" --pool "$SLX_VM_POOL_FILTER" --fullscreen --tab "$TAB" -else - exec vmchooser.real "$@" --url "$URL" --fullscreen --tab "$TAB" +EXTRA= +[ -n "$SLX_VMCHOOSER_TEMPLATES" ] && EXTRA="$EXTRA --template-mode $SLX_VMCHOOSER_TEMPLATES" +[ -n "$SLX_VMCHOOSER_FORLOCATION" ] && EXTRA="$EXTRA --location-mode $SLX_VMCHOOSER_FORLOCATION" + +if [ -z "$SLX_LOCATIONS" ]; then + exec vmchooser.real "$@" --url "$URL" --fullscreen --tab "$TAB" $EXTRA fi +exec vmchooser.real "$@" --url "$URL" --fullscreen --tab "$TAB" --locations "$SLX_LOCATIONS" $EXTRA + diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc index f8f43ad3..092abce5 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc @@ -99,11 +99,15 @@ HEREEND # Serial, parallel: Empty, nothing is being currently set. TODO later. -# Graphics, GPU: 3D will be activated if FORCE3D is set. -# Force3D is set in set_hardware.inc if SLX_VMWARE_3D is set in config. -if [ -n "$FORCE3D" ]; then +# Graphics, GPU: 3D will be enabled (even if vmware doesn't support the chip) if we whitelisted it. +if [ -n "$SLX_VMWARE_3D" ]; then writelog "FORCE3D set - overriding 3D in vmx file." echo 'mks.gl.allowBlacklistedDrivers = "TRUE"' >> "$TMPDIR/$IMGUUID" + # We override... play safe and cap the hwVersion to 10, since some i915 chips goofed up with 12 + # Investigate if we might have to do this in other cases where we don't override + if grep -qi '^mks.enable3d.*true' "$TMPDIR/$IMGUUID"; then + vmw_cap_hw_version "10" + fi else writelog "FORCE3D not set - 3D will only work if GPU/driver is whitelisted by vmware." fi diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware.inc b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware.inc deleted file mode 100644 index a94f5b26..00000000 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware.inc +++ /dev/null @@ -1,66 +0,0 @@ -######################################### -# Include: Hardware checks and settings # -######################################### - -# check for 3D configuration setting -case "$enable3d" in - true|yes) - enable3d="TRUE" - ;; - *) - enable3d="FALSE" - ;; -esac - -# set standard sound card, overwrite depending on OS (options sb16, es1371, hdaudio) -sound="es1371" - -# set sound card explicitly if there is more than one card in the host system -sound_fileName='sound.fileName = "-1" -sound.autodetect = "TRUE"' - -# check for whitelisted HW-3D -source /opt/openslx/config -FORCE3D="" -if [ -n "$SLX_VMWARE_3D" ]; then - FORCE3D='mks.gl.allowBlacklistedDrivers = "TRUE"' -fi - -# read only the first 30 lines to be sure -imghead=$(head -n 30 "${diskfile}") -hwver=$(echo "${imghead}" | grep -m1 -ia "ddb.virtualHWVersion" | awk -F '"' '{print $2}') - - -if [ -z "$override_hddtype" ]; then - hddrv=$(echo "${imghead}" | grep -m1 -ia "ddb.adapterType" | awk -F '"' '{print $2}') -else - hddrv=$override_hddtype -fi - -PCIE= -case "${hddrv}" in - ide) - ide="TRUE" - scsi="FALSE" - ;; - lsisas*) - ide="FALSE" - scsi="TRUE" - PCIE='pciBridge4.present = "TRUE" - pciBridge4.virtualDev = "pcieRootPort" - pciBridge4.functions = "8"' - ;; - lsilogic|buslogic) - ide="FALSE" - scsi="TRUE" - ;; - scsi) - ide="FALSE" - scsi="TRUE" - hddrv="lsilogic" - ;; - *) - slxlog "virt-vmware-hdd" "vmware: Unknown HDD adapter type $hddrv" - ;; -esac - diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware_legacy.inc b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware_legacy.inc index 899f5aea..22718839 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware_legacy.inc +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware_legacy.inc @@ -43,7 +43,6 @@ case "$enable3d" in esac # check for whitelisted HW-3D -source /opt/openslx/config FORCE3D="" if [ -n "$SLX_VMWARE_3D" ]; then FORCE3D='mks.gl.allowBlacklistedDrivers = "TRUE"' diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include index f63092bd..5c76a180 100644 --- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include +++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/run-virt.include @@ -22,43 +22,41 @@ VMWAREINCLUDEDIR=/opt/openslx/vmchooser/vmware/includes vmostype=$(rv_clean_string "$vmostype") +# declaration of default variables for vmware +source "${VMWAREINCLUDEDIR}/set_vmware_include_variables.inc" && set_vmware_include_variables +# General global openslx config +source /opt/openslx/config + +# TODO: Where to put global helper functions that could be used in several units below? +vmw_cap_hw_version() { + [ -z "$1" ] && writelog "cap_hw_version called without parameter!" && return 1 + [ "$1" -lt "$maxhardwareversion" ] && maxhardwareversion="$1" +} + if [ "$LEGACY" ]; then - # declaration of default variables for vmware - source "${VMWAREINCLUDEDIR}/set_vmware_include_variables.inc" && set_vmware_include_variables # hardware checks - # sources /opt/openslx/config to check for whitelisted HW-3D source "${VMWAREINCLUDEDIR}/set_hardware_legacy.inc" && set_hardware_legacy # write configuration files # write_config_files calls: # set_vmhome_preferences_header # set_vmware_startup_file source "${VMWAREINCLUDEDIR}/write_config_files_legacy.inc" && write_config_files_legacy - # logging and stdout - # needs writelog() from vmchooser-run_virt - source "${VMWAREINCLUDEDIR}/logging.inc" && logging else - # declaration of default variables for vmware - source "${VMWAREINCLUDEDIR}/set_vmware_include_variables.inc" && set_vmware_include_variables - - # hardware checks: sources /opt/openslx/config to check for whitelisted HW-3D - source "${VMWAREINCLUDEDIR}/set_hardware.inc" - # write configuration files source "${VMWAREINCLUDEDIR}/write_config_files.inc" # parse the given vmx file source "${VMWAREINCLUDEDIR}/parse_vmx.inc" +fi - # logging and stdout - # needs writelog() from vmchooser-run_virt - source "${VMWAREINCLUDEDIR}/logging.inc" && logging - -fi - -# $maxhardwareversion +# logging and stdout +# needs writelog() from vmchooser-run_virt +source "${VMWAREINCLUDEDIR}/logging.inc" && logging +# Apply $maxhardwareversion to final VMX HWVER=$(grep -i '^virtualHW.version *= *' "$conffile" | head -n 1 | awk -F '=' '{print $2}' | sed -r 's/[^0-9]//g') if [ -n "$HWVER" ] && [ "$HWVER" -gt "$maxhardwareversion" ]; then + writelog "Hardware version capped to $maxhardwareversion (was $HWVER)" sed -i 's/^virtualHW\.version.*$/virtualHW.version = "'$maxhardwareversion'"/I' "$conffile" fi |
