#!/bin/sh

if [ -f /tftpboot/$KERNEL ]; then
	echo "Build $KERNEL version $MAJOR.$MINOR.$OEM.$TESTING"
	cp -a /tftpboot/$KERNEL /tftpboot/noaddversion/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING
	./addver /tftpboot/$KERNEL $MAJOR $MINOR $OEM $TESTING
	if [ $OEM -eq 0 ]; then
		mv -f /tftpboot/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$KERNEL-$MAJOR.$MINOR.bin
	elif [ $TESTING -eq 0 ]; then
		mv -f /tftpboot/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$KERNEL-$MAJOR.$MINOR.$OEM.bin
	else
		mv -f /tftpboot/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$KERNEL-$MAJOR.$MINOR.$OEM.$TESTING.bin
	fi
fi

if [ -f /tftpboot/$MXDISK ]; then
	echo "Build $MXDISK version $MAJOR.$MINOR.$OEM.$TESTING"
	cp -a /tftpboot/$MXDISK /tftpboot/noaddversion/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING
	./addver /tftpboot/$MXDISK $MAJOR $MINOR $OEM $TESTING
	if [ $OEM -eq 0 ]; then
		mv -f /tftpboot/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$MXDISK-$MAJOR.$MINOR.dsk
	elif [ $TESTING -eq 0 ]; then
		mv -f /tftpboot/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$MXDISK-$MAJOR.$MINOR.$OEM.dsk
	else
		mv -f /tftpboot/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$MXDISK-$MAJOR.$MINOR.$OEM.$TESTING.dsk
	fi
fi

if [ -f /tftpboot/$USRDISK ]; then
	echo "Build $USRDISK version $MAJOR.$MINOR.$OEM.$TESTING"
	cp -a /tftpboot/$USRDISK /tftpboot/noaddversion/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING
	./addver /tftpboot/$USRDISK $MAJOR $MINOR $OEM $TESTING
	if [ $OEM -eq 0 ]; then
		mv -f /tftpboot/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$USRDISK-$MAJOR.$MINOR.dsk
	elif [ $TESTING -eq 0 ]; then
		mv -f /tftpboot/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$USRDISK-$MAJOR.$MINOR.$OEM.dsk
	else
		mv -f /tftpboot/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING /tftpboot/$USRDISK-$MAJOR.$MINOR.$OEM.$TESTING.dsk
	fi
fi
