Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.1 kB)

1 139cbdf5 Lance Albertson
#!/bin/bash
2 139cbdf5 Lance Albertson
3 139cbdf5 Lance Albertson
# Copyright (C) 2011 Oregon State University
4 139cbdf5 Lance Albertson
#
5 139cbdf5 Lance Albertson
# This program is free software; you can redistribute it and/or modify
6 139cbdf5 Lance Albertson
# it under the terms of the GNU General Public License as published by
7 139cbdf5 Lance Albertson
# the Free Software Foundation; either version 2 of the License, or
8 139cbdf5 Lance Albertson
# (at your option) any later version.
9 139cbdf5 Lance Albertson
#
10 139cbdf5 Lance Albertson
# This program is distributed in the hope that it will be useful, but
11 139cbdf5 Lance Albertson
# WITHOUT ANY WARRANTY; without even the implied warranty of
12 139cbdf5 Lance Albertson
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 139cbdf5 Lance Albertson
# General Public License for more details.
14 139cbdf5 Lance Albertson
#
15 139cbdf5 Lance Albertson
# You should have received a copy of the GNU General Public License
16 139cbdf5 Lance Albertson
# along with this program; if not, write to the Free Software
17 139cbdf5 Lance Albertson
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 139cbdf5 Lance Albertson
# 02110-1301, USA.
19 139cbdf5 Lance Albertson
#
20 139cbdf5 Lance Albertson
# This is an example script that configures your DHCP clients to set "send
21 139cbdf5 Lance Albertson
# host-name" so that Dynamic DNS work properly after installation.
22 139cbdf5 Lance Albertson
23 139cbdf5 Lance Albertson
set -e
24 139cbdf5 Lance Albertson
25 139cbdf5 Lance Albertson
. common.sh
26 139cbdf5 Lance Albertson
27 139cbdf5 Lance Albertson
debug set -x
28 139cbdf5 Lance Albertson
29 139cbdf5 Lance Albertson
FQDN="${INSTANCE_NAME}"
30 139cbdf5 Lance Albertson
SHORT_NAME="$(echo ${INSTANCE_NAME} | cut -d . -f 1)"
31 139cbdf5 Lance Albertson
32 139cbdf5 Lance Albertson
if [ -z "${TARGET}" -o ! -d "${TARGET}" ] ; then
33 139cbdf5 Lance Albertson
    log_error "Missing target directory"
34 139cbdf5 Lance Albertson
    exit 1
35 139cbdf5 Lance Albertson
fi
36 139cbdf5 Lance Albertson
37 139cbdf5 Lance Albertson
38 139cbdf5 Lance Albertson
# Functions
39 139cbdf5 Lance Albertson
debian_setup() {
40 139cbdf5 Lance Albertson
    local dhclient_conf=""
41 139cbdf5 Lance Albertson
    if [ -f "${TARGET}/etc/dhcp/dhclient.conf" ] ; then
42 139cbdf5 Lance Albertson
        dhclient_conf="${TARGET}/etc/dhcp/dhclient.conf"
43 139cbdf5 Lance Albertson
    elif [ -f "${TARGET}/etc/dhcp3/dhclient.conf" ] ; then
44 139cbdf5 Lance Albertson
        dhclient_conf="${TARGET}/etc/dhcp3/dhclient.conf"
45 139cbdf5 Lance Albertson
    else
46 139cbdf5 Lance Albertson
        log_error "Missing dhclient.conf file"
47 139cbdf5 Lance Albertson
        exit 1
48 139cbdf5 Lance Albertson
    fi
49 139cbdf5 Lance Albertson
50 139cbdf5 Lance Albertson
    if [ -n "${FQDN}" ] ; then
51 b6ccd2b4 Lance Albertson
        echo "send host-name ${SHORT_NAME};" >> ${dhclient_conf}
52 139cbdf5 Lance Albertson
    fi
53 139cbdf5 Lance Albertson
}
54 139cbdf5 Lance Albertson
55 139cbdf5 Lance Albertson
redhat_setup() {
56 139cbdf5 Lance Albertson
    if [ ! -f "${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0" ] ; then
57 139cbdf5 Lance Albertson
        log_error "Missing ifcfg-eth0 file"
58 139cbdf5 Lance Albertson
        exit 1
59 139cbdf5 Lance Albertson
    fi
60 139cbdf5 Lance Albertson
    if [ -n "${FQDN}" ] ; then
61 139cbdf5 Lance Albertson
        echo "DHCP_HOSTNAME=${SHORT_NAME}" >> ${TARGET}/etc/sysconfig/network-scripts/ifcfg-eth0
62 139cbdf5 Lance Albertson
    fi
63 139cbdf5 Lance Albertson
}
64 139cbdf5 Lance Albertson
65 139cbdf5 Lance Albertson
gentoo_setup() {
66 139cbdf5 Lance Albertson
    echo "no action needed for ddns"
67 139cbdf5 Lance Albertson
}
68 139cbdf5 Lance Albertson
69 139cbdf5 Lance Albertson
suse_setup() {
70 139cbdf5 Lance Albertson
    echo "untested for suse"
71 139cbdf5 Lance Albertson
}
72 139cbdf5 Lance Albertson
73 139cbdf5 Lance Albertson
# Main
74 139cbdf5 Lance Albertson
get_os_type $TARGET
75 139cbdf5 Lance Albertson
76 139cbdf5 Lance Albertson
if [ "${NIC_COUNT}" -gt 0 -a -n "${OS_TYPE}" ] ; then
77 139cbdf5 Lance Albertson
    ${OS_TYPE}_setup
78 139cbdf5 Lance Albertson
else
79 139cbdf5 Lance Albertson
    log_error "Unsupported OS_TYPE"
80 139cbdf5 Lance Albertson
fi
81 139cbdf5 Lance Albertson
82 139cbdf5 Lance Albertson
exit 0