qubes-sysinit.sh 1.8 KB

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