#!/bin/bash
#
# $1 is username
# $2 is ldap uid

g="hmc"

if [ ! -d /home/$1 ]
then
   mkdir /home/$1
   chown "$2"."$g" /home/$1
   chmod 755 /home/$1
fi

if [ ! -d /home/$1/.ssh ]
then
   mkdir /home/$1/.ssh
fi
chmod 755 /home/$1/.ssh
chown root."$g" /home/$1/.ssh
if [ ! -f /home/"$1"/.ssh/authorized_keys2 ]
then
  touch /home/"$1"/.ssh/authorized_keys2
  chown "$2"."$g" /home/"$1"/.ssh/authorized_keys2
  chmod 644 /home/"$1"/.ssh/authorized_keys2
fi

cp /opt/hsc/data/ssh/bashrc /home/$1/.bashrc
chmod 555 /home/$1/.bashrc
chown root.root /home/$1/.bashrc
cp /opt/hsc/data/ssh/hmcprofile /home/$1/.bash_profile
chmod 555 /home/$1/.bash_profile
chown root.root /home/$1/.bash_profile

if [ ! -d /home/$1/.fonts ]
then
   mkdir /home/$1/.fonts
   chown "$2"."$g" /home/$1/.fonts
   chmod 755 /home/$1/.fonts
fi

exit 0
