#! /bin/sh
#
# umountfs	Turn off swap and unmount all local file systems.
#
# Version:      @(#)umountfs  2.85-16  03-Jun-2004  miquels@cistron.nl
#
# chkconfig: 06 40 0
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
# Workaround for UFS910 14W
model=`cat /etc/model`
if [ "$model" == "ufs910" ]; then
	var=`cat /proc/boxtype`
	if [ "$var" == "1" ] || [ "$var" == "3" ]; then
		/usr/bin/lircd
		/bin/evremote2 &
	fi
fi
 
# Workaround for Flash Image
if [ -e /mnt/settings/timers.xml ]; then
	timers=`cat /mnt/settings/timers.xml`
	vdstandby=`cat /var/etc/vdstandby.cfg`
fi
 

echo -n "Deactivating swap..."
umount -ttmpfs -a -r
swapoff -a
echo "done."

#
#	Umount all filesystems except the virtual ones.
#
echo -n "Unmounting local filesystems..."
umount -tnoproc,noprocfs,nodevfs,nosysfs,nousbfs,nousbdevfs,nodevpts,novar -d -a -r
echo "done."

# This is superfluous.
mount -n -o remount,ro /
 
# Workaround for Flash Image
if [ -e /tmp ]; then
	mount -ttmpfs tmpfs /tmp
	echo -e "$timers" > /tmp/timers.xml
	echo -e "$vdstandby" > /tmp/vdstandby.cfg
fi
 

: exit 0
