Adding New Users
Example:
root@sekhmet> /home/simonh/sbin/newuser.bash mpciish2
- Grabs user's uid and gid from ITS LDAP.
- Creates user account and makes home-dir with the above uid/gid.
- Adds user to fuse group so that they can use sshfs to mount
their Danzek (CSF) home-dir.
The newuser.bash Script:
#!/bin/bash
#
# -- get uid from ldap
#
uid=`ldapsearch -x -h ldap.manchester.ac.uk "cn=$1" | grep uidNumber | awk '{print $2}'`
echo "Gonna use UID: $uid"
#
# -- get gid from ldap
#
gid=`ldapsearch -x -h ldap.manchester.ac.uk "cn=$1" | grep gidNumber | awk '{print $2}'`
echo "Gonna use GID: $gid"
#
# -- useradd
#
echo "useradd -u $uid -g $gid -s /bin/bash $1"
useradd -u $uid -g $gid -s /bin/bash $1
#
# -- mkdir home dir
#
echo "mkdir /home/$1"
mkdir /home/$1
#
echo "chown $1 /home/$1"
chown $1 /home/$1
chgrp $gid /home/$1
#
# -- add to fuse group
#
echo "usermod -a -G fuse $i"
usermod -a -G fuse $1