1 |
#!/bin/sh |
2 |
|
3 |
PXE_ROOT=/var/lib/tftpboot/X86PC/linux/pxelinux.cfg |
4 |
MAC_TABLE=/var/lib/tftpboot/X86PC/conf_mac_profiles |
5 |
|
6 |
log() { |
7 |
logger -t deployd $@ |
8 |
} |
9 |
|
10 |
read MAC_ADDR |
11 |
PXE_ADDR=01-${MAC_ADDR//:/-} |
12 |
PXE_FILE=${PXE_ROOT}/${PXE_ADDR} |
13 |
|
14 |
NEW_PROFILE=`awk --field-separator \| "!/^#/ { if (\\$1 == \"$MAC_ADDR\") print \\$3}" /var/lib/tftpboot/X86PC/conf_mac_profiles` |
15 |
|
16 |
if [ -n "${NEW_PROFILE}" ]; then |
17 |
INST_LINK=`readlink ${PXE_FILE}` |
18 |
NEW_LINK=profiles/boot/${NEW_PROFILE} |
19 |
if [ ${INST_LINK} = ${NEW_LINK} ]; then |
20 |
log "${MAC_ADDR} was already installed" |
21 |
elif ln -sf ${NEW_LINK} ${PXE_FILE}; then |
22 |
killall -USR1 drakpelinux |
23 |
log "${MAC_ADDR} successfully installed" |
24 |
else |
25 |
log "unable to switch ${MAC_ADDR} to boot profile" |
26 |
fi |
27 |
else |
28 |
log "failed to locate configuration for ${MAC_ADDR}" |
29 |
fi |