summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc')
-rw-r--r--core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc68
1 files changed, 68 insertions, 0 deletions
diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc
new file mode 100644
index 00000000..eb9030fa
--- /dev/null
+++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/includes/create-rw-diskimage.inc
@@ -0,0 +1,68 @@
+# -----------------------------------------------------------------------------
+#
+# Copyright (c) 2009..2021 bwLehrpool-Projektteam
+#
+# This program/file is free software distributed under the GPL version 2.
+# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
+#
+# If you have any feedback please consult https://bwlehrpool.de and
+# send your feedback to support@bwlehrpool.de.
+#
+# General information about bwLehrpool can be found at https://bwlehrpool.de
+#
+# -----------------------------------------------------------------------------
+# Utils and functions to parse Linux kernel command line options
+# -----------------------------------------------------------------------------
+
+#
+# Return :
+function create_rw_diskimage() {
+ # writelog "Creating rw image for qemu to safe and upload the snapshot later"
+
+ # Register upload function to trigger before the cleanup deletes the tmp image snapshot
+ add_cleanup upload_qemu_rw
+
+ # If the edit checkbox is checked the environment variable VMCHOOSER_ADMIN_MODE is TRUE
+ # ALLOW_EDIT=${VMCHOOSER_ADMIN_MODE}
+}
+
+# Helper to safe and upload the image before the cleanup deletes everything
+upload_qemu_rw() {
+
+ # writelog "Calling scp task trigger on SAT"
+ # SERVERIP=$SLX_PXE_SERVER_IP
+ # Call slx-admin api to trigger taskmanager ScpSnapshot task with all the info needed
+ # LECTUREID=$IMGUUID
+ # CLIENTIP=$SLX_PXE_CLIENT_IP
+ # curl "http://$SERVERIP/slx-admin/api.php?do=remoteaccess&action=scp&lectureid=$LECTUREID&clientip=$CLIENTIP"
+ # Image will be deleted by SAT via SSH after finished downloading
+
+
+ # LECTUREID=$IMGUUID
+ # CLIENTIP=$SLX_PXE_CLIENT_IP
+ SERVERIP=$SLX_PXE_SERVER_IP
+ SESSIONID=$(cat /var/lib/lightdm/editsession.id)
+
+ # Open firefox where the user can either safe or cancel
+ # Prepare firefox to not start the privacy "first launch" Page
+ firefox --CreateProfile progress
+ FFPROFILE=$(realpath ~/.mozilla/firefox/*.progress)
+ echo 'user_pref("toolkit.telemetry.reportingpolicy.firstRun", false);' >> $FFPROFILE/user.js
+
+ # Start firefox and wait for the process
+ firefox --kiosk http://$SERVERIP:5000/progress/$SESSIONID -P progress &
+ FFPID="$!"
+ writelog "FF PID IS: $FFPID"
+ writelog "Waiting for firefox to exit"
+ wait $!
+ writelog "Firefox exited"
+
+ # At this point the snapshot was either downloaded by the sat or the edit session was cancelled and can be deleted
+ rm -rf /tmp/upload
+
+ # No permission to delete this file
+ # rm -f /var/lib/lightdm/editsession.id
+ # Remove the /var/lib/lightdm/edit.desktop that the slxgreeter created for autostart-editmode-login
+ # rm /var/lib/lightdm/edit.desktop
+}
+