#! /bin/sh

NFSROOTDIR=/mnt/nfsroot

if [ -r /etc/nfsbooted/mountfix.conf ] ; then
    . /etc/nfsbooted/mountfix.conf
fi

case "$1" in
    'start')
    TMPDIRS=$(mount | grep ramfs | sed -e "s|.*on ||;s| .*||;")
    
    for TD in $TMPDIRS ; do
	find $NFSROOTDIR$TD -type d -printf "%m %u %g %p\n" | sed -e "s|$NFSROOTDIR||;" \
	    | while read MODE OWN GRP CPATH ; do
	    mkdir -p $CPATH
	    chown $OWN.$GRP $CPATH
	    chmod $MODE $CPATH
	done
    done
    ;;
    'stop')
    ;;
    'restart')
	$0 stop
	$0 start
    ;;
    'force-reload')
	$0 stop
	$0 start
    ;;
    *)
    ;;
esac
