setup-rw.sh 2.1 KB

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