2015-04-15 18:52:42 +02:00
|
|
|
#!/bin/bash
|
2012-01-10 12:10:16 +01:00
|
|
|
|
|
|
|
possibly_run_save_script()
|
|
|
|
{
|
2013-06-07 05:20:55 +02:00
|
|
|
ENCODED_SCRIPT=$(qubesdb-read /qubes-save-script)
|
2012-01-10 12:10:16 +01:00
|
|
|
if [ -z "$ENCODED_SCRIPT" ] ; then return ; fi
|
2013-03-14 04:30:22 +01:00
|
|
|
echo $ENCODED_SCRIPT|perl -e 'use MIME::Base64 qw(decode_base64); local($/) = undef;print decode_base64(<STDIN>)' >/tmp/qubes-save-script
|
|
|
|
chmod 755 /tmp/qubes-save-script
|
|
|
|
DISPLAY=:0 su - user -c /tmp/qubes-save-script
|
2012-01-10 12:10:16 +01:00
|
|
|
}
|
|
|
|
|
2016-07-01 18:01:48 +02:00
|
|
|
echo user | /bin/sh /etc/qubes-rpc/qubes.WaitForSession
|
|
|
|
possibly_run_save_script
|
|
|
|
umount /rw
|
|
|
|
dmesg -c >/dev/null
|
|
|
|
qubesdb-watch /qubes-restore-complete &
|
|
|
|
watch_pid=$!
|
|
|
|
free | grep Mem: |
|
|
|
|
(read label total used free shared buffers cached; qubesdb-write /qubes-used-mem $(( $used + $cached )) )
|
|
|
|
# we're still running in DispVM template
|
|
|
|
echo "Waiting for save/restore..."
|
|
|
|
qubesdb-read /qubes-restore-complete || wait $watch_pid
|
|
|
|
echo Back to life.
|
2016-07-16 23:44:57 +02:00
|
|
|
systemctl restart systemd-random-seed.service
|