Blame IbaTools/FastFabric/mac_to_dhcp.sh

Packit Service 3470d1
#!/bin/bash
Packit Service 3470d1
# BEGIN_ICS_COPYRIGHT8 ****************************************
Packit Service 3470d1
# 
Packit Service 3470d1
# Copyright (c) 2015, Intel Corporation
Packit Service 3470d1
# 
Packit Service 3470d1
# Redistribution and use in source and binary forms, with or without
Packit Service 3470d1
# modification, are permitted provided that the following conditions are met:
Packit Service 3470d1
# 
Packit Service 3470d1
#     * Redistributions of source code must retain the above copyright notice,
Packit Service 3470d1
#       this list of conditions and the following disclaimer.
Packit Service 3470d1
#     * Redistributions in binary form must reproduce the above copyright
Packit Service 3470d1
#       notice, this list of conditions and the following disclaimer in the
Packit Service 3470d1
#       documentation and/or other materials provided with the distribution.
Packit Service 3470d1
#     * Neither the name of Intel Corporation nor the names of its contributors
Packit Service 3470d1
#       may be used to endorse or promote products derived from this software
Packit Service 3470d1
#       without specific prior written permission.
Packit Service 3470d1
# 
Packit Service 3470d1
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit Service 3470d1
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 3470d1
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit Service 3470d1
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit Service 3470d1
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 3470d1
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit Service 3470d1
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit Service 3470d1
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit Service 3470d1
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit Service 3470d1
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 3470d1
# 
Packit Service 3470d1
# END_ICS_COPYRIGHT8   ****************************************
Packit Service 3470d1
Packit Service 3470d1
#[ICS VERSION STRING: unknown]
Packit Service 3470d1
Packit Service 3470d1
# given a file of host and mac addresses, generate dhcp stanzas to
Packit Service 3470d1
# append to dhcpd.conf
Packit Service 3470d1
# this works for an inpurt file format such as:
Packit Service 3470d1
# myserver252 00:26:6C:F0:BB:94
Packit Service 3470d1
# myserver253 00:26:6C:F0:A7:A4
Packit Service 3470d1
# Usage:
Packit Service 3470d1
#	mac_to_dhcp < in_file > dhcp_file
Packit Service 3470d1
Packit Service 3470d1
Packit Service 3470d1
while read host mac
Packit Service 3470d1
do
Packit Service 3470d1
cat << EOF
Packit Service 3470d1
host $host {
Packit Service 3470d1
  option host-name "$host";
Packit Service 3470d1
  hardware ethernet $mac;
Packit Service 3470d1
  fixed-address $host;
Packit Service 3470d1
}
Packit Service 3470d1
EOF
Packit Service 3470d1
done