This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

gnux_pxe_ubuntu.sh

By: a guest on Feb 3rd, 2013  |  syntax: Bash  |  size: 1.37 KB  |  views: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2.  
  3. ARCH=i386
  4. #ARCH=amd64
  5. DISTRO=ubuntu
  6. PXE_ROOT=/opt/pxe/$DISTRO-$ARCH
  7. DNSMASQ_CONF=/opt/pxe/$DISTRO-$ARCH/dnsmasq.conf
  8.  
  9. sudo apt-get install dnsmasq syslinux memtest86+
  10.  
  11. # Creation du repertoire servi par le builtin tftp de dnsmasq
  12. mkdir -p $PXE_ROOT/pxelinux.cfg
  13. cd $PXE_ROOT
  14.  
  15. # On fetch le kernel, le bootloader pxe et le ramdisk
  16. export SITEFTP=http://archive.ubuntu.com/ubuntu/dists/precise/main/installer-$ARCH/current/images/netboot/ubuntu-installer/i386
  17.  
  18. wget -c $SITEFTP/pxelinux.0 -O $PXE_ROOT/pxelinux.0
  19.  
  20. wget -c $SITEFTP/linux -O $PXE_ROOT/linux
  21. wget -c $SITEFTP/initrd.gz -O $PXE_ROOT/initrd.gz
  22.  
  23.  
  24. # Config du bootloader
  25. cat > $PXE_ROOT/pxelinux.cfg/default << EOF
  26. DEFAULT $DISTRO
  27. LABEL $DISTRO
  28.         kernel linux
  29.         append vga=normal initrd=initrd.gz --
  30. TIMEOUT 0
  31. EOF
  32.  
  33. # Config dnsmasq
  34. cat > $DNSMASQ_CONF << EOF
  35. interface=eth0
  36. enable-tftp
  37. tftp-root=$PXE_ROOT
  38. dhcp-range=10.42.0.10,10.42.0.50,255.255.255.0
  39. dhcp-boot=pxelinux.0,pxeserver,10.42.0.1
  40. EOF
  41.  
  42. echo 1 |sudo cat > /proc/sys/net/ipv4/ip_forward
  43. sudo ifconfig eth0 10.42.0.1 netmask 255.255.255.0
  44. sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
  45.  
  46. # Reload dnsmasq
  47. sudo /etc/init.d/dnsmasq stop
  48. sudo dnsmasq \
  49.         --keep-in-foreground \
  50.         --conf-file=$DNSMASQ_CONF \
  51.         --dhcp-authoritative \
  52.         --log-queries \
  53.         --log-facility=-
clone this paste RAW Paste Data