File "mkhomedir.sh"
Full path: /www/wwwroot/fabriciovc.eti.br/downloads/ldap/mkhomedir.sh
File size: 786 B
MIME-type: text/x-shellscript
Charset: utf-8
#!/bin/bash
# -- Variaveis de comando --
AWK=$(which awk)
CHMOD=$(which chmod)
CHOWN=$(which chown)
FIND=$(which find)
GREP=$(which grep)
LDAPSEARCH=$(which ldapsearch)
MKDIR=$(which mkdir)
# -- Variaveis de caminhos --
HOMEDIR="/srv/usuarios"
# -- Obtendo a lista de usuarios --
USERS=$(${LDAPSEARCH} -x uid=* | ${GREP} "uid:" | ${GREP} -v '\$' | ${GREP} -v root | ${AWK} '{ print $2 }')
# -- Criando os diretorios dos usuarios se nao existir --
for USER in ${USERS}
do
if [ ! -d "${HOMEDIR}/${USER}" ]; then
${MKDIR} -p ${HOMEDIR}/${USER}
fi
${CHOWN} -R ${USER}:smb-informatica ${HOMEDIR}/${USER}
${FIND} ${HOMEDIR}/${USER}/ -type d -exec chmod 775 {} \;
${FIND} ${HOMEDIR}/${USER}/ -type f -exec chmod 664 {} \;
${CHMOD} 770 ${HOMEDIR}/${USER}
done
# -- Feito --
exit 0