Advertisement
tolikpunkoff

netboot-slacko.sh

Jan 11th, 2018
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.75 KB | None | 0 0
  1. #!/bin/sh
  2. #jamesbond 2011
  3. # convert a puppy iso into netboot-compatible vmlinuz and humongous initrd.gz
  4.  
  5. Xdialog --title "mknetboot" --msgbox "This script will create a set of files suitable for puppy netbooting.
  6. The input is a puppy ISO file. The output will be located in /tmp/netboot - one vmlinuz and one huge initrd.gz.
  7. If /root/tftpboot/pxelinux.cfg exist, the output files will be symlinked to this directory as well,
  8. so you can use netboot-server to server them straight away." 0 0
  9.  
  10. ISO=$(Xdialog --title "Choose puppy ISO" -fselect "" 0 0 2>&1 | tail -n 1)
  11.  
  12. if [ -n "$ISO" ]; then
  13.     rm -rf /tmp/netboot /tmp/netboot_iso
  14.     mkdir -p /tmp/netboot/x /tmp/netboot_iso
  15.     if mount -o loop "$ISO" /tmp/netboot_iso; then
  16.         if [ -f /tmp/netboot_iso/vmlinuz -a -f /tmp/netboot_iso/initrd.gz ]; then
  17.             Xdialog --title "mknetboot" --no-buttons --infobox "This will take a while. Please wait ..." 0 0 60000 &
  18.             PID=$!
  19.             cp /tmp/netboot_iso/vmlinuz /tmp/netboot
  20.             cd /tmp/netboot/x
  21.             zcat /tmp/netboot_iso/initrd.gz | cpio -i
  22.             cp /tmp/netboot_iso/*.sfs .
  23.             find . | cpio -o -H newc | gzip -9 > ../initrd.gz
  24.             cd /tmp/netboot
  25.             rm -rf x
  26.             if [ -d /root/tftpboot/pxelinux.cfg ]; then
  27.                 rm /root/tftpboot/pxelinux.cfg/vmlinuz /root/tftpboot/pxelinux.cfg/initrd.gz
  28.                 ln -s /tmp/netboot/vmlinuz /root/tftpboot/pxelinux.cfg
  29.                 ln -s /tmp/netboot/initrd.gz /root/tftpboot/pxelinux.cfg
  30.             fi
  31.             kill $PID
  32.             Xdialog --title "mknetboot" --infobox "Done. Output is in /tmp/netboot." 0 0 10000
  33.         else
  34.             Xdialog --title "mknetboot" --msgbox "Invalid ISO - cannot find vmlinuz and initrd.gz" 0 0
  35.             rm -rf /tmp/netboot
  36.         fi
  37.         umount /tmp/netboot_iso
  38.         rm -rf /tmp/netboot_iso
  39.     else
  40.         Xdialog --title "mknetboot" --msgbox "Failed to mount $ISO" 0 0
  41.     fi
  42. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement