util:datablob: data_blob_pad checks its alignment assumption
[samba.git] / source3 / script / creategroup
blob1e2486744a8576cefd0508627f38a900bc3bc102
1 #!/bin/sh
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.
7 # Note that this is only an example and assumes /dev/urandom.
9 # Volker
11 GROUPNAME="$1"
12 ITERS=0
14 while ! /usr/sbin/groupadd "$GROUPNAME" >/dev/null 2>&1; do
15 # we had difficulties creating that group. Maybe the name was
16 # too weird, or it already existed. Create a random name.
17 GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5)
18 ITERS=$(expr "$ITERS" + 1)
19 if [ "$ITERS" -gt 10 ]; then
20 # Too many attempts
21 exit 1
23 done
25 getent group | grep ^"$GROUPNAME": | cut -d : -f 3