qubes-sysinit.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # Wait for xenbus initialization
  12. while [ ! -e /dev/xen/xenbus ]; do
  13. sleep 0.1
  14. done
  15. mkdir -p /var/run/qubes
  16. chgrp qubes /var/run/qubes
  17. chmod 0775 /var/run/qubes
  18. mkdir -p /var/run/qubes-service
  19. mkdir -p /var/run/xen-hotplug
  20. # Set default services depending on VM type
  21. is_appvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_APPVM && touch /var/run/qubes/this-is-appvm
  22. is_netvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_NETVM && touch /var/run/qubes/this-is-netvm
  23. is_proxyvm && DEFAULT_ENABLED=$DEFAULT_ENABLED_PROXYVM && touch /var/run/qubes/this-is-proxyvm
  24. is_templatevm && DEFAULT_ENABLED=$DEFAULT_ENABLED_TEMPLATEVM && touch /var/run/qubes/this-is-templatevm
  25. # Enable default services
  26. for srv in $DEFAULT_ENABLED; do
  27. touch "/var/run/qubes-service/$srv"
  28. done
  29. # Enable services
  30. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 1'|cut -f 1 -d ' '); do
  31. touch "/var/run/qubes-service/$srv"
  32. done
  33. # Disable services
  34. for srv in $(qubesdb-multiread /qubes-service/ 2>/dev/null |grep ' = 0'|cut -f 1 -d ' '); do
  35. rm -f "/var/run/qubes-service/$srv"
  36. done
  37. # Prepare environment for other services
  38. echo > /var/run/qubes-service-environment
  39. exit 0