#!/bin/bash

set -e

fcopy -r /etc/fai

if [ "$FAI_ACTION" == "install" ] || [ "$CONVERT" == "true" ] ; then
    ## fetch template and insert 'number' of workstations:
    FILE="/usr/local/sbin/debian-lan-chroots"
    fcopy $FILE
    sed -i "s/WS_RANGE/${WS_RANGE}/g" "${target}$FILE"
    sed -i "s/DL_RANGE/${DL_RANGE}/g" "${target}$FILE"
    PREFIX=$(echo "$SUBNET" | cut -d "." --fields=1,2,3)
    sed -i "s/PREFIX/${PREFIX}/g" "${target}$FILE"

    if ifclass DISKLESS_SERVER ; then
	sed -i "s%\(^.*\#\#DISKLESS_SERVER\#\#\)%\#\1%"  "${target}$FILE"
    fi
fi
