#!/bin/busybox sh

# Define some handy variables
imagedir=/mnt/nfs/images
scriptdir=/mnt/nfs/scripts/
hostname=$(hostname)

# Load helper functions
source /etc/rc.d/funcs		# Load EFIcast helper functions (echo_color, machine_info, network_show, sfx_*)
source $scriptdir/funcs.sh	# Load some nfs-autorun.sh specific helper functions

# Check all prerequisites and exit if it fail
hostname_test || exit 1
firstdisk_test || exit 2

# Run the main action script
if nfswrite_test
then	# Start deploy script after letting a chance to cancel it
	message deploy ; pause10s; sfx_starting
	source $scriptdir/image_deploy.sh

else	scriptavailability_test image_capture_${hostname}.sh || exit 3
	# Start capture script if all it needs is available
	message capture ; pause10s; sfx_starting
	source $scriptdir/image_capture.sh
fi