0d529146b9a80bb025461a0d733da59f2ee070fe
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 05-hostname
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/05-hostname
3 # Purpose:       set hostname of live-system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -u
10 set -e
11
12 . "$GRML_LIVE_CONFIG"
13
14 # the hostname of the chroot usually isn't the same as the one for the live-system
15 BUILD_HOSTNAME="$($ROOTCMD hostname)"
16 [ -n "$BUILD_HOSTNAME" ] || BUILD_HOSTNAME="grml"
17
18 echo "$HOSTNAME" > $target/etc/hostname
19 echo "$HOSTNAME" > $target/etc/mailname
20
21 if [ -r $target/etc/postfix/main.cf ] ; then
22   sed -i "s/^mydestination = .*/mydestination = $HOSTNAME, localhost, localhost.localdomain/" $target/etc/postfix/main.cf
23   sed -i "s/^myhostname = .*/myhostname = $HOSTNAME/" $target/etc/postfix/main.cf
24   echo "postfix postfix/mailname     string $HOSTNAME" | $ROOTCMD debconf-set-selections
25   echo "postfix postfix/destinations string ${HOSTNAME}, localhost.grml.org, localhost" \
26   | $ROOTCMD debconf-set-selections
27   # make sure to execute newaliases after adjusting configuration,
28   # otherwise the old hostname will be left inside /etc/aliases.db
29   $ROOTCMD newaliases
30 fi
31
32 if [ -r $target/etc/bacula/bacula-fd.conf ] ; then
33   sed -i "s/$BUILD_HOSTNAME/$HOSTNAME/g" $target/etc/bacula/bacula-fd.conf
34 fi
35
36 ## END OF FILE #################################################################
37 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2