2015-02-05 03:14:41 +01:00
|
|
|
#!/bin/sh
|
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"
|
|
|
|
DEFAULT_ENABLED_PROXYVM="meminfo-writer qubes-network qubes-firewall qubes-netwatcher qubes-update-check"
|
|
|
|
DEFAULT_ENABLED_APPVM="meminfo-writer cups qubes-update-check"
|
2014-09-27 01:52:19 +02:00
|
|
|
DEFAULT_ENABLED_TEMPLATEVM="$DEFAULT_ENABLED_APPVM updates-proxy-setup"
|
2015-01-29 01:10:34 +01:00
|
|
|
DEFAULT_ENABLED="meminfo-writer"
|
2012-01-10 12:10:16 +01:00
|
|
|
|
2015-01-30 00:30:24 +01:00
|
|
|
QDB_READ=qubesdb-read
|
|
|
|
QDB_LS=qubesdb-multiread
|
2012-01-10 12:10:16 +01:00
|
|
|
|
|
|
|
read_service() {
|
2013-06-07 05:20:55 +02:00
|
|
|
$QDB_READ /qubes-service/$1 2> /dev/null
|
2012-01-10 12:10:16 +01:00
|
|
|
}
|
|
|
|
|
2014-07-16 04:15:21 +02:00
|
|
|
systemd_pkg_version=`systemctl --version|head -n 1`
|
|
|
|
if ! dmesg | grep -q "$systemd_pkg_version running in system mode."; then
|
|
|
|
# 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
|
|
|
|
2012-01-30 14:22:58 +01:00
|
|
|
# Wait for evtchn initialization
|
|
|
|
while [ ! -e /proc/xen/xenbus ]; do
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
|
2012-01-10 12:10:16 +01:00
|
|
|
mkdir -p /var/run/qubes
|
|
|
|
mkdir -p /var/run/qubes-service
|
|
|
|
mkdir -p /var/run/xen-hotplug
|
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
# Set permissions to /proc/xen/xenbus, so normal user can use qubesdb-read
|
2012-01-10 12:10:16 +01:00
|
|
|
chmod 666 /proc/xen/xenbus
|
2014-09-26 19:56:12 +02:00
|
|
|
|
|
|
|
[ -e /proc/u2mfn ] || modprobe u2mfn
|
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
|
2012-01-10 12:10:16 +01:00
|
|
|
|
|
|
|
# Set default services depending on VM type
|
2013-06-07 05:20:55 +02:00
|
|
|
TYPE=`$QDB_READ /qubes-vm-type 2> /dev/null`
|
2014-09-29 22:57:55 +02:00
|
|
|
[ "$TYPE" = "AppVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM
|
|
|
|
[ "$TYPE" = "NetVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM
|
|
|
|
[ "$TYPE" = "ProxyVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM
|
|
|
|
[ "$TYPE" = "TemplateVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_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
|
2013-06-10 04:35:51 +02:00
|
|
|
for srv in `$QDB_LS /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
|
2013-06-10 04:35:51 +02:00
|
|
|
for srv in `$QDB_LS /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
|
|
|
|
|
|
|
|
# Set the hostname
|
2013-06-07 05:20:55 +02:00
|
|
|
name=`$QDB_READ /name`
|
2012-01-10 12:10:16 +01:00
|
|
|
if [ -n "$name" ]; then
|
|
|
|
hostname $name
|
2014-09-29 05:03:25 +02:00
|
|
|
if [ -e /etc/debian_version ]; then
|
|
|
|
ipv4_localhost_re="127\.0\.1\.1"
|
|
|
|
else
|
|
|
|
ipv4_localhost_re="127\.0\.0\.1"
|
|
|
|
fi
|
|
|
|
sed -i "s/^\($ipv4_localhost_re\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
|
|
|
|
sed -i "s/^\(::1\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
|
2012-01-10 12:10:16 +01:00
|
|
|
fi
|
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
timezone=`$QDB_READ /qubes-timezone 2> /dev/null`
|
2012-01-18 16:59:58 +01:00
|
|
|
if [ -n "$timezone" ]; then
|
2014-09-26 19:56:12 +02:00
|
|
|
cp -p /usr/share/zoneinfo/$timezone /etc/localtime
|
|
|
|
if [ -e /etc/debian_version ]; then
|
|
|
|
echo "$timezone" > /etc/timezone
|
|
|
|
else
|
|
|
|
echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
|
|
|
|
echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
|
|
|
|
fi
|
2012-01-18 16:59:58 +01:00
|
|
|
fi
|
2012-05-22 16:49:03 +02:00
|
|
|
|
|
|
|
# Prepare environment for other services
|
|
|
|
echo > /var/run/qubes-service-environment
|
|
|
|
|
2013-06-07 05:20:55 +02:00
|
|
|
debug_mode=`$QDB_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
|