diff --git a/.gitignore b/.gitignore index ac7179c..f0d5c26 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ *.iso *.tar *.gz +tftproot/fedora +tftproot/debian +tftproot/centos +tftproot/opensuse # Created by https://www.gitignore.io/api/python,linux ### Python ### diff --git a/pykickxe.py b/pykickxe.py index 969272e..edf6e18 100644 --- a/pykickxe.py +++ b/pykickxe.py @@ -24,36 +24,15 @@ def downloadFromURL(args): # TODO: Implement download #p1 # urllib.urlretrieve(distroURL) # TODO: Decide on this or wget #p3 # TODO: Check if file already present #p1 # TODO: Check filesum #p2 - return filePath # TODO: return filename from url #p1 + return filePath -def unpackImage(args, fileName): - # modify using subprocess - # ISO_PATH = "your_iso_path_here" - # # Mount the ISO in your OS - # os.system("mkdir /media/tmp_iso") - # os.system("mount -o rw,loop %s /media/tmp_iso" % ISO_PATH) - # # Do your Pythonic manipulation here: - # new_file = open("/media/tmp_iso/.config", 'w') - # new_file.write(data) - # new_file.close() - # # Unmount - # os.system("umount /media/tmp_iso") - # os.system("rmdir /media/tmp_iso") - return - - -def unpackArchive(args, fileName): - return +def copyToTftp(): + os.system('cp ./tftproot/. ' + pykickxe_conf.tftpRoot) -def unpackDownloaded(args, fileName): - # TODO: Of cource this is ugly and wrong, use python-magic #p2 - if '.iso' in fileName: - unpackImage(args, fileName) - elif '.tar.gz' in fileName: - unpackArchive(args, fileName) - return +def writeToMenu(): + menuPath = pykickxe_conf.tftpRoot + 'pxelinux.cfg/autoinstall.menu' def parseArgs(): @@ -72,12 +51,16 @@ def parseArgs(): '--list', help='list some default options', action='store_true') + parser.add_argument( + '-d', + '--download', + help='Download (not really working)', + action='store_true') parser.add_argument( '-v', '--verbose', help='print some of what this is doing at any moment', action='store_true') - parser.add_argument( '-t', '--tftp_root', @@ -102,28 +85,6 @@ def parseArgs(): args = parseArgs() # TODO: Add sensible options and check exclusivity #p3 if args.list is True: listConfig() -filePath = downloadFromURL(args) -# TODO: Restructure parser to make sense #p2 -# parse_args() - -# assign to chosen distro -# assign to tftp-root location -# unpack() (iso or tar) - - -# modify using subprocess - -# ISO_PATH = "your_iso_path_here" - -# # Mount the ISO in your OS -# os.system("mkdir /media/tmp_iso") -# os.system("mount -o rw,loop %s /media/tmp_iso" % ISO_PATH) - -# # Do your Pythonic manipulation here: -# new_file = open("/media/tmp_iso/.config", 'w') -# new_file.write(data) -# new_file.close() - -# # Unmount -# os.system("umount /media/tmp_iso") -# os.system("rmdir /media/tmp_iso") +if args.download is True: + filePath = downloadFromURL(args) +copyToTftp() \ No newline at end of file diff --git a/tftproot/fedora/initrd.img b/tftproot/fedora/initrd.img deleted file mode 100644 index 71a29a2..0000000 Binary files a/tftproot/fedora/initrd.img and /dev/null differ diff --git a/tftproot/fedora/vmlinuz b/tftproot/fedora/vmlinuz deleted file mode 100755 index b5afc4f..0000000 Binary files a/tftproot/fedora/vmlinuz and /dev/null differ diff --git a/tftproot/pxelinux.0 b/tftproot/pxelinux.0 new file mode 100644 index 0000000..61a3888 Binary files /dev/null and b/tftproot/pxelinux.0 differ diff --git a/tftproot/pxelinux.cfg/default b/tftproot/pxelinux.cfg/default index 2b172fa..dae8703 100644 --- a/tftproot/pxelinux.cfg/default +++ b/tftproot/pxelinux.cfg/default @@ -8,10 +8,18 @@ LABEL autoinstall KERNEL menu.c32 APPEND pxelinux.cfg/graphics.conf pxelinux.cfg/autoinstall.menu -LABEL debian - KERNEL debian-installer/amd64/linux - APPEND vga=normal initrd=debian-installer/amd64/initrd.gz +LABEL Debian + KERNEL debian/linux + APPEND ftinitrd=debian/initrd.gz -LABEL fedora +LABEL Fedora KERNEL fedora/vmlinuz - APPEND vga=normal initrd=fedora/initrd.img inst.repo=https://dl.fedoraproject.org/pub/fedora/linux/development/25/Workstation/x86_64/os/ \ No newline at end of file + APPEND initrd=fedora/initrd.img inst.repo=https://ftp-stud.hs-esslingen.de/pub/fedora/linux/releases/25/Everything/x86_64/os/ + +LABEL CentOS + KERNEL centos/vmlinuz + APPEND initrd=centos/initrd.img method=ftp://192.168.0.2/centos/CentOS_ISO/ devfs=nomount ip=dhcp + +LABEL OpenSUSE + KERNEL opensuse/? + APPEND ? \ No newline at end of file