diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-06-07 17:13:50 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-06-07 17:13:50 +0300 |
commit | 6eff099c73db8d293a9e0e433f66bcfddee7ee3f (patch) | |
tree | 8e9133733ca2f4f28279b8fd171ae8616a8f8e08 /asd2nb | |
parent | 3f4f9e895f94cea1931fb1418ad6d2d7731e5aa9 (diff) | |
download | mtk-6eff099c73db8d293a9e0e433f66bcfddee7ee3f.tar.gz mtk-6eff099c73db8d293a9e0e433f66bcfddee7ee3f.tar.bz2 mtk-6eff099c73db8d293a9e0e433f66bcfddee7ee3f.zip |
added asd2nb
Diffstat (limited to 'asd2nb')
-rw-r--r-- | asd2nb/asdbless.sh | 36 | ||||
-rw-r--r-- | asd2nb/server.php | 33 |
2 files changed, 69 insertions, 0 deletions
diff --git a/asd2nb/asdbless.sh b/asd2nb/asdbless.sh new file mode 100644 index 0000000..e18d170 --- /dev/null +++ b/asd2nb/asdbless.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# asdbless.sh +# Pick correct ASD image for this machine +# @author Filipp Lepalaan <filipp@mcare.fi> +# @package mtk + +SERVER_IP=192.168.1.10 # The IP of the NetBoot server +SERVER_URL="http://example.com/mtk/asd2nb/server.php" # URL of the server-side script +NBI_PATH=/data/nb # Path to the ASD image repository +ASD_ROOT=/asd # + +if [[ ! -d "${NBI_PATH}" ]]; then + echo "Path ${NBI_PATH} does not exist" 2>&1 + exit 1 +fi + +MODEL=$(/usr/sbin/sysctl -n hw.model) +MACHINE=$(/usr/sbin/sysctl -n hw.machine) +RESULT=$(/usr/bin/curl -s ${SERVER_URL} -d m=${MODEL}) + +if [[ -z ${RESULT} ]]; then + echo "${MODEL} not found on server, exiting" 2>&1 + exit 1; +fi + +ASD=$(echo $RESULT | awk 'BEGIN { FS = "/" } ; { print $1 }') +DMG=$(echo $RESULT | awk 'BEGIN { FS = "/" } ; { print $2 }') + +/usr/sbin/bless --netboot \ + --booter tftp://${SERVER_IP}${ASD_ROOT}/${ASD}/${MACHINE}/booter \ + --kernel tftp://${SERVER_IP}${ASD_ROOT}/${ASD}/${MACHINE}/mach.macosx \ + --options "rp=nfs:${SERVER_IP}:${NBI_PATH}:${ASD_ROOT}/${RESULT}" \ + --nextonly + +echo "Boot volume set to ${ASD}" +exit 0 diff --git a/asd2nb/server.php b/asd2nb/server.php new file mode 100644 index 0000000..26aaf1a --- /dev/null +++ b/asd2nb/server.php @@ -0,0 +1,33 @@ +<?php + + /** + * server.php + * example server-side script for asd2nb. + * plist.php is here: https://github.com/filipp/php_plist + * @author Filipp Lepalaan <filipp@mcare.fi> + * @package mtk + */ + + header('Content-Type: text/plain'); + + if (!isset($_REQUEST['m'])) { + exit("Sorry, have to know who you are first..."); + } + + $imgdir = '/data/nb/asd'; // edit this + + $model = $_REQUEST['m']; + + require "plist.php"; + + foreach(glob("${imgdir}/*.nbi") as $nbi) + { + $p = new PropertyList("{$nbi}/NBImageInfo.plist"); + $a = $p->toArray(); + $ids = $a['EnabledSystemIdentifiers']; + if (in_array($model, $ids)) { + exit(basename($nbi).'/'.$a['RootPath']); + } + } + +?> |