Statistics
| Branch: | Revision:

root / example / hooks / linux / zz_ddns @ 8d77389f

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

    
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