Revision bb78ba49

b/Makefile.am
1 1
osdir=$(OS_DIR)/$(OS_NAME)
2
customdir=${sysconfdir}/ganeti/instance-image/hooks
2
linuxcustomdir=${sysconfdir}/ganeti/instance-image/hooks/linux
3 3
configdir=${sysconfdir}/ganeti/instance-image
4 4
variantsdir=${sysconfdir}/ganeti/instance-image/variants
5 5
networksdir=${sysconfdir}/ganeti/instance-image/networks
......
12 12
dist_config_DATA = variants.list
13 13
os_DATA = common.sh
14 14

  
15
dist_custom_DATA = example/hooks/*
15
dist_linuxcustom_DATA = example/hooks/linux/*
16 16

  
17 17
dist_doc_DATA = COPYING NEWS README
18 18

  
b/common_linux.sh
58 58
    fi
59 59
}
60 60

  
61
format_disk0() {
61
linux_format_disk0() {
62 62
    local sfdisk_cmd="$SFDISK -uM -H 255 -S 63 --quiet --Linux --DOS $1"
63 63
    if [  "${SWAP}" = "yes" -a -z "${KERNEL_PATH}" ] ; then
64 64
        # Create three partitions:
......
95 95
    fi
96 96
}
97 97

  
98
mkfs_disk0() {
98
linux_mkfs_disk0() {
99 99
    local mkfs="mkfs.${FILESYSTEM}"
100 100
    # Format /
101 101
    $mkfs -Fq -L / $root_dev > /dev/null
......
114 114
    sleep 2
115 115
}
116 116

  
117
setup_fstab() {
117
linux_setup_fstab() {
118 118
    local target=$1 fs=${FILESYSTEM}
119 119
    get_os_type $target
120 120
    cat > $target/etc/fstab <<EOF
......
153 153
fi
154 154
}
155 155

  
156
setup_console() {
156
linux_setup_console() {
157 157
    local target=$1
158 158
    if [ -z "$target" ] ; then
159 159
        log_error "target not set for setup_console"
......
193 193
    esac
194 194
}
195 195

  
196
filesystem_check() {
196
linux_filesystem_check() {
197 197
    local target=$1
198 198
    if [ -z "$target" ] ; then
199 199
        log_error "target not set for filesystem_check"
b/create
53 53
    # volumes, filesystems, etc
54 54
    if [ "${IMAGE_TYPE}" = "tarball" -o "${IMAGE_TYPE}" = "dump" ] ; then
55 55
        # Create 3 partitions, /boot, swap, & /
56
        format_disk0 $blockdev
56
        ${OS_FAMILY}_format_disk0 $blockdev
57 57
    elif [ "${IMAGE_TYPE}" = "qemu" ] ; then
58 58
        # need a recent version of qemu for this
59 59
        ${QEMU_IMG} convert ${IMAGE_FILE} -O host_device ${blockdev} > /dev/null
......
72 72
    swap_dev=$(map_partition $filesystem_dev swap)
73 73

  
74 74
    if [ "${IMAGE_TYPE}" = "tarball" -o "${IMAGE_TYPE}" = "dump" ] ; then
75
        mkfs_disk0
75
        ${OS_FAMILY}_mkfs_disk0
76 76
        root_uuid="$($VOL_ID $root_dev)"
77 77
        [ -n "$boot_dev" ] && sleep 1 && boot_uuid="$($VOL_ID $boot_dev)"
78 78
        [ -n "$swap_dev" ] && sleep 1 && swap_uuid="$($VOL_ID $swap_dev)"
......
102 102
    fi
103 103

  
104 104
    if [ "${IMAGE_TYPE}" = "tarball" -o "${IMAGE_TYPE}" = "dump" ] ; then
105
        setup_fstab $TARGET
105
        ${OS_FAMILY}_setup_fstab $TARGET
106 106
    fi
107 107

  
108 108
    if [ "${INSTANCE_HV_serial_console}" = "True" ] ; then
109
        setup_console $TARGET
109
        ${OS_FAMILY}_setup_console $TARGET
110 110
    fi
111 111

  
112
    filesystem_check $TARGET
112
    ${OS_FAMILY}_filesystem_check $TARGET
113 113

  
114 114
    RUN_PARTS=`which run-parts`
115 115

  
116
    if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "$CUSTOMIZE_DIR" ]; then
116
    if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "${CUSTOMIZE_DIR}/$OS_FAMILY" ]; then
117 117
      TARGET=$TARGET
118 118
      BLOCKDEV=$blockdev
119 119
      ROOT_DEV=$root_dev
120 120
      BOOT_DEV=$boot_dev
121 121
      IMG_PASSWD=$IMG_PASSWD
122 122
      export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMAGE_TYPE IMG_PASSWD
123
      $RUN_PARTS $CUSTOMIZE_DIR
123
      $RUN_PARTS $CUSTOMIZE_DIR/$OS_FAMILY
124 124
    fi
125 125
fi
126 126

  
/dev/null
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures, grub after installation. This
21
# script assumes that grub has been installed onto the image already and a
22
# working grub.conf exists. This is only enabled if using the tarball image
23
# type. 
24

  
25
set -e
26

  
27
. common.sh
28

  
29
debug set -x
30

  
31
CLEANUP=( )
32

  
33
trap cleanup EXIT
34

  
35
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
36
    log_error "Missing target directory"
37
    exit 1
38
fi
39

  
40
# Set disk based on type of hypervisor
41
disk=""
42
if [ "${HYPERVISOR}" = "kvm" ] ; then
43
  disk="vda"
44
else
45
  disk="xda"
46
fi
47

  
48
boot_dir="${TARGET}/boot/grub"
49

  
50
setup_disk_devs() {
51
    root_part="${ROOT_DEV/*-/}"
52
    boot_part="${BOOT_DEV/*-/}"
53

  
54
    mknod ${TARGET}/dev/${disk} b $(stat -L -c "0x%t 0x%T" $BLOCKDEV)
55
    CLEANUP+=("rm -f ${TARGET}/dev/$disk")
56

  
57
    mknod ${TARGET}/dev/${disk}${root_part} b $(stat -L -c "0x%t 0x%T" $ROOT_DEV)
58
    CLEANUP+=("rm -f ${TARGET}/dev/${disk}${root_part}")
59

  
60
    if [ -n "$BOOT_DEV" ] ; then
61
        mknod ${TARGET}/dev/${disk}${boot_part} b $(stat -L -c "0x%t 0x%T" $BOOT_DEV)
62
        CLEANUP+=("rm -f ${TARGET}/dev/${disk}${boot_part}")
63
    fi
64

  
65
    # setup minimal proc environment for grub2
66
    $MKDIR_P ${TARGET}/proc/
67
    cat > ${TARGET}/proc/mounts <<EOF
68
/dev/${disk}${boot_part} /boot ${FILESYSTEM} rw,relatime,barrier=1,data=ordered 0 0
69
/dev/${disk}${root_part} / ${FILESYSTEM} rw,relatime,barrier=1,data=ordered 0 0
70
EOF
71
    CLEANUP+=("rm -r ${TARGET}/proc/mounts")
72

  
73
    cat > ${TARGET}/proc/devices <<EOF
74
Block devices:
75
251 virtblk
76
252 device-mapper
77
EOF
78
    CLEANUP+=("rm -r ${TARGET}/proc/devices")
79
    cat > ${TARGET}/proc/misc << EOF
80
 60 device-mapper
81
EOF
82
    CLEANUP+=("rm -r ${TARGET}/proc/misc")
83
}
84

  
85
add_devicemap() {
86
    cat > "${TARGET}/boot/grub/device.map" <<EOF
87
(hd0) /dev/${disk}
88
EOF
89
}
90

  
91
if [ "${IMAGE_TYPE}" != "qemu" ] && \
92
   [ -z "${INSTANCE_HV_kernel_path}" -o "${IMPORT_SCRIPT}" = "1" ] ; then
93
    setup_disk_devs
94
    add_devicemap
95

  
96
    if [ -e "${boot_dir}/menu.lst" ] ; then
97
        # install grub to the block device
98
        chroot ${TARGET} grub --batch --no-floppy \
99
            --device-map=/boot/grub/device.map > /dev/null <<EOF
100
root (hd0,0)
101
setup (hd0)
102
quit
103
EOF
104
        # check to see if grub is using UUID's and replace if so
105
        if [ -n "$(grep 'root=UUID' ${boot_dir}/menu.lst)" ] ; then
106
            root_uuid="$($VOL_ID $ROOT_DEV)"
107
            sed --follow-symlinks -ie "s/\(root=UUID=\)\([a-z0-9-]*\)/\1${root_uuid}/g" \
108
                ${boot_dir}/menu.lst
109
        fi
110
        # additional kernel arguments for the instance
111
        if [ -n "${KERNEL_ARGS}" ] ; then
112
            sed --follow-symlinks -ie "s/\(.*kernel.*\)/\1 ${KERNEL_ARGS}/g" \
113
                ${boot_dir}/menu.lst
114
        fi
115
    elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then
116
        echo "grub2 support is partially supported"
117
        echo "please run update-grub after the instance is online"
118
        # check to see if grub is using UUID's and replace if so
119
        if [ -n "$(grep 'root=UUID' ${boot_dir}/grub.cfg)" ] ; then
120
            root_uuid="$($VOL_ID $ROOT_DEV)"
121
            sed --follow-symlinks -ie "s/\(root=UUID=\)\([a-z0-9-]*\)/\1${root_uuid}/g" \
122
                ${boot_dir}/grub.cfg
123
        fi
124
        # additional kernel arguments for the instance
125
        if [ -n "${KERNEL_ARGS}" ] ; then
126
            sed -ie "s/.*GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 ${KERNEL_ARGS}\"/" \
127
                ${TARGET}/etc/default/grub
128
        fi
129
        # show the menu countdown in case we want to boot to a different kernel
130
        sed -ie 's/.*GRUB_HIDDEN_TIMEOUT=.*/GRUB_HIDDEN_TIMEOUT=5/' ${TARGET}/etc/default/grub
131
        sed -ie 's/.*GRUB_HIDDEN_TIMEOUT_QUIET=.*/GRUB_HIDDEN_TIMEOUT_QUIET=false/' ${TARGET}/etc/default/grub
132
        # install grub2 MBR
133
        chroot ${TARGET} grub-setup --force --device-map=/boot/grub/device.map \
134
            --directory=/boot/grub --root-device="(hd0,1)" "(hd0)" > /dev/null
135
    fi
136
fi
137

  
138
# setup serial console
139
if [ "${INSTANCE_HV_serial_console}" = "True" ] ; then
140
    if [ ! -e ${TARGET}/dev/${disk} ] ; then
141
        setup_disk_devs
142
    fi
143
    if [ -e "${boot_dir}/menu.lst" ] ; then
144
        # grub 0.x
145
        sed --follow-symlinks -ie 's/^default.*/default 0\n\nserial --unit=0\nterminal --timeout=3 console serial/' \
146
            ${boot_dir}/menu.lst
147
        sed --follow-symlinks -ie 's/\(.*kernel.*\)/\1 console=ttyS0,115200n8/g' \
148
            ${boot_dir}/menu.lst
149
    elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then
150
        # grub 2.x
151
        add_devicemap
152
        sed -ie 's/.*GRUB_TERMINAL.*/GRUB_TERMINAL=serial/' ${TARGET}/etc/default/grub
153
        sed -ie 's/.*GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 console=ttyS0,115200n8\"/' \
154
            ${TARGET}/etc/default/grub
155
        echo "GRUB_SERIAL_COMMAND=\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\"" \
156
            >> ${TARGET}/etc/default/grub
157
    else
158
        echo "No grub bootloader found, skipping..."
159
    fi
160
fi
161

  
162
# execute cleanups
163
cleanup
164
trap - EXIT
165

  
166
exit 0
/dev/null
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures your network settings after
21
# installation. By default it sets it up to use dhcp.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
FQDN="${INSTANCE_NAME}"
30
SHORT_NAME="$(echo ${INSTANCE_NAME} | cut -d . -f 1)"
31
STATIC=""
32

  
33
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
34
    log_error "Missing target directory"
35
    exit 1
36
fi
37

  
38
if [ -z "${NIC_COUNT}" ] ; then
39
    log_error "Missing NIC_COUNT"
40
    exit 1
41
fi
42

  
43
if [ -f "${NETWORKS_DIR}/instances/${FQDN}" ] ; then
44
    STATIC="yes"
45
    source ${NETWORKS_DIR}/instances/${FQDN}
46
    if [ -f "${NETWORKS_DIR}/subnets/${SUBNET}" ] ; then
47
        source ${NETWORKS_DIR}/subnets/${SUBNET}
48
    else
49
        echo "No subnet file for subnet ${SUBNET}!"
50
        exit 1
51
    fi
52
fi
53

  
54
# Functions
55
debian_setup() {
56
    if [ ! -d "${TARGET}/etc/network" ] ; then
57
        log_error "Missing target network directory"
58
        exit 1
59
    fi
60

  
61
    if [ -z "${STATIC}" ] ; then
62
        cat > ${TARGET}/etc/network/interfaces << EOF
63
# This file describes the network interfaces available on your system
64
# and how to activate them. For more information, see interfaces(5).
65

  
66
auto lo
67
iface lo inet loopback
68

  
69
auto eth0
70
iface eth0 inet dhcp
71

  
72
EOF
73
    else
74
        cat > ${TARGET}/etc/network/interfaces << EOF
75
# This file describes the network interfaces available on your system
76
# and how to activate them. For more information, see interfaces(5).
77

  
78
auto lo
79
iface lo inet loopback
80

  
81
auto eth0
82
iface eth0 inet static
83
    address ${ADDRESS}
84
    netmask ${NETMASK}
85
    gateway ${GATEWAY}
86

  
87
EOF
88
    fi
89

  
90
    if [ -n "${FQDN}" ] ; then
91
        echo "${SHORT_NAME}" > ${TARGET}/etc/hostname
92
    fi
93
}
94

  
95
redhat_setup() {
96
    if [ ! -d "${TARGET}/etc/sysconfig/network-scripts" ] ; then
97
        log_error "Missing target network directory"
98
        exit 1
99
    fi
100
    if [ -z "${STATIC}" ] ; then
101
        cat > ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
102
DEVICE=eth0
103
BOOTPROTO=dhcp
104
ONBOOT=yes
105
EOF
106
    else
107
        cat > ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
108
DEVICE=eth0
109
BOOTPROTO=static
110
IPADDR=${ADDRESS}
111
NETMASK=${NETMASK}
112
ONBOOT=yes
113
EOF
114
    fi
115

  
116
    if [ -n "${FQDN}" ] ; then
117
        cat > ${TARGET}/etc/sysconfig/network << EOF
118
NETWORKING=yes
119
HOSTNAME=${FQDN}
120
GATEWAY=${GATEWAY}
121
EOF
122
    else
123
        cat > ${TARGET}/etc/sysconfig/network << EOF
124
NETWORKING=yes
125
GATEWAY=${GATEWAY}
126
EOF
127
    fi
128
}
129

  
130
gentoo_setup() {
131
    if [ ! -f "${TARGET}/etc/conf.d/net" ] ; then
132
        log_error "Missing target network file"
133
        exit 1
134
    fi
135
    if [ -z "${STATIC}" ] ; then
136
        cat > ${TARGET}/etc/conf.d/net << EOF
137
config_eth0=( "dhcp" )
138
EOF
139
    else
140
        cat > ${TARGET}/etc/conf.d/net << EOF
141
config_eth0=( "${ADDRESS} netmask ${NETMASK}" )
142
routes_eth0=( "default gw ${GATEWAY}" )
143
EOF
144
    fi
145

  
146
    chroot ${TARGET} ln -sf /etc/init.d/net.lo /etc/init.d/net.eth0
147
    chroot ${TARGET} rc-update add net.eth0 default
148

  
149
    if [ -n "${FQDN}" ] ; then
150
        # baselayout-2.x
151
        if [ -d "${TARGET}/usr/share/openrc/" ] ; then
152
            cat > ${TARGET}/etc/conf.d/hostname << EOF
153
hostname="${SHORT_NAME}"
154
EOF
155
        else
156
            cat > ${TARGET}/etc/conf.d/hostname << EOF
157
HOSTNAME="${SHORT_NAME}"
158
EOF
159
        fi
160
    fi
161
}
162

  
163
suse_setup() {
164
    if [ ! -d ${TARGET}/etc/sysconfig/network ] ; then
165
        log_error "Missing target network directory"
166
        exit 1
167
    fi
168
    cat > ${TARGET}/etc/sysconfig/network/ifcfg-eth0 << EOF
169
BOOTPROTO='dhcp4'
170
STARTMODE='auto'
171
NAME='Ethernet Card 0'
172
EOF
173
    if [ -n "${FQDN}" ] ; then
174
        echo "${FQDN}" > ${TARGET}/etc/HOSTNAME
175
    fi
176
}
177

  
178
# Main
179
get_os_type $TARGET
180

  
181
if [ "${NIC_COUNT}" -gt 0 -a -n "${OS_TYPE}" ] ; then
182
    ${OS_TYPE}_setup
183
else
184
    log_error "Unsupported OS_TYPE"
185
fi
186

  
187

  
188
exit 0
b/example/hooks/linux/grub
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures, grub after installation. This
21
# script assumes that grub has been installed onto the image already and a
22
# working grub.conf exists. This is only enabled if using the tarball image
23
# type. 
24

  
25
set -e
26

  
27
. common.sh
28

  
29
debug set -x
30

  
31
CLEANUP=( )
32

  
33
trap cleanup EXIT
34

  
35
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
36
    log_error "Missing target directory"
37
    exit 1
38
fi
39

  
40
# Set disk based on type of hypervisor
41
disk=""
42
if [ "${HYPERVISOR}" = "kvm" ] ; then
43
  disk="vda"
44
else
45
  disk="xda"
46
fi
47

  
48
boot_dir="${TARGET}/boot/grub"
49

  
50
setup_disk_devs() {
51
    root_part="${ROOT_DEV/*-/}"
52
    boot_part="${BOOT_DEV/*-/}"
53

  
54
    mknod ${TARGET}/dev/${disk} b $(stat -L -c "0x%t 0x%T" $BLOCKDEV)
55
    CLEANUP+=("rm -f ${TARGET}/dev/$disk")
56

  
57
    mknod ${TARGET}/dev/${disk}${root_part} b $(stat -L -c "0x%t 0x%T" $ROOT_DEV)
58
    CLEANUP+=("rm -f ${TARGET}/dev/${disk}${root_part}")
59

  
60
    if [ -n "$BOOT_DEV" ] ; then
61
        mknod ${TARGET}/dev/${disk}${boot_part} b $(stat -L -c "0x%t 0x%T" $BOOT_DEV)
62
        CLEANUP+=("rm -f ${TARGET}/dev/${disk}${boot_part}")
63
    fi
64

  
65
    # setup minimal proc environment for grub2
66
    $MKDIR_P ${TARGET}/proc/
67
    cat > ${TARGET}/proc/mounts <<EOF
68
/dev/${disk}${boot_part} /boot ${FILESYSTEM} rw,relatime,barrier=1,data=ordered 0 0
69
/dev/${disk}${root_part} / ${FILESYSTEM} rw,relatime,barrier=1,data=ordered 0 0
70
EOF
71
    CLEANUP+=("rm -r ${TARGET}/proc/mounts")
72

  
73
    cat > ${TARGET}/proc/devices <<EOF
74
Block devices:
75
251 virtblk
76
252 device-mapper
77
EOF
78
    CLEANUP+=("rm -r ${TARGET}/proc/devices")
79
    cat > ${TARGET}/proc/misc << EOF
80
 60 device-mapper
81
EOF
82
    CLEANUP+=("rm -r ${TARGET}/proc/misc")
83
}
84

  
85
add_devicemap() {
86
    cat > "${TARGET}/boot/grub/device.map" <<EOF
87
(hd0) /dev/${disk}
88
EOF
89
}
90

  
91
if [ "${IMAGE_TYPE}" != "qemu" ] && \
92
   [ -z "${INSTANCE_HV_kernel_path}" -o "${IMPORT_SCRIPT}" = "1" ] ; then
93
    setup_disk_devs
94
    add_devicemap
95

  
96
    if [ -e "${boot_dir}/menu.lst" ] ; then
97
        # install grub to the block device
98
        chroot ${TARGET} grub --batch --no-floppy \
99
            --device-map=/boot/grub/device.map > /dev/null <<EOF
100
root (hd0,0)
101
setup (hd0)
102
quit
103
EOF
104
        # check to see if grub is using UUID's and replace if so
105
        if [ -n "$(grep 'root=UUID' ${boot_dir}/menu.lst)" ] ; then
106
            root_uuid="$($VOL_ID $ROOT_DEV)"
107
            sed --follow-symlinks -ie "s/\(root=UUID=\)\([a-z0-9-]*\)/\1${root_uuid}/g" \
108
                ${boot_dir}/menu.lst
109
        fi
110
        # additional kernel arguments for the instance
111
        if [ -n "${KERNEL_ARGS}" ] ; then
112
            sed --follow-symlinks -ie "s/\(.*kernel.*\)/\1 ${KERNEL_ARGS}/g" \
113
                ${boot_dir}/menu.lst
114
        fi
115
    elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then
116
        echo "grub2 support is partially supported"
117
        echo "please run update-grub after the instance is online"
118
        # check to see if grub is using UUID's and replace if so
119
        if [ -n "$(grep 'root=UUID' ${boot_dir}/grub.cfg)" ] ; then
120
            root_uuid="$($VOL_ID $ROOT_DEV)"
121
            sed --follow-symlinks -ie "s/\(root=UUID=\)\([a-z0-9-]*\)/\1${root_uuid}/g" \
122
                ${boot_dir}/grub.cfg
123
        fi
124
        # additional kernel arguments for the instance
125
        if [ -n "${KERNEL_ARGS}" ] ; then
126
            sed -ie "s/.*GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 ${KERNEL_ARGS}\"/" \
127
                ${TARGET}/etc/default/grub
128
        fi
129
        # show the menu countdown in case we want to boot to a different kernel
130
        sed -ie 's/.*GRUB_HIDDEN_TIMEOUT=.*/GRUB_HIDDEN_TIMEOUT=5/' ${TARGET}/etc/default/grub
131
        sed -ie 's/.*GRUB_HIDDEN_TIMEOUT_QUIET=.*/GRUB_HIDDEN_TIMEOUT_QUIET=false/' ${TARGET}/etc/default/grub
132
        # install grub2 MBR
133
        chroot ${TARGET} grub-setup --force --device-map=/boot/grub/device.map \
134
            --directory=/boot/grub --root-device="(hd0,1)" "(hd0)" > /dev/null
135
    fi
136
fi
137

  
138
# setup serial console
139
if [ "${INSTANCE_HV_serial_console}" = "True" ] ; then
140
    if [ ! -e ${TARGET}/dev/${disk} ] ; then
141
        setup_disk_devs
142
    fi
143
    if [ -e "${boot_dir}/menu.lst" ] ; then
144
        # grub 0.x
145
        sed --follow-symlinks -ie 's/^default.*/default 0\n\nserial --unit=0\nterminal --timeout=3 console serial/' \
146
            ${boot_dir}/menu.lst
147
        sed --follow-symlinks -ie 's/\(.*kernel.*\)/\1 console=ttyS0,115200n8/g' \
148
            ${boot_dir}/menu.lst
149
    elif [ -e "${boot_dir}/grub.cfg" -a -e "${TARGET}/etc/default/grub" ] ; then
150
        # grub 2.x
151
        add_devicemap
152
        sed -ie 's/.*GRUB_TERMINAL.*/GRUB_TERMINAL=serial/' ${TARGET}/etc/default/grub
153
        sed -ie 's/.*GRUB_CMDLINE_LINUX=\"\(.*\)\"/GRUB_CMDLINE_LINUX=\"\1 console=ttyS0,115200n8\"/' \
154
            ${TARGET}/etc/default/grub
155
        echo "GRUB_SERIAL_COMMAND=\"serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1\"" \
156
            >> ${TARGET}/etc/default/grub
157
    else
158
        echo "No grub bootloader found, skipping..."
159
    fi
160
fi
161

  
162
# execute cleanups
163
cleanup
164
trap - EXIT
165

  
166
exit 0
b/example/hooks/linux/interfaces
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures your network settings after
21
# installation. By default it sets it up to use dhcp.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
FQDN="${INSTANCE_NAME}"
30
SHORT_NAME="$(echo ${INSTANCE_NAME} | cut -d . -f 1)"
31
STATIC=""
32

  
33
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
34
    log_error "Missing target directory"
35
    exit 1
36
fi
37

  
38
if [ -z "${NIC_COUNT}" ] ; then
39
    log_error "Missing NIC_COUNT"
40
    exit 1
41
fi
42

  
43
if [ -f "${NETWORKS_DIR}/instances/${FQDN}" ] ; then
44
    STATIC="yes"
45
    source ${NETWORKS_DIR}/instances/${FQDN}
46
    if [ -f "${NETWORKS_DIR}/subnets/${SUBNET}" ] ; then
47
        source ${NETWORKS_DIR}/subnets/${SUBNET}
48
    else
49
        echo "No subnet file for subnet ${SUBNET}!"
50
        exit 1
51
    fi
52
fi
53

  
54
# Functions
55
debian_setup() {
56
    if [ ! -d "${TARGET}/etc/network" ] ; then
57
        log_error "Missing target network directory"
58
        exit 1
59
    fi
60

  
61
    if [ -z "${STATIC}" ] ; then
62
        cat > ${TARGET}/etc/network/interfaces << EOF
63
# This file describes the network interfaces available on your system
64
# and how to activate them. For more information, see interfaces(5).
65

  
66
auto lo
67
iface lo inet loopback
68

  
69
auto eth0
70
iface eth0 inet dhcp
71

  
72
EOF
73
    else
74
        cat > ${TARGET}/etc/network/interfaces << EOF
75
# This file describes the network interfaces available on your system
76
# and how to activate them. For more information, see interfaces(5).
77

  
78
auto lo
79
iface lo inet loopback
80

  
81
auto eth0
82
iface eth0 inet static
83
    address ${ADDRESS}
84
    netmask ${NETMASK}
85
    gateway ${GATEWAY}
86

  
87
EOF
88
    fi
89

  
90
    if [ -n "${FQDN}" ] ; then
91
        echo "${SHORT_NAME}" > ${TARGET}/etc/hostname
92
    fi
93
}
94

  
95
redhat_setup() {
96
    if [ ! -d "${TARGET}/etc/sysconfig/network-scripts" ] ; then
97
        log_error "Missing target network directory"
98
        exit 1
99
    fi
100
    if [ -z "${STATIC}" ] ; then
101
        cat > ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
102
DEVICE=eth0
103
BOOTPROTO=dhcp
104
ONBOOT=yes
105
EOF
106
    else
107
        cat > ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
108
DEVICE=eth0
109
BOOTPROTO=static
110
IPADDR=${ADDRESS}
111
NETMASK=${NETMASK}
112
ONBOOT=yes
113
EOF
114
    fi
115

  
116
    if [ -n "${FQDN}" ] ; then
117
        cat > ${TARGET}/etc/sysconfig/network << EOF
118
NETWORKING=yes
119
HOSTNAME=${FQDN}
120
GATEWAY=${GATEWAY}
121
EOF
122
    else
123
        cat > ${TARGET}/etc/sysconfig/network << EOF
124
NETWORKING=yes
125
GATEWAY=${GATEWAY}
126
EOF
127
    fi
128
}
129

  
130
gentoo_setup() {
131
    if [ ! -f "${TARGET}/etc/conf.d/net" ] ; then
132
        log_error "Missing target network file"
133
        exit 1
134
    fi
135
    if [ -z "${STATIC}" ] ; then
136
        cat > ${TARGET}/etc/conf.d/net << EOF
137
config_eth0=( "dhcp" )
138
EOF
139
    else
140
        cat > ${TARGET}/etc/conf.d/net << EOF
141
config_eth0=( "${ADDRESS} netmask ${NETMASK}" )
142
routes_eth0=( "default gw ${GATEWAY}" )
143
EOF
144
    fi
145

  
146
    chroot ${TARGET} ln -sf /etc/init.d/net.lo /etc/init.d/net.eth0
147
    chroot ${TARGET} rc-update add net.eth0 default
148

  
149
    if [ -n "${FQDN}" ] ; then
150
        # baselayout-2.x
151
        if [ -d "${TARGET}/usr/share/openrc/" ] ; then
152
            cat > ${TARGET}/etc/conf.d/hostname << EOF
153
hostname="${SHORT_NAME}"
154
EOF
155
        else
156
            cat > ${TARGET}/etc/conf.d/hostname << EOF
157
HOSTNAME="${SHORT_NAME}"
158
EOF
159
        fi
160
    fi
161
}
162

  
163
suse_setup() {
164
    if [ ! -d ${TARGET}/etc/sysconfig/network ] ; then
165
        log_error "Missing target network directory"
166
        exit 1
167
    fi
168
    cat > ${TARGET}/etc/sysconfig/network/ifcfg-eth0 << EOF
169
BOOTPROTO='dhcp4'
170
STARTMODE='auto'
171
NAME='Ethernet Card 0'
172
EOF
173
    if [ -n "${FQDN}" ] ; then
174
        echo "${FQDN}" > ${TARGET}/etc/HOSTNAME
175
    fi
176
}
177

  
178
# Main
179
get_os_type $TARGET
180

  
181
if [ "${NIC_COUNT}" -gt 0 -a -n "${OS_TYPE}" ] ; then
182
    ${OS_TYPE}_setup
183
else
184
    log_error "Unsupported OS_TYPE"
185
fi
186

  
187

  
188
exit 0
b/example/hooks/linux/overlays
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# Copy files from an overlay directory into an instance. This assumes the same
21
# filesystem structure as the system.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
30
    log_error "Missing target directory"
31
    exit 1
32
fi
33

  
34
if [ -n "${OVERLAY}" ] ; then
35
    local overlay="${OVERLAYS_DIR}/${OVERLAY}"
36
    if [ ! -d "${overlay}" ] ; then
37
        log_error "${overlay} not found"
38
    fi
39
    # copy overlay files into target instance
40
    cp -a ${overlay} ${TARGET}
41
fi
42

  
43
exit 0
b/example/hooks/linux/root_passwd
1
#!/bin/bash
2

  
3
#
4
# Copyright (C) 2011 Greek Research and Technology Network
5
#
6

  
7
set -e
8

  
9
. common.sh
10

  
11
debug set -x
12

  
13
HASH=$(${TOOLS_DIR}/snf-passtohash.py -p $IMG_PASSWD)
14

  
15
trap cleanup EXIT
16

  
17
if [ -e ${TARGET}/etc/shadow ]; then
18
    echo "Setting root password... "
19
    SHADOW_TMP=$(mktemp --tmpdir=${TARGET}/etc)
20
    echo "root:$HASH:15103:0:99999:7:::" > $SHADOW_TMP
21
    grep -v "root" ${TARGET}/etc/shadow >> $SHADOW_TMP
22
    cat $SHADOW_TMP > ${TARGET}/etc/shadow
23
    CLEANUP+=("rm $SHADOW_TMP")
24
    echo "Root password changed successfully."
25
    cleanup
26
    trap - EXIT
27
    exit 0
28
fi
29

  
30
echo "Couldn't change root password!"
31

  
32
trap - EXIT
33
exit 0
b/example/hooks/linux/ssh
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# Remove all generated keys so that each instance has unique keys for ssh
21

  
22
set -e
23

  
24
. common.sh
25

  
26
debug set -x
27

  
28
HOST_KEY="/etc/ssh/ssh_host_key"
29
RSA_KEY="/etc/ssh/ssh_host_rsa_key"
30
DSA_KEY="/etc/ssh/ssh_host_dsa_key"
31

  
32
if [ -e ${TARGET}/etc/debian_version ] ; then
33
    echo "Debian/Ubuntu: replace existing ssh keys"
34
    [ -f "${TARGET}/${RSA_KEY}" ] && rm -f ${TARGET}/${RSA_KEY}* && \
35
        ssh-keygen -t rsa -q -N '' -f ${TARGET}/${RSA_KEY}
36
    [ -f "${TARGET}/${DSA_KEY}" ] && rm -f ${TARGET}/${DSA_KEY}* && \
37
        ssh-keygen -t dsa -q -N '' -f ${TARGET}/${DSA_KEY}
38
    exit 0
39
fi
40

  
41
for key in $HOST_KEY $RSA_KEY $DSA_KEY ; do
42
    if [ -f "${TARGET}/${key}" ] ; then
43
        rm -f ${TARGET}/${key}*
44
    fi
45
done
46

  
47
exit 0
b/example/hooks/linux/zz_ddns
1
#!/bin/bash
2

  
3
# Copyright (C) 2011 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures your DHCP clients to set "send
21
# host-name" so that Dynamic DNS work properly after installation.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
FQDN="${INSTANCE_NAME}"
30
SHORT_NAME="$(echo ${INSTANCE_NAME} | cut -d . -f 1)"
31

  
32
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
33
    log_error "Missing target directory"
34
    exit 1
35
fi
36

  
37

  
38
# Functions
39
debian_setup() {
40
    local dhclient_conf=""
41
    if [ -f "${TARGET}/etc/dhcp/dhclient.conf" ] ; then
42
        dhclient_conf="${TARGET}/etc/dhcp/dhclient.conf"
43
    elif [ -f "${TARGET}/etc/dhcp3/dhclient.conf" ] ; then
44
        dhclient_conf="${TARGET}/etc/dhcp3/dhclient.conf"
45
    else
46
        log_error "Missing dhclient.conf file"
47
        exit 1
48
    fi
49

  
50
    if [ -n "${FQDN}" ] ; then
51
        echo "send host-name ${SHORT_NAME};" >> ${dhclient_conf}
52
    fi
53
}
54

  
55
redhat_setup() {
56
    if [ ! -f "${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0" ] ; then
57
        log_error "Missing ifcfg-eth0 file"
58
        exit 1
59
    fi
60
    if [ -n "${FQDN}" ] ; then
61
        echo "DHCP_HOSTNAME=${SHORT_NAME}" >> ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0
62
    fi
63
}
64

  
65
gentoo_setup() {
66
    echo "no action needed for ddns"
67
}
68

  
69
suse_setup() {
70
    echo "untested for suse"
71
}
72

  
73
# Main
74
get_os_type $TARGET
75

  
76
if [ "${NIC_COUNT}" -gt 0 -a -n "${OS_TYPE}" ] ; then
77
    ${OS_TYPE}_setup
78
else
79
    log_error "Unsupported OS_TYPE"
80
fi
81

  
82
exit 0
/dev/null
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# Copy files from an overlay directory into an instance. This assumes the same
21
# filesystem structure as the system.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
30
    log_error "Missing target directory"
31
    exit 1
32
fi
33

  
34
if [ -n "${OVERLAY}" ] ; then
35
    local overlay="${OVERLAYS_DIR}/${OVERLAY}"
36
    if [ ! -d "${overlay}" ] ; then
37
        log_error "${overlay} not found"
38
    fi
39
    # copy overlay files into target instance
40
    cp -a ${overlay} ${TARGET}
41
fi
42

  
43
exit 0
/dev/null
1
#!/bin/bash
2

  
3
#
4
# Copyright (C) 2011 Greek Research and Technology Network
5
#
6

  
7
set -e
8

  
9
. common.sh
10

  
11
debug set -x
12

  
13
HASH=$(${TOOLS_DIR}/snf-passtohash.py -p $IMG_PASSWD)
14

  
15
trap cleanup EXIT
16

  
17
if [ -e ${TARGET}/etc/shadow ]; then
18
    echo "Setting root password... "
19
    SHADOW_TMP=$(mktemp --tmpdir=${TARGET}/etc)
20
    echo "root:$HASH:15103:0:99999:7:::" > $SHADOW_TMP
21
    grep -v "root" ${TARGET}/etc/shadow >> $SHADOW_TMP
22
    cat $SHADOW_TMP > ${TARGET}/etc/shadow
23
    CLEANUP+=("rm $SHADOW_TMP")
24
    echo "Root password changed successfully."
25
    cleanup
26
    trap - EXIT
27
    exit 0
28
fi
29

  
30
echo "Couldn't change root password!"
31

  
32
trap - EXIT
33
exit 0
/dev/null
1
#!/bin/bash
2

  
3
# Copyright (C) 2010 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# Remove all generated keys so that each instance has unique keys for ssh
21

  
22
set -e
23

  
24
. common.sh
25

  
26
debug set -x
27

  
28
HOST_KEY="/etc/ssh/ssh_host_key"
29
RSA_KEY="/etc/ssh/ssh_host_rsa_key"
30
DSA_KEY="/etc/ssh/ssh_host_dsa_key"
31

  
32
if [ -e ${TARGET}/etc/debian_version ] ; then
33
    echo "Debian/Ubuntu: replace existing ssh keys"
34
    [ -f "${TARGET}/${RSA_KEY}" ] && rm -f ${TARGET}/${RSA_KEY}* && \
35
        ssh-keygen -t rsa -q -N '' -f ${TARGET}/${RSA_KEY}
36
    [ -f "${TARGET}/${DSA_KEY}" ] && rm -f ${TARGET}/${DSA_KEY}* && \
37
        ssh-keygen -t dsa -q -N '' -f ${TARGET}/${DSA_KEY}
38
    exit 0
39
fi
40

  
41
for key in $HOST_KEY $RSA_KEY $DSA_KEY ; do
42
    if [ -f "${TARGET}/${key}" ] ; then
43
        rm -f ${TARGET}/${key}*
44
    fi
45
done
46

  
47
exit 0
/dev/null
1
#!/bin/bash
2

  
3
# Copyright (C) 2011 Oregon State University
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19
#
20
# This is an example script that configures your DHCP clients to set "send
21
# host-name" so that Dynamic DNS work properly after installation.
22

  
23
set -e
24

  
25
. common.sh
26

  
27
debug set -x
28

  
29
FQDN="${INSTANCE_NAME}"
30
SHORT_NAME="$(echo ${INSTANCE_NAME} | cut -d . -f 1)"
31

  
32
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
33
    log_error "Missing target directory"
34
    exit 1
35
fi
36

  
37

  
38
# Functions
39
debian_setup() {
40
    local dhclient_conf=""
41
    if [ -f "${TARGET}/etc/dhcp/dhclient.conf" ] ; then
42
        dhclient_conf="${TARGET}/etc/dhcp/dhclient.conf"
43
    elif [ -f "${TARGET}/etc/dhcp3/dhclient.conf" ] ; then
44
        dhclient_conf="${TARGET}/etc/dhcp3/dhclient.conf"
45
    else
46
        log_error "Missing dhclient.conf file"
47
        exit 1
48
    fi
49

  
50
    if [ -n "${FQDN}" ] ; then
51
        echo "send host-name ${SHORT_NAME};" >> ${dhclient_conf}
52
    fi
53
}
54

  
55
redhat_setup() {
56
    if [ ! -f "${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0" ] ; then
57
        log_error "Missing ifcfg-eth0 file"
58
        exit 1
59
    fi
60
    if [ -n "${FQDN}" ] ; then
61
        echo "DHCP_HOSTNAME=${SHORT_NAME}" >> ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0
62
    fi
63
}
64

  
65
gentoo_setup() {
66
    echo "no action needed for ddns"
67
}
68

  
69
suse_setup() {
70
    echo "untested for suse"
71
}
72

  
73
# Main
74
get_os_type $TARGET
75

  
76
if [ "${NIC_COUNT}" -gt 0 -a -n "${OS_TYPE}" ] ; then
77
    ${OS_TYPE}_setup
78
else
79
    log_error "Unsupported OS_TYPE"
80
fi
81

  
82
exit 0
b/ganeti-instance-image.spec
61 61
%doc COPYING README NEWS example/hooks/*
62 62
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/variants/default.conf
63 63
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/variants.list
64
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/hooks/*
64
%config(noreplace) %{_sysconfdir}/ganeti/instance-%{instancename}/hooks/linux/*
65 65
%{_libdir}/ganeti/os/%{instancename}/*
66 66

  
67 67

  

Also available in: Unified diff