#!/bin/bash

if [ -z "$1" ]; then
	echo ""
    echo "Please append an RootFS-Imagefile:"
    echo "./remount.sh <imagefilename>"
    exit
else
	if [ -e "$1" ]; then
		echo " Stopping NFS-Kernel-Server"
		echo "----------------------------"
		sudo service nfs-kernel-server stop

		echo " Unmounting RootFS"
		echo "----------------------------"
		sudo umount /pollinux/nandfs

		echo " Mounting new RootFS"
		echo "----------------------------"
		sudo mount -t ext2 $1 /pollinux/nandfs -o loop

		echo "Restart NFS-Kernel-Server"
		sudo service nfs-kernel-server start
	else
		echo ""
		echo "Imagefile  \"$1\"  not found!"
		exit
	fi
fi
exit