diff options
Diffstat (limited to 'netbless.sh')
-rwxr-xr-x | netbless.sh | 42 |
1 files changed, 42 insertions, 0 deletions
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 |