setup-rw.sh 2.4 KB

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