forked from ISTI-ansible-roles/ansible-roles
31 lines
933 B
Django/Jinja
Executable File
31 lines
933 B
Django/Jinja
Executable File
#!/bin/bash
|
|
|
|
USER="$1"
|
|
HDIR="{{ r_connector_usershome }}$USER"
|
|
logfile={{ smartgears_user_home }}/tomcat/logs/runuseradd.log
|
|
exec > $logfile 2>&1
|
|
|
|
|
|
if [ -d $HDIR ] ; then
|
|
#echo "user dir exist"
|
|
exit 0
|
|
else
|
|
if id -u $USER >/dev/null 2>&1
|
|
then
|
|
#"echo "ldap user first login"
|
|
sudo /bin/su - $USER /bin/ls
|
|
sudo /bin/chmod g+ws $HDIR
|
|
sudo /usr/bin/touch $HDIR/{{ r_connector_userconfig }}
|
|
sudo /bin/chmod 660 $HDIR/{{ r_connector_userconfig }}
|
|
sudo /bin/chgrp -R {{ smartgears_user }} $HDIR
|
|
exit 0
|
|
else
|
|
#echo "user does not exist and is not ldap"
|
|
sudo /usr/sbin/useradd -m -s /bin/false -g {{ smartgears_user }} $USER
|
|
sudo /bin/chmod g+ws $HDIR
|
|
sudo /usr/bin/touch $HDIR/{{ r_connector_userconfig }}
|
|
sudo /bin/chmod 660 $HDIR/{{ r_connector_userconfig }}
|
|
sudo /bin/chgrp -R {{ smartgears_user }} $HDIR
|
|
fi
|
|
fi
|