qubes-core 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. #
  3. # chkconfig: 345 90 90
  4. # description: Executes Qubes core scripts at VM boot
  5. #
  6. # Source function library.
  7. . /etc/rc.d/init.d/functions
  8. start()
  9. {
  10. echo -n $"Executing Qubes Core scripts:"
  11. # Set permissions to /proc/xen/xenbus, so normal user can use qubesdb-read
  12. chmod 666 /proc/xen/xenbus
  13. # Set permissions to files needed to listen at vchan
  14. chmod 666 /proc/u2mfn
  15. mkdir -p /var/run/xen-hotplug
  16. name=$(/usr/bin/qubesdb-read /name)
  17. if ! [ -f /etc/this-is-dvm ] ; then
  18. # we don't want to set hostname for DispVM
  19. # because it makes some of the pre-created dotfiles invalid (e.g. .kde/cache-<hostname>)
  20. # (let's be frank: nobody's gonna use xterm on DispVM)
  21. hostname $name
  22. sed -i "s/^\(127\.0\.0\.1[\t ].*\) \($name \)\?\(.*\)/\1\2 $name/" /etc/hosts
  23. fi
  24. timezone=`/usr/bin/qubesdb-read /qubes-timezone 2> /dev/null`
  25. if [ -n "$timezone" ]; then
  26. ln -f /usr/share/zoneinfo/$timezone /etc/localtime
  27. echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
  28. echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
  29. fi
  30. yum_proxy_setup=$(/usr/bin/qubesdb-read /qubes-service/yum-proxy-setup 2> /dev/null || /usr/bin/qubesdb-read /qubes-service/updates-proxy-setup 2> /dev/null)
  31. type=$(/usr/bin/qubesdb-read /qubes-vm-type)
  32. if [ "$yum_proxy_setup" != "0" ] || [ -z "$yum_proxy_setup" -a "$type" == "TemplateVM" ]; then
  33. echo proxy=http://10.137.255.254:8082/ > /etc/yum.conf.d/qubes-proxy.conf
  34. else
  35. echo > /etc/yum.conf.d/qubes-proxy.conf
  36. fi
  37. # Set IP address again (besides action in udev rules); this is needed by
  38. # DispVM (to override DispVM-template IP) and in case when qubes-ip was
  39. # called by udev before loading evtchn kernel module - in which case
  40. # qubesdb-read fails
  41. INTERFACE=eth0 /usr/lib/qubes/setup-ip
  42. mkdir -p /var/run/qubes
  43. if [ -e /dev/xvdb ] ; then
  44. resize2fs /dev/xvdb 2> /dev/null || echo "'resize2fs /dev/xvdb' failed"
  45. mount /rw
  46. if ! [ -d /rw/home ] ; then
  47. echo
  48. echo "--> Virgin boot of the VM: Linking /home to /rw/home"
  49. mkdir -p /rw/config
  50. touch /rw/config/rc.local
  51. mkdir -p /rw/home
  52. cp -a /home.orig/user /rw/home
  53. mkdir -p /rw/usrlocal
  54. cp -a /usr/local.orig/* /rw/usrlocal
  55. touch /var/lib/qubes/first-boot-completed
  56. fi
  57. fi
  58. if [ -L /home ]; then
  59. rm /home
  60. mkdir /home
  61. fi
  62. mount /home
  63. [ -x /rw/config/rc.local ] && /rw/config/rc.local
  64. success
  65. echo ""
  66. start_ntpd=$(/usr/bin/qubesdb-read /qubes-service/ntpd 2> /dev/null)
  67. if [ "$start_ntpd" == "1" ]; then
  68. /sbin/service ntpd start
  69. fi
  70. return 0
  71. }
  72. stop()
  73. {
  74. su -c 'mkdir -p /home_volatile/user/.local/share/applications' user
  75. su -c 'cp -a /usr/share/applications/defaults.list /home_volatile/user/.local/share/applications/' user
  76. if [ -r '/home/user/.local/share/applications/defaults.list' ]; then
  77. su -c 'cat /home/user/.local/share/applications/defaults.list >> /home_volatile/user/.local/share/applications/defaults.list' user
  78. fi
  79. return 0
  80. }
  81. case "$1" in
  82. start)
  83. start
  84. ;;
  85. stop)
  86. stop
  87. ;;
  88. *)
  89. echo $"Usage: $0 {start|stop}"
  90. exit 3
  91. ;;
  92. esac
  93. exit $RETVAL