summaryrefslogtreecommitdiffstats
path: root/deployd.sh
blob: 3321abeb5a3dba585835064235ac652418622bd2 (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
26
27
28
29
#!/bin/sh

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

log() {
    logger -t deployd $@
}

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

NEW_PROFILE=`awk --field-separator \| "!/^#/ { if (\\$1 == \"$MAC_ADDR\") print \\$3}" /var/lib/tftpboot/X86PC/conf_mac_profiles`

if [ -n "${NEW_PROFILE}" ]; then
    INST_LINK=`readlink ${PXE_FILE}`
    NEW_LINK=profiles/boot/${NEW_PROFILE}
    if [ ${INST_LINK} = ${NEW_LINK} ]; then
        log "${MAC_ADDR} was already installed"
    elif ln -sf ${NEW_LINK} ${PXE_FILE}; then
        killall -USR1 drakpelinux
        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