#!/bin/sh

ERR=0;

case "$1" in
    "start")
	ls -1 /home |grep -v root | \
	while read dir
	do
	    grep -sq $dir /etc/passwd
	    if [ $? -eq 0 ]
	    then
		uid=`grep $dir /etc/passwd | cut -d':' -f3`
		gid=`grep $dir /etc/passwd | cut -d':' -f4`
		chown -R $uid.$gid /home/$dir
	    fi
	done
	rm -f /etc/init.d/70owners
	;;
    "stop")
        exit 0;
        ;;
    *)
        echo "Syntax is $0 start | stop"
        exit 255;
        ;;
esac

exit ${ERR};

