| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #!/bin/bash
- . .env
- . funcs
- uid=$1
- if user_exists $uid; then
- true
- else
- echo "User $uid does not exist."
- exit 1
- fi
- user="dn: uid=%UID%,$PEOPLEDN
- changeType: modify
- add: objectClass
- objectClass: posixAccount
- -
- add: uidNumber
- uidNumber: %NUMBER%
- -
- add: gidNumber
- gidNumber: %NUMBER%
- -
- add: homeDirectory
- homeDirectory: /home/%UID%
- -
- add: loginShell
- loginShell: /bin/bash
- -
- add: objectClass
- objectClass: shadowAccount
- -
- add: objectClass
- objectClass: ldapPublicKey"
- group="dn: cn=%UID%,$GROUPSDN
- objectClass: top
- objectClass: posixGroup
- cn: %UID%
- gidNumber: %NUMBER%
- memberUid: %UID%"
- # get the list of currently used uid numbers and add 1 to get the next one
- uidnumber=get_posix_number
- # add the necessary attribbute for a posixAccount
- echo "$user" | sed \
- -e "s/%NUMBER%/$uidnumber/" \
- -e "s/%UID%/$uid/" | ldapmodify $LDAPOPTS
- # create a posix group with the same name and uid as the user
- # and add them to it
- echo "$group" | sed \
- -e "s/%NUMBER%/$uidnumber/" \
- -e "s/%UID%/$uid/" | ldapadd $LDAPOPTS
|