summaryrefslogtreecommitdiffstats
path: root/deployd.sh
blob: 692196a964e6879ad552e0f30959cde6fd9151d8 (plain)
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
#!/bin/sh

PXE_ROOT=/var/lib/tftpboot/X86PC/linux/pxelinux.cfg

log() {
    logger -t deployd $@
}

read MAC_ADDR
PXE_ADDR=01-${MAC_ADDR//:/-}
PXE_FILE=${PXE_ROOT}/${PXE_ADDR}

if [ -L ${PXE_FILE} ]; then
    INST_LINK=`readlink ${PXE_FILE}`
    BOOT_LINK=${INST_LINK/install/boot}
    if [ ${INST_LINK} = ${BOOT_LINK} ]; then
        log "${MAC_ADDR} was already installed"
    elif ln -sf ${BOOT_LINK} ${PXE_FILE}; then
        log "${MAC_ADDR} successfully installed"
    else
        log "unable to switch ${MAC_ADDR} to boot profile"
    fi
else
    log "failed to locate configuration for ${MAC_ADDR}"
fi