Created
December 30, 2012 21:08
-
-
Save jatkins/c8d1235f91999ba2ab98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
MODE = 2 # Modes 1: set boot record; 2: Remove boot record | |
RECORD = 1 # Record 1: Windows; 2: Linux; 3: Image Cast; 4: Image Recive | |
BASE_ADDRESS = "143.60" | |
VLAN = "74" | |
START_IP = "1" | |
END_IP = "255" | |
############################################################################### | |
# NO EDIT BELOW! | |
############################################################################### | |
def ip2hex(ipaddress) | |
`gethostip #{ipaddress}`.match(/(\w{8})$/) | |
end | |
ip = START_IP.to_i | |
while ip < END_IP.to_i do | |
hex = ip2hex([BASE_ADDRESS, VLAN, ip.to_s].join('.')) | |
if(MODE == 1) | |
if(RECORD == 1) | |
`ln -s /srv/tftp/pxe_configs/boot_windows /srv/tftp/pxelinux.cfg/#{hex}` | |
elsif(RECORD == 2) | |
`ln -s /srv/tftp/pxe_configs/debian /srv/tftp/pxelinux.cfg/#{hex}` | |
elsif(RECORD == 3) | |
`ln -s /srv/tftp/pxe_configs/udpcast_send_image /srv/tftp/pxelinux.cfg/#{hex}` | |
elsif(RECORD == 4) | |
`ln -s /srv/tftp/pxe_configs/udpcast_take_image /srv/tftp/pxelinux.cfg/#{hex}` | |
end | |
elsif(MODE == 2) | |
links = Dir["/srv/tftp/pxelinux.cfg/[0-9A-F]*"] | |
links.each { |n| `rm #{n}` } | |
end | |
ip = ip + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment