qubes-sysinit.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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"
  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. mkdir -p /var/run/qubes
  13. mkdir -p /var/run/qubes-service
  14. mkdir -p /var/run/xen-hotplug
  15. # Set permissions to /proc/xen/xenbus, so normal user can use xenstore-read
  16. chmod 666 /proc/xen/xenbus
  17. # Set default services depending on VM type
  18. TYPE=`$XS_READ qubes_vm_type 2> /dev/null`
  19. [ "$TYPE" == "AppVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM
  20. [ "$TYPE" == "NetVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM
  21. [ "$TYPE" == "ProxyVM" ] && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM
  22. # Enable default services
  23. for srv in $DEFAULT_ENABLED; do
  24. touch /var/run/qubes-service/$srv
  25. done
  26. # Enable services
  27. for srv in `$XS_LS qubes-service 2>/dev/null |grep ' = "1"'|cut -f 1 -d ' '`; do
  28. touch /var/run/qubes-service/$srv
  29. done
  30. # Disable services
  31. for srv in `$XS_LS qubes-service 2>/dev/null |grep ' = "0"'|cut -f 1 -d ' '`; do
  32. rm -f /var/run/qubes-service/$srv
  33. done
  34. # Set the hostname
  35. name=`$XS_READ name`
  36. if [ -n "$name" ]; then
  37. hostname $name
  38. (grep -v "\<$name\>" /etc/hosts; echo "127.0.0.1 $name") > /etc/hosts
  39. fi