2010-04-05 20:58:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# chkconfig: 345 90 90
|
|
|
|
# description: Executes Qubes core scripts at VM boot
|
|
|
|
#
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
start()
|
|
|
|
{
|
|
|
|
echo -n $"Executing Qubes Core scripts:"
|
|
|
|
|
|
|
|
if ! [ -x /usr/bin/xenstore-read ] ; then
|
|
|
|
echo "ERROR: /usr/bin/xenstore-read not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-07-02 13:14:57 +02:00
|
|
|
# Set permissions to /proc/xen/xenbus, so normal user can use xenstore-read
|
|
|
|
chmod 666 /proc/xen/xenbus
|
2012-11-03 01:57:36 +01:00
|
|
|
# Set permissions to files needed to listen at vchan
|
2012-11-22 00:51:18 +01:00
|
|
|
chmod 666 /proc/u2mfn
|
2011-04-07 18:43:52 +02:00
|
|
|
|
2011-12-27 17:34:36 +01:00
|
|
|
mkdir -p /var/run/xen-hotplug
|
|
|
|
|
2010-04-05 20:58:57 +02:00
|
|
|
name=$(/usr/bin/xenstore-read name)
|
2010-07-30 16:01:15 +02:00
|
|
|
if ! [ -f /etc/this_is_dvm ] ; then
|
|
|
|
# we don't want to set hostname for DispVM
|
|
|
|
# because it makes some of the pre-created dotfiles invalid (e.g. .kde/cache-<hostname>)
|
|
|
|
# (let's be frank: nobody's gonna use xterm on DispVM)
|
|
|
|
hostname $name
|
2012-05-08 23:34:01 +02:00
|
|
|
sed -i "s/^\(127\.0\.0\.1 .*\) \($name \)\?\(.*\)/\1\2 $name/" /etc/hosts
|
2010-07-30 16:01:15 +02:00
|
|
|
fi
|
2010-04-05 20:58:57 +02:00
|
|
|
|
2012-01-18 16:59:58 +01:00
|
|
|
timezone=`/usr/bin/xenstore-read qubes-timezone 2> /dev/null`
|
|
|
|
if [ -n "$timezone" ]; then
|
|
|
|
ln -f /usr/share/zoneinfo/$timezone /etc/localtime
|
|
|
|
echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
|
|
|
|
echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
|
|
|
|
fi
|
|
|
|
|
2012-05-31 02:37:53 +02:00
|
|
|
yum_proxy_setup=$(/usr/bin/xenstore-read qubes-service/yum-proxy-setup 2> /dev/null)
|
2012-06-05 19:38:37 +02:00
|
|
|
type=$(/usr/bin/xenstore-read qubes_vm_type)
|
|
|
|
if [ "$yum_proxy_setup" != "0" ] || [ -z "$yum_proxy_setup" -a "$type" == "TemplateVM" ]; then
|
2012-05-31 02:37:53 +02:00
|
|
|
echo proxy=http://10.137.255.254:8082/ > /etc/yum.conf.d/qubes-proxy.conf
|
|
|
|
else
|
|
|
|
echo > /etc/yum.conf.d/qubes-proxy.conf
|
|
|
|
fi
|
|
|
|
|
2011-07-13 20:16:04 +02:00
|
|
|
# Set IP address again (besides action in udev rules); this is needed by
|
|
|
|
# DispVM (to override DispVM-template IP) and in case when qubes_ip was
|
|
|
|
# called by udev before loading evtchn kernel module - in which case
|
|
|
|
# xenstore-read fails
|
|
|
|
INTERFACE=eth0 /usr/lib/qubes/setup_ip
|
|
|
|
|
2011-09-27 01:37:09 +02:00
|
|
|
mkdir -p /var/run/qubes
|
|
|
|
|
2010-06-02 15:50:22 +02:00
|
|
|
if [ -e /dev/xvdb ] ; then
|
|
|
|
mount /rw
|
2010-06-18 16:21:04 +02:00
|
|
|
|
2010-06-02 15:50:22 +02:00
|
|
|
if ! [ -d /rw/home ] ; then
|
|
|
|
echo
|
|
|
|
echo "--> Virgin boot of the VM: Linking /home to /rw/home"
|
2010-10-04 19:36:54 +02:00
|
|
|
|
2010-06-02 15:50:22 +02:00
|
|
|
mkdir -p /rw/config
|
2010-10-04 19:36:54 +02:00
|
|
|
touch /rw/config/rc.local
|
|
|
|
|
2010-06-02 15:50:22 +02:00
|
|
|
mkdir -p /rw/home
|
2012-11-16 14:03:36 +01:00
|
|
|
cp -a /home.orig/user /rw/home
|
2010-06-02 15:50:22 +02:00
|
|
|
|
2010-10-04 19:36:54 +02:00
|
|
|
mkdir -p /rw/usrlocal
|
2012-11-16 14:03:36 +01:00
|
|
|
cp -a /usr/local.orig/* /rw/usrlocal
|
2010-10-04 19:36:54 +02:00
|
|
|
|
|
|
|
touch /var/lib/qubes/first_boot_completed
|
2010-06-02 15:50:22 +02:00
|
|
|
fi
|
2010-04-05 20:58:57 +02:00
|
|
|
fi
|
2012-11-16 14:03:36 +01:00
|
|
|
if [ -L /home ]; then
|
|
|
|
rm /home
|
|
|
|
mkdir /home
|
|
|
|
fi
|
|
|
|
mount /home
|
2010-04-05 20:58:57 +02:00
|
|
|
|
|
|
|
[ -x /rw/config/rc.local ] && /rw/config/rc.local
|
2011-03-31 15:15:10 +02:00
|
|
|
|
2010-04-05 20:58:57 +02:00
|
|
|
success
|
|
|
|
echo ""
|
2011-06-26 18:57:46 +02:00
|
|
|
|
2011-10-01 02:49:25 +02:00
|
|
|
start_ntpd=$(/usr/bin/xenstore-read qubes-service/ntpd 2> /dev/null)
|
|
|
|
if [ "$start_ntpd" == "1" ]; then
|
2011-06-26 18:57:46 +02:00
|
|
|
/sbin/service ntpd start
|
|
|
|
fi
|
2010-04-05 20:58:57 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
2012-02-06 15:29:36 +01:00
|
|
|
su -c 'mkdir -p /home_volatile/user/.local/share/applications' user
|
2012-02-06 19:07:13 +01:00
|
|
|
su -c 'cp -a /usr/share/applications/defaults.list /home_volatile/user/.local/share/applications/' user
|
|
|
|
if [ -r '/home/user/.local/share/applications/defaults.list' ]; then
|
|
|
|
su -c 'cat /home/user/.local/share/applications/defaults.list >> /home_volatile/user/.local/share/applications/defaults.list' user
|
|
|
|
fi
|
2010-04-05 20:58:57 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop}"
|
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|