#!/bin/sh 

usage(){
   echo "$0 username(s)"
   exit
}


if [ $# -lt 1 ]; then
  usage
fi

while [ "$1.x" != ".x" ]; do
    user=$1
    home=`grep $user /etc/passwd | cut -f6 -d':'`
    gid=`grep $user /etc/passwd | cut -f4 -d':'`
    group=`grep ":$gid:" /etc/group | head -n1 | cut -f1 -d':'`
    # echo "gid:$gid, group:$group"
    echo "modifing $user's local configuration"
    cd $home
    for i in .bash_login .bashrc .login .tcshrc .zlogin .zshrc ; do
        if [ -f $i ]; then
            rm $i
            cp /etc/template/Source/$i .
            chown $user.$group $i 
        fi
    done
    shift
done
