setup-rw.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 include 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 in AppVMs after every firewall update (configuration
  32. # change, starting some VM etc). This is good place to write own custom
  33. # firewall rules, in addition to autogenerated ones. Remember that in most cases
  34. # you'll need to insert the rules at the beginning (iptables -I) for it to be
  35. # efective.
  36. EOF
  37. chmod 755 /rw/config/qubes-firewall-user-script
  38. touch /rw/config/suspend-module-blacklist
  39. cat > /rw/config/suspend-module-blacklist <<EOF
  40. # You can list modules here that you want to be unloaded before going to sleep. This
  41. # file is used only if the VM has any PCI device assigned. Modules will be
  42. # automatically re-loaded after resume.
  43. EOF
  44. fi
  45. if ! [ -d /rw/usrlocal ] ; then
  46. if [ -d /usr/local.orig ] ; then
  47. echo "Virgin boot of the VM: populating /rw/usrlocal from /usr/local.orig" >&2
  48. cp -af /usr/local.orig /rw/usrlocal
  49. else
  50. echo "Virgin boot of the VM: creating /rw/usrlocal" >&2
  51. mkdir -p /rw/usrlocal
  52. fi
  53. fi
  54. echo "Finished checking /rw" >&2
  55. fi
  56. # Old Qubes versions had symlink /home -> /rw/home; now we use mount --bind
  57. if [ -L /home ]; then
  58. rm /home
  59. mkdir /home
  60. fi
  61. if [ ! -e /var/lib/qubes/first-boot-completed ]; then
  62. touch /var/lib/qubes/first-boot-completed
  63. fi