2016-10-22 17:43:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Source Qubes library.
|
|
|
|
. /usr/lib/qubes/init/functions
|
2012-01-10 12:10:16 +01:00
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
# List of services enabled by default (in case of absence of qubesdb entry)
|
2015-01-29 01:10:34 +01:00
|
|
|
DEFAULT_ENABLED_NETVM="network-manager qubes-network qubes-update-check qubes-updates-proxy"
|
2016-09-12 05:31:02 +02:00
|
|
|
DEFAULT_ENABLED_PROXYVM="qubes-network qubes-firewall qubes-update-check"
|
2016-06-21 19:08:16 +02:00
|
|
|
DEFAULT_ENABLED_APPVM="cups qubes-update-check"
|
2014-09-27 01:52:19 +02:00
|
|
|
DEFAULT_ENABLED_TEMPLATEVM="$DEFAULT_ENABLED_APPVM updates-proxy-setup"
|
2016-06-21 19:08:16 +02:00
|
|
|
DEFAULT_ENABLED=""
|
|
|
|
|
2017-05-26 05:24:04 +02:00
|
|
|
# devices emulated by qemu, first list of vendor IDs then list of device IDs:
|
|
|
|
qemu_devices="0x8086
|
|
|
|
0x8086
|
|
|
|
0x8086
|
|
|
|
0x8086
|
|
|
|
0x8086
|
|
|
|
0x5853
|
|
|
|
0x1013
|
|
|
|
0x1237
|
|
|
|
0x7000
|
|
|
|
0x7010
|
|
|
|
0x7020
|
|
|
|
0x7113
|
|
|
|
0x0001
|
|
|
|
0x00b8
|
|
|
|
"
|
|
|
|
if [ -z "$(ls /sys/bus/pci/devices/)" -o \
|
|
|
|
"$(cat /sys/bus/pci/devices/*/{vendor,device})" != "$qemu_devices" ]; then
|
|
|
|
# do not enable meminfo-writer (so qmemman for this domain) when any real PCI
|
2016-06-21 19:08:16 +02:00
|
|
|
# device is present
|
|
|
|
DEFAULT_ENABLED="$DEFAULT_ENABLED meminfo-writer"
|
|
|
|
DEFAULT_ENABLED_APPVM="$DEFAULT_ENABLED_APPVM meminfo-writer"
|
|
|
|
DEFAULT_ENABLED_PROXYVM="$DEFAULT_ENABLED_PROXYVM meminfo-writer"
|
|
|
|
DEFAULT_ENABLED_TEMPLATEVM="$DEFAULT_ENABLED_TEMPLATEVM meminfo-writer"
|
|
|
|
fi
|
|
|
|
|
2012-01-10 12:10:16 +01:00
|
|
|
|
2016-10-22 17:43:16 +02:00
|
|
|
if systemd_version_changed ; then
|
2014-07-16 04:15:21 +02:00
|
|
|
# Ensure we're running right version of systemd (the one started by initrd may be different)
|
|
|
|
systemctl daemon-reexec
|
|
|
|
fi
|
2014-04-23 01:50:21 +02:00
|
|
|
|
2016-01-13 05:05:00 +01:00
|
|
|
# Wait for xenbus initialization
|
|
|
|
while [ ! -e /dev/xen/xenbus -a ! -e /proc/xen/xenbus ]; do
|
2012-01-30 14:22:58 +01:00
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
|
2012-01-10 12:10:16 +01:00
|
|
|
mkdir -p /var/run/qubes
|
2015-02-17 04:51:55 +01:00
|
|
|
chgrp qubes /var/run/qubes
|
|
|
|
chmod 0775 /var/run/qubes
|
2012-01-10 12:10:16 +01:00
|
|
|
mkdir -p /var/run/qubes-service
|
|
|
|
mkdir -p /var/run/xen-hotplug
|
|
|
|
|
2015-03-25 00:20:11 +01:00
|
|
|
# Set permissions to /proc/xen/xenbus, so normal user can talk to xenstore, to
|
|
|
|
# open vchan connection. Note that new code uses /dev/xen/xenbus (which have
|
|
|
|
# permissions set by udev), so this probably can go away soon
|
2012-01-10 12:10:16 +01:00
|
|
|
chmod 666 /proc/xen/xenbus
|
2014-09-26 19:56:12 +02:00
|
|
|
|
2015-02-07 12:26:51 +01:00
|
|
|
# Set permissions to /proc/xen/privcmd, so a user in qubes group can access
|
|
|
|
chmod 660 /proc/xen/privcmd
|
|
|
|
chgrp qubes /proc/xen/privcmd
|
|
|
|
|
2014-09-26 19:56:12 +02:00
|
|
|
[ -e /proc/u2mfn ] || modprobe u2mfn
|
2015-03-25 00:20:11 +01:00
|
|
|
# Set permissions to files needed by gui-agent
|
2012-11-22 00:51:18 +01:00
|
|
|
chmod 666 /proc/u2mfn
|
2012-01-10 12:10:16 +01:00
|
|
|
|
|
|
|
# Set default services depending on VM type
|
2016-10-22 17:43:16 +02:00
|
|
|
is_appvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM && touch /var/run/qubes/this-is-appvm
|
|
|
|
is_netvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM && touch /var/run/qubes/this-is-netvm
|
|
|
|
is_proxyvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM && touch /var/run/qubes/this-is-proxyvm
|
|
|
|
is_templatevm && DEFAULT_ENABLED=$DEFAULT_ENABLED_TEMPLATEVM && touch /var/run/qubes/this-is-templatevm
|
2012-01-10 12:10:16 +01:00
|
|
|
|
|
|
|
# Enable default services
|
|
|
|
for srv in $DEFAULT_ENABLED; do
|
|
|
|
touch /var/run/qubes-service/$srv
|
|
|
|
done
|
|
|
|
|
|
|
|
# Enable services
|
2016-10-22 17:43:16 +02:00
|
|
|
for srv in `qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 1'|cut -f 1 -d ' '`; do
|
2012-01-10 12:10:16 +01:00
|
|
|
touch /var/run/qubes-service/$srv
|
|
|
|
done
|
|
|
|
|
|
|
|
# Disable services
|
2016-10-22 17:43:16 +02:00
|
|
|
for srv in `qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 0'|cut -f 1 -d ' '`; do
|
2012-01-10 12:10:16 +01:00
|
|
|
rm -f /var/run/qubes-service/$srv
|
|
|
|
done
|
|
|
|
|
2012-05-22 16:49:03 +02:00
|
|
|
# Prepare environment for other services
|
|
|
|
echo > /var/run/qubes-service-environment
|
|
|
|
|
2016-10-22 17:43:16 +02:00
|
|
|
debug_mode=`qubesdb-read /qubes-debug-mode 2> /dev/null`
|
2012-05-22 16:49:03 +02:00
|
|
|
if [ -n "$debug_mode" -a "$debug_mode" -gt 0 ]; then
|
|
|
|
echo "GUI_OPTS=-vv" >> /var/run/qubes-service-environment
|
|
|
|
fi
|
2012-09-23 23:25:39 +02:00
|
|
|
|
2012-10-15 02:33:36 +02:00
|
|
|
exit 0
|