2016-07-21 14:58:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
USER="$1"
|
2016-07-21 19:29:32 +02:00
|
|
|
HDIR="{{ r_connector_usershome }}$USER"
|
|
|
|
logfile={{ smartgears_user_home }}/tomcat/logs/runuseradd.log
|
2016-10-20 20:10:56 +02:00
|
|
|
exec >> $logfile 2>&1
|
2016-07-21 19:29:32 +02:00
|
|
|
|
2016-07-21 14:58:46 +02:00
|
|
|
|
|
|
|
if [ -d $HDIR ] ; then
|
2016-10-20 20:10:56 +02:00
|
|
|
echo "user $HDIR dir exists"
|
2016-07-21 19:29:32 +02:00
|
|
|
exit 0
|
2016-07-21 14:58:46 +02:00
|
|
|
else
|
2016-07-21 19:29:32 +02:00
|
|
|
if id -u $USER >/dev/null 2>&1
|
|
|
|
then
|
2016-10-20 20:10:56 +02:00
|
|
|
echo "ldap user $USER first login"
|
|
|
|
sudo /bin/mkdir -p $HDIR
|
|
|
|
sudo /bin/chown -R $USER $HDIR
|
2016-07-21 19:29:32 +02:00
|
|
|
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
|
2016-10-20 20:10:56 +02:00
|
|
|
echo "user $USER does not exist and is not into ldap"
|
2016-07-21 19:29:32 +02:00
|
|
|
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
|
2016-10-20 20:10:56 +02:00
|
|
|
exit 0
|
2016-07-21 19:29:32 +02:00
|
|
|
fi
|
2016-07-21 14:58:46 +02:00
|
|
|
fi
|