2010-04-05 20:58:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: 2345 99 00
|
|
|
|
# description: Executes Qubes core scripts at Dom0 boot
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: qubes-core
|
|
|
|
# Required-Start: xend
|
|
|
|
# Default-Start: 3 4 5
|
|
|
|
# Default-Stop: 0 1 2 6
|
|
|
|
# Default-Enabled: yes
|
|
|
|
# Short-Description: Start/stop qubes-core services
|
|
|
|
# Description: Starts and stops the qubes-core serives
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
2010-07-13 04:32:42 +02:00
|
|
|
setup_dvm_files()
|
|
|
|
{
|
|
|
|
ROOT=/var/lib/qubes/dvmdata/savefile_root
|
|
|
|
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
|
|
|
|
if ! [ -f $DEFAULT ] ; then return ; fi
|
|
|
|
if ! [ -f $ROOT ] ; then return ; fi
|
|
|
|
if [ $ROOT -nt $DEFAULT ] ; then
|
|
|
|
echo DVM require reconfiguration
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
|
|
|
|
ln -s $DEFAULT /var/run/qubes/current_savefile
|
|
|
|
else
|
|
|
|
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-04-05 20:58:57 +02:00
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
echo -n $"Executing Qubes Core scripts:"
|
|
|
|
chgrp qubes /etc/xen
|
|
|
|
chmod 710 /etc/xen
|
|
|
|
chgrp qubes /var/run/xend
|
|
|
|
chmod 710 /var/run/xend
|
|
|
|
chgrp qubes /var/run/xend/xen-api.sock /var/run/xend/xmlrpc.sock
|
|
|
|
chmod 660 /var/run/xend/xen-api.sock /var/run/xend/xmlrpc.sock
|
|
|
|
chgrp qubes /var/run/xenstored/*
|
|
|
|
chmod 660 /var/run/xenstored/*
|
|
|
|
xm sched-credit -d 0 -w 65535
|
2010-06-02 15:50:22 +02:00
|
|
|
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM_seq
|
2010-06-30 15:23:44 +02:00
|
|
|
chown root:qubes /var/run/qubes/dispVM_seq
|
|
|
|
chmod 660 /var/run/qubes/dispVM_seq
|
2010-07-30 16:00:18 +02:00
|
|
|
xm mem-set 0 1600
|
2010-04-05 20:58:57 +02:00
|
|
|
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml
|
2010-07-13 04:32:42 +02:00
|
|
|
setup_dvm_files
|
2010-08-30 11:40:19 +02:00
|
|
|
/usr/lib/qubes/qmemman_daemon.py >/var/log/qubes/qmemman.log 2>/var/log/qubes/qmemman.errs &
|
2010-09-09 17:51:53 +02:00
|
|
|
|
|
|
|
MEM_CHANGE_THRESHOLD_KB=30000
|
|
|
|
MEMINFO_DELAY_USEC=100000
|
|
|
|
/usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC &
|
|
|
|
|
2010-04-05 20:58:57 +02:00
|
|
|
touch /var/lock/subsys/qubes_core
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
echo -n $"Shutting down all Qubes VMs:"
|
|
|
|
NETVM=$(qvm-get-default-netvm)
|
|
|
|
qvm-run -q --shutdown --all --wait --exclude $NETVM
|
|
|
|
rm -f /var/lock/subsys/qubes_core
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop}"
|
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|