From 0d4d8bfde80e4d7efcb4bab14627a6c97a185dc7 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 17 Nov 2010 17:26:53 +0200 Subject: added netbless --- netbless.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 netbless.sh (limited to 'netbless.sh') diff --git a/netbless.sh b/netbless.sh new file mode 100755 index 0000000..72e3b3b --- /dev/null +++ b/netbless.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +SERVER=sw.mcare.fi +SERVER_PATH="/data/nb" + +if [[ ${USER} != "root" ]]; then + echo "This must be run as root" 2>&1 + exit 1 +fi + +SERVER_IP=$(dig +short ${SERVER}) + +ME=$(/usr/sbin/sysctl -n hw.model) +MACHINE=$(sysctl -n hw.machine) + +if [[ -z ${ME} ]]; then + echo "Error: could not determine hardware model" 2>&1 + exit 1 +fi + +IMAGES=$(/usr/bin/curl -s http://${SERVER}/mh/) + +if [[ $1 == "help" ]]; then + echo -e "Usage: $(basename $0) [${IMAGES}]" 2>&1 + exit 0 +fi + +for IMG in ${IMAGES} +do + if [[ "${IMG}" == "${ME}.nbi" || "${IMG}" == "$1" ]] + then + /usr/sbin/bless --netboot \ + --booter tftp://${SERVER_IP}/${IMG}/${MACHINE}/booter \ + --kernel tftp://${SERVER_IP}/${IMG}/${MACHINE}/mach.macosx \ + --options "rp=nfs:${SERVER_IP}:${SERVER_PATH}:/${IMG}/NetInstall.dmg" + echo "NetBoot set" + exit 0 + fi +done + +echo "Error: model ${ME} not found on the NetBoot server" 2>&1 +exit 1 -- cgit v1.2.3