prepare-dvm.sh 856 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. possibly_run_save_script()
  3. {
  4. ENCODED_SCRIPT=$(qubesdb-read /qubes-save-script)
  5. if [ -z "$ENCODED_SCRIPT" ] ; then return ; fi
  6. echo $ENCODED_SCRIPT|perl -e 'use MIME::Base64 qw(decode_base64); local($/) = undef;print decode_base64(<STDIN>)' >/tmp/qubes-save-script
  7. chmod 755 /tmp/qubes-save-script
  8. DISPLAY=:0 su - user -c /tmp/qubes-save-script
  9. }
  10. echo user | /bin/sh /etc/qubes-rpc/qubes.WaitForSession
  11. possibly_run_save_script
  12. umount /rw
  13. dmesg -c >/dev/null
  14. qubesdb-watch /qubes-restore-complete &
  15. watch_pid=$!
  16. free | grep Mem: |
  17. (read label total used free shared buffers cached; qubesdb-write /qubes-used-mem $(( $used + $cached )) )
  18. # we're still running in DispVM template
  19. echo "Waiting for save/restore..."
  20. qubesdb-read /qubes-restore-complete || wait $watch_pid
  21. echo Back to life.
  22. systemctl restart systemd-random-seed.service