#!/bin/sh #---------------------------------------------------------------------------- # remove-group - remove a group # # usage: remove-group [-f] [group] # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # 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 #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi ASK=/var/install/bin/ask MKTEMP=/usr/bin/mktemp RM=/usr/bin/rm GREP=/usr/bin/grep GROUPDEL=/usr/sbin/groupdel #---------------------------------------------------------------------------- # usage #---------------------------------------------------------------------------- usage() { cat <&2 fi } #---------------------------------------------------------------------------- # remove groupn #---------------------------------------------------------------------------- remove_group() { group=${1} if "${interactive}" then clrhome mecho --info "Remove group" mecho mecho _ask_tmpfile=$(${MKTEMP} -t XXXXXXXXXXXXX) ${ASK} "Group to remove (e.g. 'www'): " '' '*' >${_ask_tmpfile} rc=${?} read group < ${_ask_tmpfile} ${RM} -f ${_ask_tmpfile} if [ ${rc} = 255 ] then exit 1 fi fi if [ -z "${group}" ] then mecho myecho --warn "Command aborted" do_exit 1 fi line=$(${GREP} "^${group}:" /etc/group) if [ -z "${line}" ] then mecho myecho --error "Group ${group} does not exist" do_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 mecho myecho --error "It is not allowed to remove group ${group}, sorry" do_exit 1 fi fi while read line do IFS=':' set -- ${line} g="${4}" IFS="${oldifs}" if [ ${g} = ${gid} ] then mecho myecho --error "Cannot remove group ${group}, user ${1} is member of ${group}" do_exit 1 fi done