#! /bin/sh #---------------------------------------------------------------------------- # remove-group - remove a group # # Copyright (c) 2001-2004 Frank Meyer # # usage: remove-group [-f] [group] # # Creation: 04.11.2001 fm # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib if [ "$1" = "-f" ] then force=true shift else force=false fi case $# in 0) interactive='true' group="" ;; 1) interactive='false' group="$1" ;; *) mecho "usage: $0 [group]" >&2 exit 1 ;; esac if [ "$interactive" = "true" ] then clrhome mecho -info "Remove group" echo tty=`tty` mecho -n "Group to remove (e.g. 'www'): \c" read group if [ "$group" = "" ] then mecho anykey exit 1 fi fi line=`grep "^$group:" /etc/group` if [ "$line" = "" ] then if [ "$interactive" = "true" ] then echo mecho -error "Group $group does not exist" echo anykey else mecho "Group $group does not exist" >&2 fi exit 1 fi oldifs="$IFS" IFS=':' set -- $line gid=$3 IFS="$oldifs" if [ $force = false ] then if [ $gid -lt 200 -o $gid -ge 65534 ] then if [ "$interactive" = "true" ] then echo mecho -error "It is not allowed to remove group $group, sorry" echo anykey else mecho "It is not allowed to remove group $group, sorry" >&2 fi exit 1 fi fi while read line do IFS=':' set -- $line g="$4" IFS="$oldifs" if [ $g = $gid ] then if [ "$interactive" = "true" ] then echo mecho -error "Cannot remove group $group, user $1 is member of $group" echo anykey <$tty else mecho -error "Cannot remove group $group, user $1 is member of $group" >&2 fi exit 0 fi done