#!/bin/sh
# - The floppy disk must be formatted.
# - The following command will format the floppy disk under QNX:
#           fdformat /dev/fd0
# - You may have to run this script as the "superuser" with uid 0
# 

# Copy the qnx demodisk data to the floppy disk
case "`uname`" in
	*QNX)
	DEV=/dev/fd0
	CMDS="cp qnxdemo.dat $DEV"
	;;

	*inux)
	if test -b /dev/fd0h1440 ; then
		DEV=/dev/fd0h1440
	elif test -b /dev/fd0 ; then
		DEV=/dev/fd0
	else
		echo "$0: /dev/fd0h1440 does not exist"
		exit 1
	fi
	CMDS="dd if=qnxdemo.dat of=$DEV bs=16k"
	;;

	*BSD)
	if test -b /dev/fd0a ; then
		DEV=/dev/fd0a
	elif test -c /dev/rfd0a ; then
		DEV=/dev/rfd0a
	elif test -b /dev/fd0 ; then
		DEV=/dev/fd0
	elif test -c /dev/rfd0 ; then
		DEV=/dev/rfd0
	else
		echo "$0: /dev/rfd0 does not exist"
		exit 1
	fi
	CMDS="dd if=qnxdemo.dat of=$DEV"
	;;

	*)
	if test -b /dev/fd0a ; then
		DEV=/dev/fd0a
	elif test -c /dev/rfd0a ; then
		DEV=/dev/rfd0a
	elif test -b /dev/fd0 ; then
		DEV=/dev/fd0
	elif test -c /dev/rfd0 ; then
		DEV=/dev/rfd0
	elif test -b /dev/floppy ; then
		DEV=/dev/floppy
	else
		echo "$0: unable to determine floppy drive device"
		echo "     ask for help on comp.os.qnx or from demodisk@qnx.com"
		exit 1
	fi
	CMDS="dd if=qnxdemo.dat of=$DEV"
	;;
esac

if test -w $DEV ; then
	$CMDS
else
	echo "$0: cannot write $DEV"
	exit 1
fi
