qubes-early-vm-config.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # This is invoked by qubes-early-vm-config.service.
  3. # It happens after local-fs.target is reached
  4. # but before sysinit.target is reached.
  5. # Source Qubes library.
  6. . /usr/lib/qubes/init/functions
  7. # Set the hostname
  8. if ! is_protected_file /etc/hostname ; then
  9. name=`qubesdb-read /name`
  10. if [ -n "$name" ]; then
  11. hostname $name
  12. if [ -e /etc/debian_version ]; then
  13. ipv4_localhost_re="127\.0\.1\.1"
  14. else
  15. ipv4_localhost_re="127\.0\.0\.1"
  16. fi
  17. sed -i "s/^\($ipv4_localhost_re\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
  18. sed -i "s/^\(::1\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
  19. fi
  20. fi
  21. # Set the timezone
  22. if ! is_protected_file /etc/timezone ; then
  23. timezone=`qubesdb-read /qubes-timezone 2> /dev/null`
  24. if [ -n "$timezone" ]; then
  25. ln -sf ../usr/share/zoneinfo/"$timezone" /etc/localtime
  26. if [ -e /etc/debian_version ]; then
  27. echo "$timezone" > /etc/timezone
  28. elif test -d /etc/sysconfig ; then
  29. echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
  30. echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
  31. fi
  32. fi
  33. fi