Koozali.org: home of the SME Server

can I change group name?

Sergei Slobodov

can I change group name?
« on: September 09, 2003, 10:39:26 AM »
I'm maintaining a school server where students/parent are grouped by grade, for easier broadcast email. Every year I need to move those in, say, "grade_8_parents" group to the "grade_9_parents" group, which involves manually going through hundreds of user accounts and painstakingly changing their groups.  I'm wondering if there is an easy way to simply rename the group "grade_8_parents" to "grade_9_parents" and so on? Any other solution would also be appreciated.

Thanks,
Sergei

Graeme Fleming

Re: can I change group name?
« Reply #1 on: September 09, 2003, 05:09:53 PM »
Wouldn't it be easier to use just Group1, Group2, etc and just update your master list (in say Excel) every year to reflect which group is which - all groups would have the same people in it every year and just the classification of the group would change.  Update the group description in SME to match the master Excel list.

Nice and simple and very little work :-)

Sergei Slobodov

Re: can I change group name?
« Reply #2 on: September 09, 2003, 08:16:27 PM »
I don't think it would work well. It's not me using the group addresses, it's the users. They are not going to maintain excel spreadsheets, they just want to reach their classmates. In the hindsite, I should have created pseudonyms (aliases) to fixed group names, and update the alias names only. However, I do need to rename groups now, and any easy solution would be appreciated.

Sergei

Maggard

Re: can I change group name?
« Reply #3 on: September 09, 2003, 08:58:41 PM »
The following up on Graeme's excellent suggestion, and since you have to update at least one more time anyhow, how about then using a fixed name like "Class of 2005", "Class of 2006", etc. Don't use a variable but go with a constant.

Yeah it might mean the parents have to update their address books. On the other hand they appear to have to every year anyway, might as well make it for a last time.

As to the specific mechanics I'd look up the e-smith command line server tools that were put together awhile ago (I can't find my link to 'em, perhaps someone else can point them out.) As I recall one could move users en masse with it.

Graeme Fleming

Re: can I change group name?
« Reply #4 on: September 09, 2003, 11:24:09 PM »
Check out the Lazy Admin tools on Contribs.org, they may be of some use

Sergei Slobodov

Re: can I change group name?
« Reply #5 on: September 10, 2003, 11:19:45 AM »
Thanks for the suggestion, Graeme! It looks like the lazy admin contrib has everything, but I couldn't find a way to simply rename a group... Or create a new group and include all the users from another group. Have I missed something?

Thanks,
Sergei

Graeme Fleming wrote:
>
> Check out the Lazy Admin tools on Contribs.org, they may be
> of some use

Graeme Fleming

Re: can I change group name?
« Reply #6 on: September 10, 2003, 10:21:50 PM »
Looks like your outta luck - you could of course request a mod to the LAT to do what you need.

My guess is you may well end up choosing the best option available from those presented as you can't do precisely what you want.

Good luck

Michiel

Re: can I change group name?
« Reply #7 on: September 11, 2003, 01:02:46 AM »
> Looks like your outta luck - you could of course request a
> mod to the LAT to do what you need.

No need for that. The following command will remove users from a group (you'll need LAT version 0.7.2 for that):

lat-groups -r -f -c="grade_8_parents | john | mary | will | etc"

and to add them to the next grade:

lat-groups -a -c="grade_9_parents | Grade 9 Year 2003 |  | john | mary | will | etc"

john, mary, will, etc must be valid users on the system. Please note also the empty field before the first user.

Michiel

Sergei Slobodov

Re: can I change group name?
« Reply #8 on: September 11, 2003, 09:28:34 AM »
OK, this is getting closer!

So I need a script that would do something like this:
- generate a list of users for a given group
- add users to the new group using the generated list

Can LAT do that?

Thanks,
Sergei

Michiel

Re: can I change group name?
« Reply #9 on: September 11, 2003, 12:46:20 PM »
The fastest way to move all members from one group to an other would be to manually edit /etc/groups and /home/e-smith/accounts. But this can be tricky and you better make a backup of those files first. The LAT tools would be a safer, but much sloooower approach

> So I need a script that would do something like this:
> - generate a list of users for a given group

db accounts getprop grade_8_parents Members | sed "s/\,/|/g" > /tmp/grade8.all

Or to move all members in one go:
#!/bin/bash
OLDCLASS="grade_8_parents"
NEWCLASS="grade_9_parents"
PUPILS=db accounts getprop $OLDCLASS Members | sed "s/\,/|/g"
/usr/sbin/lat-groups -a -c="$NEWCLASS | Some description | | $PUPILS"
/usr/sbin/lat-groups -r -c="$OLDCLASS | $PUPILS"

Michiel