]> git.cameronkatri.com Git - pw-darwin.git/blob - adduser/rmgroup.sh
rmgroup - delete a Unix group
[pw-darwin.git] / adduser / rmgroup.sh
1 #!/bin/sh
2 # Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
3 # All rights reserved.
4 #
5 # rmgroup - delete a Unix group
6 #
7 # $Id: rmgroup.sh,v 1.1 1996/10/30 20:41:17 wosch Exp wosch $
8
9 PATH=/bin:/usr/bin; export PATH
10 db=/etc/group
11
12 case "$1" in
13 ""|-*) echo "usage: rmgroup group"; exit 1;;
14 wheel|daemon|kmem|sys|tty|operator|bin|nogroup|nobody)
15 echo "Do not remove system group: $1"; exit 2;;
16 *) group="$1";;
17 esac
18
19 if egrep -q -- "^$group:" $db; then
20 if egrep -q -- "^$group:\*:0:" $db; then
21 echo "Do not remove group with gid 0: $group"
22 exit 2
23 fi
24 egrep -v -- "^$group:" $db > $db.new &&
25 cp -pf $db $db.bak &&
26 mv -f $db.new $db
27 else
28 echo "Group \"$group\" does not exists in $db."; exit 1
29 fi