FNNDSC / projectman

FNNDSC project manager
3 stars 0 forks source link

neuro-adduser.sh needs to be fixed #93

Closed jbernal0019 closed 9 years ago

jbernal0019 commented 9 years ago

The script is assigning id 10000 to any newly created user.

NicolasRannou commented 9 years ago

@jbernal0019 can you just tell me on which machine, as which user you tried to run it?

Also, do you remember when was the last time you used it successfully?

jbernal0019 commented 9 years ago

I did the typical process: ssh fnndsc@fnndsc sudo bash cd /neuro ... to where ./neuro-adduser.sh -u username -g gaab

I can't seem to remember when it worked properly last time <-(

NicolasRannou commented 9 years ago

@jbernal0019 thanks!

NicolasRannou commented 9 years ago

https://github.com/FNNDSC/scripts/blob/master/neuro-adduser.sh

NicolasRannou commented 9 years ago

issue is there: https://github.com/FNNDSC/scripts/blob/master/neuro-adduser.sh#L132

@rudolphpienaar do you know on the top of your hear how to fix that? The sort -nk2 is ordering uids as below: 0 10000 10001 ... 9999

whereas we would like 10000 to appears after 9999.

NicolasRannou commented 9 years ago

I guess one soultion is to enforce the same number of decimals for each number..

NicolasRannou commented 9 years ago

[fnndsc@fnndsc:x86_64-Linux]~$>ldapsearch -b "dc=fnndsc" -D "cn=admin,dc=fnndsc" -W -h fnndsc | grep uidNumber | awk '{print $2 | "sort -nk2"}'

NicolasRannou commented 9 years ago

ldapsearch -b "dc=fnndsc" -D "cn=admin,dc=fnndsc" -W -h fnndsc | grep uidNumber | awk '{print $2 | "sort -n"}'

seems to work.

@rudolphpienaar do you know if -k2 is needed?

rudolphpienaar commented 9 years ago

Hi Nico --

Sorry, only saw this now.

Yes, this what I would do:

ldapsearch -b "dc=fnndsc" -D "cn=admin,dc=fnndsc" -W -h fnndsc | grep uidNumber | awk '{print $2 | "sort -n -k 1"}'

for the sort:

-n : sort in numeric order -k 1 : sort on the data in key 1, i.e. the first column, which is actually superfluous since there is only one column.

The -k2 would sort on the second (non existent) column, so it defaults I think to a string sort on the only data it has. Just by pure blind luck this worked until now.

rudolphpienaar commented 9 years ago

Source fixed and committed. Hopefully this will fix the script.