#!/bin/sh
#
# rc.floppy
# Povides floppy access for a ltsp terminal
# Author: Cicero Mota
#
PATH=/bin:$PATH; export PATH
. /etc/ltsp_functions

################################################################
# Set up floppy access

FLOPPY=`get_cfg FLOPPY N`
if [ "${FLOPPY}" = "Y" ]; then
	LOCAL_APPS=`get_cfg LOCAL_APPS N`
	if [ "${LOCAL_APPS}" = "N" ]; then
		echo "Starting internet superdaemon: xinetd"
		if [ -f /usr/sbin/xinetd ]; then
			xinetd
		else
			echo "....fail"
			echo "It looks like xinetd is not installed."
			echo "xinetd is part of the ltsp_local_apps package."
			exit
		fi
	fi
  modprobe floppy
  chmod 666 /dev/fd0
  echo 'Starting nbd-server ...'
  while [ ! -f /tmp/nohup.out ]; do
  	echo -n >/tmp/nohup.out
  done;
  ln -sf /tmp/nohup.out /nohup.out;	
  nohup bash -c "while true; do nbd-server 1025 /dev/fd0; sleep 30; done" &
fi
