qubes-core-agent.preinst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. # preinst script for core-agent-linux
  3. #
  4. # see: dh_installdeb(1)
  5. set -e
  6. # The preinst script may be called in the following ways:
  7. # * <new-preinst> 'install'
  8. # * <new-preinst> 'install' <old-version>
  9. # * <new-preinst> 'upgrade' <old-version>
  10. #
  11. # The package will not yet be unpacked, so the preinst script cannot rely
  12. # on any files included in its package. Only essential packages and
  13. # pre-dependencies (Pre-Depends) may be assumed to be available.
  14. # Pre-dependencies will have been configured at least once, but at the time the
  15. # preinst is called they may only be in an "Unpacked" or "Half-Configured" state
  16. # if a previous version of the pre-dependency was completely configured and has
  17. # not been removed since then.
  18. #
  19. #
  20. # * <old-preinst> 'abort-upgrade' <new-version>
  21. #
  22. # Called during error handling of an upgrade that failed after unpacking the
  23. # new package because the postrm upgrade action failed. The unpacked files may
  24. # be partly from the new version or partly missing, so the script cannot rely
  25. # on files included in the package. Package dependencies may not be available.
  26. # Pre-dependencies will be at least "Unpacked" following the same rules as
  27. # above, except they may be only "Half-Installed" if an upgrade of the
  28. # pre-dependency failed.[46]
  29. #
  30. # For details, see http://www.debian.org/doc/debian-policy/ or
  31. # https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html or
  32. # the debian-policy package
  33. if [ "$1" = "install" ] ; then
  34. # --------------------------------------------------------------------------
  35. # Create required directories
  36. # --------------------------------------------------------------------------
  37. mkdir -p /var/lib/qubes
  38. mkdir -p /lib/modules
  39. #mkdir -p -m 0700 /var/log/xen # xen-utils-common should do this
  40. if [ -e /etc/fstab ] ; then
  41. mv /etc/fstab /var/lib/qubes/fstab.orig
  42. fi
  43. # --------------------------------------------------------------------------
  44. # Many Qubes scripts reference /bin/sh expecting the shell to be bash but
  45. # in Debian it is dash so some scripts will fail so force an alternate for
  46. # /bin/sh to be /bin/bash
  47. # --------------------------------------------------------------------------
  48. update-alternatives --force --install /bin/sh sh /bin/bash 999
  49. # --------------------------------------------------------------------------
  50. # Modules setup
  51. # --------------------------------------------------------------------------
  52. echo "xen_netfront" >> /etc/modules
  53. # --------------------------------------------------------------------------
  54. # Remove `mesg` from root/.profile?
  55. # --------------------------------------------------------------------------
  56. sed -i -e '/^mesg n/d' /root/.profile
  57. # --------------------------------------------------------------------------
  58. # Update /etc/fstab
  59. # --------------------------------------------------------------------------
  60. cat > /etc/fstab <<EOF
  61. /dev/mapper/dmroot / ext4 defaults,noatime 1 1
  62. /dev/xvdc1 swap swap defaults 0 0
  63. /dev/xvdb /rw ext4 noauto,defaults,discard 1 2
  64. /rw/home /home none noauto,bind,defaults 0 0
  65. tmpfs /dev/shm tmpfs defaults 0 0
  66. devpts /dev/pts devpts gid=5,mode=620 0 0
  67. proc /proc proc defaults 0 0
  68. sysfs /sys sysfs defaults 0 0
  69. xen /proc/xen xenfs defaults 0 0
  70. /dev/xvdi /mnt/removable auto noauto,user,rw 0 0
  71. /dev/xvdd /lib/modules ext3 defaults 0 0
  72. EOF
  73. # --------------------------------------------------------------------------
  74. # User add / modifications
  75. # --------------------------------------------------------------------------
  76. id -u 'user' || {
  77. groupadd -f user
  78. useradd -g user -G dialout,cdrom,floppy,sudo,audio,dip,video,plugdev -m -s /bin/bash user
  79. }
  80. id -u 'tinyproxy' || {
  81. groupadd -f tinyproxy
  82. useradd -g tinyproxy -M --home /run/tinyproxy --shell /bin/false tinyproxy
  83. }
  84. usermod -p '' root
  85. usermod -L user
  86. exit 0
  87. fi
  88. if [ "$1" = "upgrade" ] ; then
  89. exit 0
  90. fi
  91. # dh_installdeb will replace this with shell code automatically
  92. # generated by other debhelper scripts.
  93. #DEBHELPER#
  94. exit 0
  95. # vim: set ts=4 sw=4 sts=4 et :