diff --git a/scripts/network/ping/prepare_tftp_bootfile.py b/scripts/network/ping/prepare_tftp_bootfile.py index 5cc08b75f98..f4589faff9b 100644 --- a/scripts/network/ping/prepare_tftp_bootfile.py +++ b/scripts/network/ping/prepare_tftp_bootfile.py @@ -32,7 +32,7 @@ TIMEOUT 26 DISPLAY boot.msg LABEL default KERNEL kernel -APPEND vga=normal devfs=nomount pxe ramdisk_size=66000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noapic nolapic lba combined_mode=libata ide0=noprobe nomce pci=nomsi irqpoll quiet Server="%s" Share="%s" Directory="%s" Image_To_Restore="%s" After_Completion="Reboot" CIFS_Preferred="Y" Zsplit_Preferred="Y" AUTO="Y" User="%s" Passwd="%s" Extend_Parts_Whenever_Possible="N" Replace_BIOS="N" +APPEND vga=normal devfs=nomount pxe ramdisk_size=66000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=initrd.gz root=/dev/ram0 rw noapic nolapic lba combined_mode=libata ide0=noprobe nomce pci=nomsi irqpoll quiet Server="%s" Share="%s" Directory="%s" Image_To_Restore="%s" After_Completion="Reboot" CIFS_Preferred="Y" Zsplit_Preferred="Y" AUTO="Y" User="%s" Passwd="%s" Extend_Parts_Whenever_Possible="N" Replace_BIOS="N" IP="%s" Netmask="%s" Gateway="%s" ''' tftp_dir = '' @@ -43,37 +43,44 @@ directory = '' image_to_restore = '' cifs_username = '' cifs_password = '' +ip = '' +netmask = '' +gateway = '' def prepare_boot_file(): - try: - pxelinux = join(tftp_dir, "pxelinux.cfg") - if exists(pxelinux) == False: - makedirs(pxelinux) + try: + pxelinux = join(tftp_dir, "pxelinux.cfg") + if exists(pxelinux) == False: + makedirs(pxelinux) - cfg_name = "01-" + mac.replace(':','-').lower() - cfg_path = join(pxelinux, cfg_name) - f = open(cfg_path, "w") - stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password) - f.write(stuff) - f.close() - return 0 - except IOError, e: - print e - return 1 + cfg_name = "01-" + mac.replace(':','-').lower() + cfg_path = join(pxelinux, cfg_name) + f = open(cfg_path, "w") + stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password, ip, netmask, gateway) + f.write(stuff) + f.close() + return 0 + except IOError, e: + print e + return 1 if __name__ == "__main__": - if len(sys.argv) < 9: - print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password" - exit(1) + if len(sys.argv) < 12: + print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway" + exit(1) - tftp_dir = sys.argv[1] - mac = sys.argv[2] - cifs_server = sys.argv[3] - share = sys.argv[4] - directory = sys.argv[5] - image_to_restore = sys.argv[6] - cifs_username = sys.argv[7] - cifs_password = sys.argv[8] + tftp_dir = sys.argv[1] + mac = sys.argv[2] + cifs_server = sys.argv[3] + share = sys.argv[4] + directory = sys.argv[5] + image_to_restore = sys.argv[6] + cifs_username = sys.argv[7] + cifs_password = sys.argv[8] + ip = sys.argv[9] + netmask = sys.argv[10] + gateway = sys.argv[11] + - ret = prepare_boot_file() - exit(ret) + ret = prepare_boot_file() + exit(ret)