2010-09-21 21:46:11 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: 2345 99 00
|
|
|
|
# description: Sets up DVM savefile at Dom0 boot
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: qubes-dvm
|
|
|
|
# Required-Start: qubes-networking
|
|
|
|
# Default-Start: 3 4 5
|
|
|
|
# Default-Stop: 0 1 2 6
|
|
|
|
# Default-Enabled: yes
|
|
|
|
# Short-Description: Sets up DVM savefile at Dom0 boot
|
|
|
|
# Description: Sets up DVM savefile at Dom0 boot
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
echo -n "Setting up DVM savefile at Dom0 boot:"
|
|
|
|
|
|
|
|
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM_seq
|
|
|
|
chown root:qubes /var/run/qubes/dispVM_seq
|
|
|
|
chmod 660 /var/run/qubes/dispVM_seq
|
|
|
|
ROOT=/var/lib/qubes/dvmdata/savefile_root
|
|
|
|
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
|
|
|
|
create_neeed=0
|
|
|
|
if ! [ -f $DEFAULT ] ; then create_neeed=1 ; fi
|
|
|
|
if ! [ -f $ROOT ] ; then create_neeed=1 ; fi
|
|
|
|
if [ $ROOT -nt $DEFAULT ] ; then create_neeed=1 ; fi
|
|
|
|
if [ $create_neeed = 1 ] ; then
|
2011-03-23 21:19:16 +01:00
|
|
|
MSG="Creating default DVM. This may take up to 2 minutes..."
|
|
|
|
echo " $MSG"
|
|
|
|
if [ -x /usr/bin/plymouth ]; then
|
|
|
|
/usr/bin/plymouth message --text="$MSG"
|
|
|
|
/usr/bin/plymouth pause-progress
|
|
|
|
fi
|
2011-03-23 18:44:58 +01:00
|
|
|
qvm-create-default-dvm --default-template --default-script
|
2011-03-23 18:45:35 +01:00
|
|
|
DVMDIR="/var/lib/qubes/appvms/`qvm-get-default-template`-dvm"
|
|
|
|
/bin/chown -R root.qubes "$DVMDIR"
|
|
|
|
/bin/chmod -R ug=rwX,o=rX "$DVMDIR"
|
2011-03-23 21:19:16 +01:00
|
|
|
if [ -x /usr/bin/plymouth ]; then
|
|
|
|
/usr/bin/plymouth message --text=""
|
|
|
|
/usr/bin/plymouth unpause-progress
|
|
|
|
fi
|
|
|
|
success
|
2010-09-21 21:46:11 +02:00
|
|
|
return
|
2011-03-23 18:44:58 +01:00
|
|
|
fi
|
2010-09-21 21:46:11 +02:00
|
|
|
if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
|
|
|
|
ln -s $DEFAULT /var/run/qubes/current_savefile
|
|
|
|
else
|
2011-03-23 18:44:58 +01:00
|
|
|
mkdir -m 770 /dev/shm/qubes
|
|
|
|
chown root.qubes /dev/shm/qubes
|
|
|
|
cp $DEFAULT /dev/shm/qubes/current_savefile
|
|
|
|
chown root.qubes /dev/shm/qubes/current_savefile
|
|
|
|
chmod 660 /dev/shm/qubes/current_savefile
|
|
|
|
ln -s /dev/shm/qubes/current_savefile /var/run/qubes/current_savefile
|
|
|
|
fi
|
2010-09-21 21:46:11 +02:00
|
|
|
|
2010-09-22 10:24:57 +02:00
|
|
|
touch /var/lock/subsys/qubes_setupdvm
|
2010-09-21 21:46:11 +02:00
|
|
|
success
|
|
|
|
echo
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
rm -f /var/lock/subsys/qubes_netvm
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2011-03-23 18:44:58 +01:00
|
|
|
start
|
|
|
|
;;
|
2010-09-21 21:46:11 +02:00
|
|
|
stop)
|
2011-03-23 18:44:58 +01:00
|
|
|
stop
|
|
|
|
;;
|
2010-09-21 21:46:11 +02:00
|
|
|
*)
|
2011-03-23 18:44:58 +01:00
|
|
|
echo $"Usage: $0 {start|stop}"
|
|
|
|
exit 3
|
|
|
|
;;
|
2010-09-21 21:46:11 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|