[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#567468: please set hostname via sysctl early on



Package: initramfs-tools
Version: 0.93.4
Severity: wishlist

mdadm in incremental mode needs the hostname to be able to work
without a configuration file, which would make RAID-boot much more
robust. Instead of mdadm touching
/proc/sys/kernel/{host,domain}name, it feels like initramfs should
do that.

The attached scripts take care of it. hostname is the hook, and
00hostname the script for init-top. It might make more sense to put
this into local-top though, I don't really know how it interacts
with netboot.

-- 
 .''`.   martin f. krafft <madduck@d.o>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
#!/bin/sh
#
# initramfs script to inform the kernel about the hostname early on
#
# Copyright © 2010 martin f. krafft <madduck@debian.org>
# Released under the terms of the Artistic Licence 2.0
#
set -eu

case "${1:-}" in prereqs) exit 0;; esac

if [ -s /conf/hostname ]; then
  . /scripts/functions

  HOSTNAME="$(cat /conf/hostname)"
  log_begin_msg "Setting hostname to $HOSTNAME"

  case "$HOSTNAME" in
    *.*)
      echo "${HOSTNAME#*.}" >/proc/sys/kernel/domainname
      HOSTNAME="${HOSTNAME%%.*}"
      ;;
  esac
  echo "$HOSTNAME" >/proc/sys/kernel/hostname

  log_end_msg
fi

exit
#!/bin/sh
#
# initramfs hook to store the hostname in the initrd
#
# Copyright © 2010 martin f. krafft <madduck@debian.org>
# Released under the terms of the Artistic Licence 2.0
#
set -eu

exec hostname --fqdn > $DESTDIR/conf/hostname

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)


Reply to: