summaryrefslogtreecommitdiff
path: root/usr.sbin/adduser/rmgroup.sh
blob: d2da83b4f55d23b5b15df4322e5f4c63c4faf18e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# $OpenBSD: rmgroup.sh,v 1.2 1998/07/16 16:47:41 millert Exp $
#
# Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# All rights reserved.
#
# rmgroup - delete a Unix group
#
# $From: rmgroup.sh,v 1.1 1996/10/30 20:58:47 wosch Exp $

PATH=/bin:/usr/bin; export PATH
db=/etc/group

case "$1" in
	""|-*)	echo "usage: rmgroup group"; exit 1;;
	wheel|daemon|kmem|sys|tty|operator|bin|nogroup|nobody)
		echo "Do not remove system group: $1"; exit 2;;
	*) group="$1";;
esac

if egrep -q -- "^$group:" $db; then
	if egrep -q -- "^$group:\*:0:" $db; then
		echo "Do not remove group with gid 0: $group"
		exit 2
	fi
	egrep -v -- "^$group:" $db > $db.new &&
		cp -pf $db $db.bak &&
		mv -f  $db.new $db
else 
	echo "Group \"$group\" does not exist in $db."; exit 1
fi