#!/bin/bash

source /etc/tos/scripts/scripts
umask 022
domain=$2
user=$3
homepath=$1

if [ -f "/etc/domain.config" ]; then
    ADS_STAT=$(iniparse -c -f /etc/domain.config -s domain -k connection_status)
    LDAP_STAT=$(iniparse -c -f /etc/domain.config -s ldap -k connection_status)
    if [ $ADS_STAT -eq 1 ]; then
	if [ ! -d $homepath ]; then
	    mkdir -p $homepath
	    chown -R $domain\\$user $homepath
	fi
    fi
    
    if [ $LDAP_STAT -eq 1 ]; then
	if [ ! -d ${homepath} ]; then
	    mkdir -p $homepath
	    chown -R $user $homepath
	fi
    fi
else
    exit 0
fi
