#!/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 $HDIR dir exists" exit 0 else if id -u $USER >/dev/null 2>&1 then echo "ldap user $USER first login" sudo /bin/mkdir -p $HDIR sudo /bin/chown -R $USER $HDIR 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 $USER does not exist and is not into 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 exit 0 fi fi