#!/bin/sh /etc/rc.common
# Copyright (C) 2009 Ubicom, Inc.

if [ $action = "start" ]	
then
	echo "Mounting file systems"
	test -f /proc/meminfo || mount -t proc proc /proc
	mount -t devpts devpts /dev/pts

	# Make contents of /etc non-volatile to keep user settings permanently.
	mkdir /flash
	mount -t jffs2 /dev/mtdblock2 /flash
	if [ $? != 0 ]; then
		eraseall /dev/mtd2
		mount -t jffs2 /dev/mtdblock2 /flash
	fi

	# Create file for nvram
	touch /etc/nvram

	#Unionmount flash over romfs
	mount -t unionfs -o dirs=/flash=rw:/etc=ro none /etc

elif [ $action = "stop"	]
then
	echo "Unmounting file systems"
	umount proc
	umount devpts
fi
