core-agent-linux/vm-init.d/qubes-core

114 lines
3.1 KiB
Plaintext
Raw Normal View History

2015-02-05 03:14:41 +01:00
#!/bin/bash
#
# 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:"
2013-06-07 05:20:55 +02:00
# Set permissions to /proc/xen/xenbus, so normal user can use qubesdb-read
2011-07-02 13:14:57 +02:00
chmod 666 /proc/xen/xenbus
# Set permissions to files needed to listen at vchan
chmod 666 /proc/u2mfn
mkdir -p /var/run/xen-hotplug
2013-06-07 05:20:55 +02:00
name=$(/usr/bin/qubesdb-read /name)
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
2014-10-27 22:39:25 +01:00
sed -i "s/^\(127\.0\.0\.1[\t ].*\) \($name \)\?\(.*\)/\1\2 $name/" /etc/hosts
fi
2013-06-07 05:20:55 +02:00
timezone=`/usr/bin/qubesdb-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
2013-06-07 05:20:55 +02:00
yum_proxy_setup=$(/usr/bin/qubesdb-read /qubes-service/yum-proxy-setup 2> /dev/null || /usr/bin/qubesdb-read /qubes-service/updates-proxy-setup 2> /dev/null)
type=$(/usr/bin/qubesdb-read /qubes-vm-type)
if [ "$yum_proxy_setup" != "0" ] || [ -z "$yum_proxy_setup" -a "$type" == "TemplateVM" ]; then
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
2011-07-13 20:16:04 +02:00
# called by udev before loading evtchn kernel module - in which case
2013-06-07 05:20:55 +02:00
# qubesdb-read fails
INTERFACE=eth0 /usr/lib/qubes/setup-ip
2011-07-13 20:16:04 +02:00
mkdir -p /var/run/qubes
2010-06-02 15:50:22 +02:00
if [ -e /dev/xvdb ] ; then
resize2fs /dev/xvdb 2> /dev/null || echo "'resize2fs /dev/xvdb' failed"
2010-06-02 15:50:22 +02:00
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-06-02 15:50:22 +02:00
mkdir -p /rw/config
touch /rw/config/rc.local
2010-06-02 15:50:22 +02:00
mkdir -p /rw/home
cp -a /home.orig/user /rw/home
2010-06-02 15:50:22 +02:00
mkdir -p /rw/usrlocal
cp -a /usr/local.orig/* /rw/usrlocal
touch /var/lib/qubes/first-boot-completed
2010-06-02 15:50:22 +02:00
fi
fi
if [ -L /home ]; then
rm /home
mkdir /home
fi
mount /home
[ -x /rw/config/rc.local ] && /rw/config/rc.local
success
echo ""
2013-06-07 05:20:55 +02:00
start_ntpd=$(/usr/bin/qubesdb-read /qubes-service/ntpd 2> /dev/null)
if [ "$start_ntpd" == "1" ]; then
/sbin/service ntpd start
fi
return 0
}
stop()
{
su -c 'mkdir -p /home_volatile/user/.local/share/applications' user
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
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 3
;;
esac
exit $RETVAL