[K12OSN] OT: Help with Template User Script
Peter Hartmann
ascensiontech at gmail.com
Mon Nov 26 22:15:09 UTC 2007
Eric sent this beauty out a while back when I was stuck.
-Peter
version 0.4:
getent passwd | awk -F: '$3>500 {print $3, $4, $6}' | while read u g h
do
chown -R $u:$g "$h"
done
"cat /etc/passwd" assumes that your users are in /etc/passwd. If you
your users in LDAP, AD, radius, etc, etc, you can't grep for them
in /etc/passwd...
"getent passwd" will output what you would expect to find in /etc/passwd,
even though the users may be in LDAP, WinBind, /etc/passwod, and/or any
other possible way the system may do authentication/authorization ;-)
-Eric
On Nov 26, 2007 4:59 PM, R. Scott Belford <scott at hosef.org> wrote:
> In the interest of being able to make a template user whose settings can
> be extracted to existing users, we have come up with a few scripts.
> Things appear to work, however, the teacher reports that a some users'
> permissions are not reset properly. I wonder if any of you could advise
> if this is a script syntax issue, or if we should be looking elsewhere
> for the answer. If nothing else, perhaps this is helpful for some
> looking to do something similar.
>
> respect
>
> --scott
>
>
>
> #!/bin/bash
>
> #Make template user, tar, extract, change permissions
>
> # settings
> BASE_HOME_DIR=/home/students
> TEMPLATE_FILE=/home/students/template/template.tar.gz
> BASE_TEMPLATE_DIR=/home/students/template
>
> cd ${BASE_TEMPLATE_DIR}
>
> tar -cvzf template.tar.gz * .[a-zA-Z0-9]*
>
> cd ${BASE_HOME_DIR}
> for USER in `ls`
> do
> echo 'Extracting for user:' ${USER}
> cd ${BASE_HOME_DIR}/${USER}
> tar -zxvf ${TEMPLATE_FILE}
> chown -fR ${USER}:Domain\ Users * .[^.]*
> done
>
>
> and, because I have not conveniently determined a way to update
> permissions and ownerships of hidden files within the user's directory
> as well as well as of the users' directories themselves, I run this next
>
>
> #!/bin/bash
>
> # change permissions of users' directories
>
> # settings
> BASE_HOME_DIR=/home/students
>
> cd ${BASE_HOME_DIR}
> for USER in `ls`
> do
> chown ${USER}:Domain\ Users ${USER}
> done
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>
More information about the K12OSN
mailing list