Revision 43c9dece

b/create
129 129
      ROOT_DEV=$root_dev
130 130
      BOOT_DEV=$boot_dev
131 131
      IMG_PASSWD=$IMG_PASSWD
132
      export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMAGE_TYPE IMG_PASSWD
132
      HOSTNAME=$instance
133
      export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMAGE_TYPE IMG_PASSWD HOSTNAME
133 134
      $RUN_PARTS $CUSTOMIZE_DIR
134 135
    fi
135 136
fi
b/example/hooks/hostname
1
#!/bin/bash
2

  
3
set -e 
4
. common.sh
5

  
6
debug set -x
7

  
8
CLEANUP=( )
9

  
10
trap cleanup EXIT
11

  
12
if [ -z "${HOSTNAME}" ] ; then
13
    log_error "Missing hostname"
14
    exit 1
15
fi
16

  
17
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
18
    log_error "Missing target directory"
19
    exit 1
20
fi
21

  
22
get_os_type $TARGET
23

  
24
case "${OS_TYPE}" in
25
    debian)
26
        echo $HOSTNAME > ${TARGET}/etc/hostname
27
        ;;
28
    redhat)
29
        sed -ie "s/HOSTNAME=.*$/HOSTNAME=$HOSTNAME/g" ${TARGET}/etc/sysconfig/network
30

  
31
        ;;
32
    slackware|suse)
33
        #local domain=$(sed -e 's/^[^\.]*//g' < /etc/HOSTNAME)
34
        
35
        # In slackware hostname and domain name are joined together. For now I
36
        # will not retain the domain name.
37
        
38
        echo $HOSTNAME > ${TARGET}/etc/HOSTNAME
39
        ;;
40
    gentoo)
41
        sed -ie "s/\(\(HOSTNAME\)\|\(hostname\)\)=.*$/\1=\"${instance}\"/" ${TARGET}/etc/conf.d/hostname
42
        ;;
43
esac
44

  
45
# execute cleanups
46
cleanup
47
trap - EXIT
48

  
49
exit 0

Also available in: Unified diff