qubes-core 3.1 KB

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