qubes-sysinit.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ]; 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 default services depending on VM type
  25. is_appvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM && touch /var/run/qubes/this-is-appvm
  26. is_netvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM && touch /var/run/qubes/this-is-netvm
  27. is_proxyvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM && touch /var/run/qubes/this-is-proxyvm
  28. is_templatevm && DEFAULT_ENABLED=$DEFAULT_ENABLED_TEMPLATEVM && touch /var/run/qubes/this-is-templatevm
  29. # Enable default services
  30. for srv in $DEFAULT_ENABLED; do
  31. touch "/var/run/qubes-service/$srv"
  32. done
  33. # Enable services
  34. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 1'|cut -f 1 -d ' '); do
  35. touch "/var/run/qubes-service/$srv"
  36. done
  37. # Disable services
  38. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 0'|cut -f 1 -d ' '); do
  39. rm -f "/var/run/qubes-service/$srv"
  40. done
  41. # Prepare environment for other services
  42. echo > /var/run/qubes-service-environment
  43. exit 0