New Script -- run-parts
[pkgusr] / usr / sbin / groupadd
1 #!/bin/bash
2 # 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!
5
6 #
7 # This is a primitive script to serve as groupadd until the real groupadd
8 # has been installed. It has little error checking, so don't pass it anything
9 # stupid or it'll mess up your /etc/group file.
10 #
11
12 if [ $# -ne 3 -o z$1 != z-g ]; then
13     echo 1>&2 USAGE: groupadd -g gid groupname
14     exit 1
15 fi
16
17 #test if group already exists
18 grep "^${3}:.*" /etc/group 
19 if [ $? -eq 0 ]; then
20     echo 1>&2 $0: Group does already exist
21     exit 1
22 fi       
23
24 cp /etc/group /tmp/group123456
25 echo ${3}:x:${2}: | sort -t : -k3,3n -m /tmp/group123456 - > /etc/group
26