2012-01-10 12:10:16 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
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
|
|
|
|
free | grep Mem: |
|
2013-06-07 05:20:55 +02:00
|
|
|
(read a b c d ; qubesdb-write /qubes-used-mem $c)
|
2013-06-10 04:37:20 +02:00
|
|
|
# give dom0 time to read some entries, when done it will shutdown qubesdb,
|
|
|
|
# so wait for it
|
|
|
|
qubesdb-watch /stop-qubesdb
|
|
|
|
# just to make sure
|
|
|
|
systemctl stop qubes-db.service
|
|
|
|
|
2012-01-10 12:10:16 +01:00
|
|
|
# we're still running in DispVM template
|
|
|
|
echo "Waiting for save/restore..."
|
2013-06-10 04:37:20 +02:00
|
|
|
# the service will start only after successful restore
|
|
|
|
systemctl start qubes-db.service
|
2012-01-10 12:10:16 +01:00
|
|
|
echo Back to life.
|
|
|
|
fi
|
|
|
|
|