1#!/bin/sh 2# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved. 3# Copyright (c) International Business Machines Corp., 2001 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License as 7# published by the Free Software Foundation; either version 2 of 8# the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it would be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU 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 the Free Software Foundation, 17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# Author: Manoj Iyer, manjo@mail.utexas.edu 20# Author: Alexey Kodanev alexey.kodanev@oracle.com 21 22TST_CLEANUP=cleanup 23TST_TOTAL=1 24TCID="dhcpd" 25dhcp_name="dhcpd" 26 27. test_net.sh 28. dhcp_lib.sh 29 30setup_dhcpd_conf() 31{ 32 if [ -f /etc/dhcpd.conf ]; then 33 DHCPD_CONF="/etc/dhcpd.conf" 34 elif [ -f /etc/dhcp/dhcpd.conf ]; then 35 DHCPD_CONF="/etc/dhcp/dhcpd.conf" 36 else 37 tst_brkm TBROK "failed to find dhcpd.conf" 38 fi 39 40 mv $DHCPD_CONF dhcpd.conf 41 [ $? -ne 0 ] && tst_brkm TBROK "failed to backup dhcpd.conf" 42 43 mv tst_dhcpd.conf $DHCPD_CONF 44 [ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf" 45} 46 47start_dhcpd() 48{ 49 dhcpd -$ipv $iface0 > tst_dhcpd.err 2>&1 50 if [ $? -ne 0 ]; then 51 cat tst_dhcpd.err 52 tst_brkm TBROK "Failed to start dhcpd" 53 fi 54 55} 56 57start_dhcp() 58{ 59 cat > tst_dhcpd.conf <<-EOF 60 ddns-update-style none; 61 update-static-leases off; 62 subnet 10.1.1.0 netmask 255.255.255.0 { 63 range 10.1.1.100 10.1.1.100; 64 default-lease-time 60; 65 max-lease-time 60; 66 } 67 EOF 68 setup_dhcpd_conf 69 start_dhcpd 70} 71 72start_dhcp6() 73{ 74 cat > tst_dhcpd.conf <<-EOF 75 ddns-update-style none; 76 update-static-leases off; 77 subnet6 fd00:1:1:2::/64 { 78 range6 fd00:1:1:2::100 fd00:1:1:2::100; 79 default-lease-time 60; 80 max-lease-time 60; 81 } 82 EOF 83 setup_dhcpd_conf 84 start_dhcpd 85} 86 87cleanup_dhcp() 88{ 89 [ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF 90} 91 92print_dhcp_log() 93{ 94 cat tst_dhcpd.err 95} 96 97init 98test01 99tst_exit 100