Statistics
| Branch: | Revision:

root / example / hooks / linux / zz_ddns @ 7be1e51e

History | View | Annotate | Download (2.1 kB)

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
. common_linux.sh
27

    
28
debug set -x
29

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

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

    
38

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

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

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

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

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

    
74
# Main
75
get_os_type $TARGET
76

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

    
83
exit 0