|
32 | 32 | DISPLAY boot.msg |
33 | 33 | LABEL default |
34 | 34 | KERNEL kernel |
35 | | -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" |
| 35 | +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" |
36 | 36 | ''' |
37 | 37 |
|
38 | 38 | tftp_dir = '' |
|
43 | 43 | image_to_restore = '' |
44 | 44 | cifs_username = '' |
45 | 45 | cifs_password = '' |
| 46 | +ip = '' |
| 47 | +netmask = '' |
| 48 | +gateway = '' |
46 | 49 |
|
47 | 50 | def prepare_boot_file(): |
48 | | - try: |
49 | | - pxelinux = join(tftp_dir, "pxelinux.cfg") |
50 | | - if exists(pxelinux) == False: |
51 | | - makedirs(pxelinux) |
| 51 | + try: |
| 52 | + pxelinux = join(tftp_dir, "pxelinux.cfg") |
| 53 | + if exists(pxelinux) == False: |
| 54 | + makedirs(pxelinux) |
52 | 55 |
|
53 | | - cfg_name = "01-" + mac.replace(':','-').lower() |
54 | | - cfg_path = join(pxelinux, cfg_name) |
55 | | - f = open(cfg_path, "w") |
56 | | - stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password) |
57 | | - f.write(stuff) |
58 | | - f.close() |
59 | | - return 0 |
60 | | - except IOError, e: |
61 | | - print e |
62 | | - return 1 |
| 56 | + cfg_name = "01-" + mac.replace(':','-').lower() |
| 57 | + cfg_path = join(pxelinux, cfg_name) |
| 58 | + f = open(cfg_path, "w") |
| 59 | + stuff = template % (cifs_server, share, directory, image_to_restore, cifs_username, cifs_password, ip, netmask, gateway) |
| 60 | + f.write(stuff) |
| 61 | + f.close() |
| 62 | + return 0 |
| 63 | + except IOError, e: |
| 64 | + print e |
| 65 | + return 1 |
63 | 66 |
|
64 | 67 | if __name__ == "__main__": |
65 | | - if len(sys.argv) < 9: |
66 | | - print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password" |
67 | | - exit(1) |
| 68 | + if len(sys.argv) < 12: |
| 69 | + print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway" |
| 70 | + exit(1) |
68 | 71 |
|
69 | | - tftp_dir = sys.argv[1] |
70 | | - mac = sys.argv[2] |
71 | | - cifs_server = sys.argv[3] |
72 | | - share = sys.argv[4] |
73 | | - directory = sys.argv[5] |
74 | | - image_to_restore = sys.argv[6] |
75 | | - cifs_username = sys.argv[7] |
76 | | - cifs_password = sys.argv[8] |
| 72 | + tftp_dir = sys.argv[1] |
| 73 | + mac = sys.argv[2] |
| 74 | + cifs_server = sys.argv[3] |
| 75 | + share = sys.argv[4] |
| 76 | + directory = sys.argv[5] |
| 77 | + image_to_restore = sys.argv[6] |
| 78 | + cifs_username = sys.argv[7] |
| 79 | + cifs_password = sys.argv[8] |
| 80 | + ip = sys.argv[9] |
| 81 | + netmask = sys.argv[10] |
| 82 | + gateway = sys.argv[11] |
| 83 | + |
77 | 84 |
|
78 | | - ret = prepare_boot_file() |
79 | | - exit(ret) |
| 85 | + ret = prepare_boot_file() |
| 86 | + exit(ret) |
0 commit comments