#!/bin/sh

# Dylan McDonald for CIS 203
# Create the base NIS Home Directories
/bin/mkdir /home/nis
/bin/chown root.nis /home/nis
/bin/chmod 750 /home/nis

# Ssshhh! Don't let people know we're setting each pasword to 'password'.
echo password > /tmp/pass

# Start our counters and at nice numbers
i=0
j=1200
while [  $i -lt 25 ]; do
        # Start off by adding users to the passwd and shadow files
        echo nis$i:x:$j:110:NIS User $i:/home/nis/nis$i:/bin/bash >> /etc/yp/passwd
        echo nis$i:!!:11752:0:99999:7::: >> /etc/shadow
        /usr/bin/passwd --stdin nis$i < /tmp/pass
        
        # Create their home directory with nice permissions and files 
        /bin/mkdir /home/nis/nis$i
        /bin/cp /etc/skel/.bash* /home/nis/nis$i
        /bin/cp /etc/skel/.emacs /home/nis/nis$i
        /bin/cp /etc/skel/.gtkrc /home/nis/nis$i
        /bin/chmod 750 /home/nis/nis$i
        /bin/chown -R nis$i.nis /home/nis/nis$i

        # Keep the counters running!
        let j=j+1
        let i=i+1 
done

# Remove the ultra l33t password
/bin/rm -f /tmp/pass