summaryrefslogtreecommitdiff
path: root/configs/syslinux-iso
diff options
context:
space:
mode:
authorGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2010-03-18 00:26:36 -0300
committerGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2010-03-18 01:01:28 -0300
commit0b2a2c4da13bc1fe7889b244dd885e79f9e636fe (patch)
treebc4c95fc92e8b21dec09207fb69dec59d840f1af /configs/syslinux-iso
parent388dfdc963f83b63ac4c5d02b45bc7048c5d8792 (diff)
downloadarchiso32-0b2a2c4da13bc1fe7889b244dd885e79f9e636fe.tar.xz
Add an overlay/arch/archiso-pxe-server script
The purpose of this script is to setup a basic PXE server enviroment from Arch Linux live-media. Only need to setup an ip address in the machine and launch it. Booting all machines conected to the network via PXE will boot Arch Linux Live media :) Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Diffstat (limited to 'configs/syslinux-iso')
-rwxr-xr-xconfigs/syslinux-iso/overlay/arch/archiso-pxe-server88
1 files changed, 88 insertions, 0 deletions
diff --git a/configs/syslinux-iso/overlay/arch/archiso-pxe-server b/configs/syslinux-iso/overlay/arch/archiso-pxe-server
new file mode 100755
index 0000000..a4f0fd4
--- /dev/null
+++ b/configs/syslinux-iso/overlay/arch/archiso-pxe-server
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# A basic script to setup a PXE server enviroment for Arch Linux live-media.
+# Contributed by Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
+
+# usage example: archiso-pxe-server [ip] [bootdevice]
+
+BOOT=/bootmnt/boot
+TFTPBOOT=/var/tftpboot
+
+IP="$1"
+ISO="$2"
+
+IP_ETH0=`ifconfig eth0 | awk -F":| +" '/inet addr/{print $4}'`
+if grep archisolabel /proc/cmdline > /dev/null; then
+ LABEL=`sed "s/.\+archisolabel=\([^ ]\+\).\+/\1/" /proc/cmdline`
+else
+ LABEL=""
+fi
+
+usage()
+{
+ echo
+ echo "archiso-pxe-server [ip] [bootdevice]"
+ echo
+ echo " options:"
+ echo " [ip] ip address of the local interface to serve (default use ip of eth0)"
+ echo " [bootdevice] boot device of Arch Linux Live media (for example /dev/cdrom)"
+ echo
+}
+
+copy_files()
+{
+ if [ ! -d $TFTPBOOT ]; then
+ mkdir -p $TFTPBOOT/boot
+ mkdir -p $TFTPBOOT/pxelinux.cfg
+ cp $BOOT/vmlinuz26 $TFTPBOOT/boot
+ cp $BOOT/archiso.img $TFTPBOOT/boot
+ cp $BOOT/memtest $TFTPBOOT/boot
+ cp $BOOT/x86test $TFTPBOOT/boot
+ cp $BOOT/splash.png $TFTPBOOT/boot
+ cp $BOOT/isolinux/pxelinux.0 $TFTPBOOT
+ cp $BOOT/isolinux/chain.c32 $TFTPBOOT
+ cp $BOOT/isolinux/reboot.c32 $TFTPBOOT
+ cp $BOOT/isolinux/vesamenu.c32 $TFTPBOOT
+ sed 's|IPAPPEND 0|IPAPPEND 1|g' \
+ $BOOT/isolinux/isolinux.cfg > \
+ $TFTPBOOT/pxelinux.cfg/default
+ fi
+}
+
+start_pxe_server()
+{
+ dnsmasq \
+ --enable-tftp \
+ --tftp-root=$TFTPBOOT \
+ --dhcp-boot=/pxelinux.0,"${IP}" \
+ --dhcp-range=${IP%.*}.2,${IP%.*}.254,86400
+}
+
+start_nbd_server()
+{
+ nbd-server 9040 ${ISO} -r
+}
+
+check_parameters()
+{
+ if [ -z "$IP_ETH0" -a -z "$IP" ]; then
+ echo "ERROR: missing IP address"
+ usage
+ exit 1
+ else
+ IP=$IP_ETH0
+ fi
+
+ if [ -z "$LABEL" -a -z "$ISO" ]; then
+ echo "ERROR: can't determine boot device, please specify on command line"
+ usage
+ exit 1
+ else
+ ISO="/dev/disk/by-label/$LABEL"
+ fi
+}
+
+check_parameters
+copy_files
+start_pxe_server
+start_nbd_server