setup-rw.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. dev=/dev/xvdb
  3. if mountpoint -q /rw ; then
  4. # This means /rw is mounted now.
  5. echo "Checking /rw" >&2
  6. echo "Private device size management: enlarging $dev" >&2
  7. if content=$(resize2fs "$dev" 2>&1) ; then
  8. echo "Private device size management: resize2fs of $dev succeeded" >&2
  9. else
  10. echo "Private device size management: resize2fs $dev failed:" >&2
  11. echo "$content" >&2
  12. fi
  13. if ! [ -d /rw/config ] ; then
  14. echo "Virgin boot of the VM: populating /rw/config" >&2
  15. mkdir -p /rw/config
  16. touch /rw/config/rc.local
  17. cat > /rw/config/rc.local <<EOF
  18. #!/bin/sh
  19. # This script will be executed at every VM startup, you can place your own
  20. # custom commands here. This includes overriding some configuration in /etc,
  21. # starting services etc.
  22. # Example for overriding the whole CUPS configuration:
  23. # rm -rf /etc/cups
  24. # ln -s /rw/config/cups /etc/cups
  25. # systemctl --no-block restart cups
  26. EOF
  27. chmod 755 /rw/config/rc.local
  28. touch /rw/config/qubes-firewall-user-script
  29. cat > /rw/config/qubes-firewall-user-script <<EOF
  30. #!/bin/sh
  31. # This script is called at AppVM boot if this AppVM has the qubes-firewall
  32. # service enabled. It is executed after the empty chains for the Qubes firewall
  33. # are created, but before rules for attached qubes are processed and inserted.
  34. #
  35. # It is a good place for custom rules and actions that should occur when the
  36. # firewall service is started.
  37. #
  38. # Executable scripts located in /rw/config/qubes-firewall.d are executed
  39. # immediately before this qubes-firewall-user-script.
  40. EOF
  41. chmod 755 /rw/config/qubes-firewall-user-script
  42. touch /rw/config/suspend-module-blacklist
  43. cat > /rw/config/suspend-module-blacklist <<EOF
  44. # You can list modules here that you want to be unloaded before going to sleep. This
  45. # file is used only if the VM has any PCI device assigned. Modules will be
  46. # automatically re-loaded after resume.
  47. EOF
  48. fi
  49. if ! [ -d /rw/usrlocal ] ; then
  50. if [ -d /usr/local.orig ] ; then
  51. echo "Virgin boot of the VM: populating /rw/usrlocal from /usr/local.orig" >&2
  52. cp -af /usr/local.orig /rw/usrlocal
  53. else
  54. echo "Virgin boot of the VM: creating /rw/usrlocal" >&2
  55. mkdir -p /rw/usrlocal
  56. fi
  57. fi
  58. echo "Finished checking /rw" >&2
  59. fi
  60. # Old Qubes versions had symlink /home -> /rw/home; now we use mount --bind
  61. if [ -L /home ]; then
  62. rm /home
  63. mkdir /home
  64. fi
  65. if [ ! -e /var/lib/qubes/first-boot-completed ]; then
  66. touch /var/lib/qubes/first-boot-completed
  67. fi