#!/bin/sh
# <BEGIN COPYRIGHT>
# This file is part of the "Bad Penguin" GNU/Linux distribution
# Copyright (C) 1997-98-99 by Antonio GALLO
# Home Page at ......: http://www.badpenguin.org
# Home Page at ......: http://www.linux.it/~agx/
# e-mail contact ....: mailto:agx@linux.it	mailto:agx@geocities.com
# This program is distributed under the GNU General Public License
# You are not allowed to remove the copyright notice
# <END COPYRIGHT>

# Check if the floppy is already mounted then umount it
# 1.0.0 by agx@linux.it 

mount | grep -q floppy
if [ $? -eq 0 ]; then
  umount /floppy
  if [ $? -eq 0 ]; then
    echoc GREEN "Il precedente floppy e' stato smontato."
  else
    echoc YELLOW "Unable to unmount the previous floppy"
    # I don't want exit with this error, so i used yellow warning instead of red
  fi
  echoc YELLOW "Per favore, togli il floppy ed inseriscine un'altro ... quindi premi INVIO"
else
  echoc CYAN "Per favore, inserisci il floppy quindi premi INVIO"
fi
read x

mount -t ext2 /dev/fd0 /floppy 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
  mount -t vfat /dev/fd0 /floppy -o noexec 2>/dev/null 1>/dev/null
  if [ $? -ne 0 ]; then
    mount -t msdos /dev/fd0 /floppy -o noexec 2>/dev/null 1>/dev/null
    if [ $? -ne 0 ]; then
      echoc RED "Spiacente, il floppy non contiene un valido filesystem !"
      exit 1
    fi
  fi
fi
echoc GREEN "Floppy mountato."
exit 0
