| Last change
 on this file since 292 was             206, checked in by Herwig Bauernfeind, 16 years ago | 
        
          | 
Import Samba 3.3 branch at 3.0.0 level (psmedley's port)
 | 
        
          | File size:
            739 bytes | 
      
      
| Line |  | 
|---|
| 1 | #!/bin/sh | 
|---|
| 2 |  | 
|---|
| 3 | # Example script for 'add group command'. Handle weird NT group | 
|---|
| 4 | # names. First attempt to create the group directly, if that fails | 
|---|
| 5 | # then create a random group and print the numeric group id. | 
|---|
| 6 | # | 
|---|
| 7 | # Note that this is only an example and assumes /dev/urandom. | 
|---|
| 8 | # | 
|---|
| 9 | # Volker | 
|---|
| 10 |  | 
|---|
| 11 | GROUPNAME="$1" | 
|---|
| 12 | ITERS=0 | 
|---|
| 13 |  | 
|---|
| 14 | while ! /usr/sbin/groupadd "$GROUPNAME" > /dev/null 2>&1 | 
|---|
| 15 | do | 
|---|
| 16 | # we had difficulties creating that group. Maybe the name was | 
|---|
| 17 | # too weird, or it already existed. Create a random name. | 
|---|
| 18 | GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5) | 
|---|
| 19 | ITERS=$(expr "$ITERS" + 1) | 
|---|
| 20 | if [ "$ITERS" -gt 10 ] | 
|---|
| 21 | then | 
|---|
| 22 | # Too many attempts | 
|---|
| 23 | exit 1 | 
|---|
| 24 | fi | 
|---|
| 25 | done | 
|---|
| 26 |  | 
|---|
| 27 | getent group | grep ^"$GROUPNAME": | cut -d : -f 3 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.