-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetbless.sh
More file actions
executable file
·56 lines (45 loc) · 1.24 KB
/
netbless.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# netbless.sh
# Select NetBoot set from server
# @author Filipp Lepalaan <filipp@mcare.fi>
# @package mtk
if [[ ${USER} != "root" && -z ${DS_USER_LOGIN} ]]; then
echo "This must be run as root" 2>&1
exit 1
fi
if [[ $1 == "help" ]]; then
echo "Usage: $(basename $0) [nbi] [url] [nbi_path]" 2>&1
exit 0
fi
SERVER=${2:-"sw.mcare.fi"}
SERVER_PATH=${3:-"/data/nb"}
SERVER_IP=$(/usr/bin/dig +short ${SERVER})
MACHINE=$(sysctl -n hw.machine)
if [[ $MACHINE == "x86_64" ]]; then
MACHINE="i386/${MACHINE}"
fi
ME=${1:-$(/usr/sbin/sysctl -n hw.model)}
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 == "list" ]]; then
echo -e "Available images: ${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" \
--nextonly
echo "Startup volume set to ${ME}"
exit 0
fi
done
echo "Error: model ${ME} not found on the NetBoot server" 2>&1
exit 1