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
|
2012-07-22 01:21:43 +02:00
|
|
|
while ! [ -S /tmp/.X11-unix/X0 ]; do sleep 0.5; done
|
2013-03-14 04:30:22 +01:00
|
|
|
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
|
2012-11-16 14:03:36 +01:00
|
|
|
if [ -L /home ]; then
|
|
|
|
rm /home
|
|
|
|
mkdir /home
|
|
|
|
fi
|
|
|
|
mount --bind /home_volatile /home
|
2013-03-13 02:26:40 +01:00
|
|
|
touch /etc/this-is-dvm
|
2014-01-24 06:46:18 +01:00
|
|
|
systemctl --ignore-dependencies start qubes-gui-agent.service
|
|
|
|
while ! xenstore-read qubes-save-request 2>/dev/null ; do
|
|
|
|
usleep 10
|
|
|
|
done
|
2012-11-12 13:44:10 +01:00
|
|
|
mount /rw
|
|
|
|
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
|
|
|
|
|