d4science-ghn-cluster: library/roles/smartgears/r_connector: fix the r_connector script that manages the users. Added the required commands to the sudoers file.

This commit is contained in:
Andrea Dell'Amico 2016-10-20 20:10:56 +02:00
parent b557e575f5
commit 188e4d1079
1 changed files with 7 additions and 5 deletions

View File

@ -3,28 +3,30 @@
USER="$1"
HDIR="{{ r_connector_usershome }}$USER"
logfile={{ smartgears_user_home }}/tomcat/logs/runuseradd.log
exec > $logfile 2>&1
exec >> $logfile 2>&1
if [ -d $HDIR ] ; then
#echo "user dir exist"
echo "user $HDIR dir exists"
exit 0
else
if id -u $USER >/dev/null 2>&1
then
#"echo "ldap user first login"
sudo /bin/su - $USER /bin/ls
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 does not exist and is not ldap"
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