#!/bin/sh debianrelease=jessie debianarch=amd64 nameserver=8.8.8.8 cidr2mask () { # Number of args to shift, 255..255, first non-255 byte, zeroes set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 [ $1 -gt 1 ] && shift $1 || shift echo ${1-0}.${2-0}.${3-0}.${4-0} } ip=$(ip route get 1 | awk '{print $NF;exit}') gateway=$(ip route get 1 | awk '{print $3;exit}') default_if=$(ip route list | awk '/^default/ {print $5}') cidr=$(ip -o -f inet addr show $default_if | awk '{print $4}') netmask=$(cidr2mask "${cidr##*/}") echo "Detected network configuration:" 1>&2 echo "IP: $ip" 1>&2 echo "Gateway: $gateway" 1>&2 echo "Netmask: $netmask" 1>&2 if mountpoint /boot > /dev/null 2>&1 then ipxepath="/ipxe.lkrn" else ipxepath="/boot/ipxe.lkrn" fi if ! test -f "/boot/ipxe.lkrn" then wget http://boot.ipxe.org/ipxe.lkrn -O /boot/ipxe.lkrn fi cat <