qubes-early-vm-config.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. # shellcheck source=init/functions
  7. . /usr/lib/qubes/init/functions
  8. # Set the hostname
  9. if ! is_protected_file /etc/hostname ; then
  10. name=$(qubesdb-read /name)
  11. if [ -n "$name" ]; then
  12. hostname "$name"
  13. if [ -e /etc/debian_version ]; then
  14. ipv4_localhost_re="127\.0\.1\.1"
  15. else
  16. ipv4_localhost_re="127\.0\.0\.1"
  17. fi
  18. sed -i "s/^\($ipv4_localhost_re\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
  19. sed -i "s/^\(::1\(\s.*\)*\s\).*$/\1${name}/" /etc/hosts
  20. fi
  21. fi
  22. # Set the timezone
  23. if ! is_protected_file /etc/timezone ; then
  24. timezone=$(qubesdb-read /qubes-timezone 2> /dev/null)
  25. if [ -n "$timezone" ]; then
  26. ln -sf ../usr/share/zoneinfo/"$timezone" /etc/localtime
  27. if [ -e /etc/debian_version ]; then
  28. echo "$timezone" > /etc/timezone
  29. elif test -d /etc/sysconfig ; then
  30. echo "# Clock configuration autogenerated based on Qubes dom0 settings" > /etc/sysconfig/clock
  31. echo "ZONE=\"$timezone\"" >> /etc/sysconfig/clock
  32. fi
  33. fi
  34. fi