Mercurial > pkg
view previous-work/more_control_helpers/sbin/groupadd @ 1:d6bef198ae71
add work by Matthias S. Benkmann which is the inspiration for this project.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 08 Jan 2013 11:45:01 +0000 |
parents | |
children |
line wrap: on
line source
1 #!/bin/bash2 # Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>3 # You may do everything with this code except misrepresent its origin.4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!6 #7 # This is a primitive script to serve as groupadd until the real groupadd8 # has been installed. It has little error checking, so don't pass it anything9 # stupid or it'll mess up your /etc/group file.10 #12 if [ $# -ne 3 -o z$1 != z-g ]; then13 echo 1>&2 USAGE: groupadd -g gid groupname14 exit 115 fi17 #test if group already exists18 grep "^${3}:.*" /etc/group19 if [ $? -eq 0 ]; then20 echo 1>&2 $0: Group does already exist21 exit 122 fi24 cp /etc/group /tmp/group12345625 echo ${3}:x:${2}: | sort -t : -k3,3n -m /tmp/group123456 - > /etc/group