qubes-sysinit.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # Source Qubes library.
  3. # shellcheck source=init/functions
  4. . /usr/lib/qubes/init/functions
  5. # List of services enabled by default (in case of absence of qubesdb entry)
  6. DEFAULT_ENABLED_NETVM="network-manager qubes-network qubes-update-check qubes-updates-proxy meminfo-writer qubes-firewall"
  7. DEFAULT_ENABLED_PROXYVM="qubes-network qubes-firewall qubes-update-check meminfo-writer"
  8. DEFAULT_ENABLED_APPVM="cups qubes-update-check meminfo-writer"
  9. DEFAULT_ENABLED_TEMPLATEVM="$DEFAULT_ENABLED_APPVM updates-proxy-setup"
  10. DEFAULT_ENABLED="meminfo-writer"
  11. if systemd_version_changed ; then
  12. # Ensure we're running right version of systemd (the one started by initrd may be different)
  13. systemctl daemon-reexec
  14. fi
  15. # Wait for xenbus initialization
  16. while [ ! -e /dev/xen/xenbus ] && [ -e /proc/xen/xenbus ]; do
  17. sleep 0.1
  18. done
  19. mkdir -p /var/run/qubes
  20. chgrp qubes /var/run/qubes
  21. chmod 0775 /var/run/qubes
  22. mkdir -p /var/run/qubes-service
  23. mkdir -p /var/run/xen-hotplug
  24. # Set permissions to /proc/xen/xenbus, so normal user can talk to xenstore, to
  25. # open vchan connection. Note that new code uses /dev/xen/xenbus (which have
  26. # permissions set by udev), so this probably can go away soon
  27. chmod 666 /proc/xen/xenbus
  28. # Set permissions to /proc/xen/privcmd, so a user in qubes group can access
  29. chmod 660 /proc/xen/privcmd
  30. chgrp qubes /proc/xen/privcmd
  31. # Set default services depending on VM type
  32. is_appvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM && touch /var/run/qubes/this-is-appvm
  33. is_netvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM && touch /var/run/qubes/this-is-netvm
  34. is_proxyvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM && touch /var/run/qubes/this-is-proxyvm
  35. is_templatevm && DEFAULT_ENABLED=$DEFAULT_ENABLED_TEMPLATEVM && touch /var/run/qubes/this-is-templatevm
  36. # Enable default services
  37. for srv in $DEFAULT_ENABLED; do
  38. touch "/var/run/qubes-service/$srv"
  39. done
  40. # Enable services
  41. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 1'|cut -f 1 -d ' '); do
  42. touch "/var/run/qubes-service/$srv"
  43. done
  44. # Disable services
  45. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 0'|cut -f 1 -d ' '); do
  46. rm -f "/var/run/qubes-service/$srv"
  47. done
  48. # Prepare environment for other services
  49. echo > /var/run/qubes-service-environment
  50. exit 0