qubes-sysinit.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. # List of services enabled by default (in case of absence of xenstore entry)
  3. DEFAULT_ENABLED_NETVM="network-manager qubes-network"
  4. DEFAULT_ENABLED_PROXYVM="meminfo-writer qubes-network qubes-firewall qubes-netwatcher"
  5. DEFAULT_ENABLED_APPVM="meminfo-writer cups"
  6. DEFAULT_ENABLED_TEMPLATEVM=$DEFAULT_ENABLED_APPVM
  7. DEFAULT_ENABLED="meminfo-writer"
  8. XS_READ=/usr/bin/xenstore-read
  9. XS_LS=/usr/bin/xenstore-ls
  10. read_service() {
  11. $XS_READ qubes-service/$1 2> /dev/null
  12. }
  13. # Wait for evtchn initialization
  14. while [ ! -e /proc/xen/xenbus ]; do
  15. sleep 0.1
  16. done
  17. mkdir -p /var/run/qubes
  18. mkdir -p /var/run/qubes-service
  19. mkdir -p /var/run/xen-hotplug
  20. # Set permissions to /proc/xen/xenbus, so normal user can use xenstore-read
  21. chmod 666 /proc/xen/xenbus
  22. # Set default services depending on VM type
  23. TYPE=`$XS_READ qubes_vm_type 2> /dev/null`
  24. [ "$TYPE" == "AppVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM
  25. [ "$TYPE" == "NetVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM
  26. [ "$TYPE" == "ProxyVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM
  27. [ "$TYPE" == "TemplateVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_TEMPLATEVM
  28. # Enable default services
  29. for srv in $DEFAULT_ENABLED; do
  30. touch /var/run/qubes-service/$srv
  31. done
  32. # Enable services
  33. for srv in `$XS_LS qubes-service 2>/dev/null |grep ' = "1"'|cut -f 1 -d ' '`; do
  34. touch /var/run/qubes-service/$srv
  35. done
  36. # Disable services
  37. for srv in `$XS_LS qubes-service 2>/dev/null |grep ' = "0"'|cut -f 1 -d ' '`; do
  38. rm -f /var/run/qubes-service/$srv
  39. done
  40. # Set the hostname
  41. name=`$XS_READ name`
  42. if [ -n "$name" ]; then
  43. hostname $name
  44. (grep -v "\<$name\>" /etc/hosts; echo "127.0.0.1 $name") > /etc/hosts
  45. fi
  46. timezone=`$XS_READ qubes-timezone 2> /dev/null`
  47. if [ -n "$timezone" ]; then
  48. ln -f /usr/share/zoneinfo/$timezone /etc/localtime
  49. echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
  50. echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
  51. fi