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
|
|
|
}
|
|
|
|
|
2014-01-24 06:46:18 +01:00
|
|
|
if true; then
|
2015-03-04 02:08:22 +01:00
|
|
|
echo user | /bin/sh /etc/qubes-rpc/qubes.WaitForSession
|
2012-11-12 13:44:10 +01:00
|
|
|
possibly_run_save_script
|
|
|
|
umount /rw
|
2012-01-10 12:10:16 +01:00
|
|
|
dmesg -c >/dev/null
|
2015-03-04 02:10:28 +01:00
|
|
|
qubesdb-watch /qubes-restore-complete &
|
|
|
|
watch_pid=$!
|
2015-10-15 04:34:55 +02:00
|
|
|
free | grep Mem: |
|
2015-04-15 18:52:42 +02:00
|
|
|
(read label total used free shared buffers cached; qubesdb-write /qubes-used-mem $(( $used + $cached )) )
|
2012-01-10 12:10:16 +01:00
|
|
|
# we're still running in DispVM template
|
|
|
|
echo "Waiting for save/restore..."
|
2015-03-04 02:10:28 +01:00
|
|
|
qubesdb-read /qubes-restore-complete || wait $watch_pid
|
2012-01-10 12:10:16 +01:00
|
|
|
echo Back to life.
|
2016-07-01 18:01:47 +02:00
|
|
|
systemctl restart qubes-random-seed.service
|
2012-01-10 12:10:16 +01:00
|
|
|
fi
|
|
|
|
|