#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/add-group - add a group # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # usage: add-group # or: add-group group gid # # 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 case $# in 0) interactive='true' group="" gid="" ;; 1) interactive='false' group="$1" gid="" ;; 2) interactive='false' group="$1" gid="$2" ;; *) echo "usage: `basename $0`" >&2 echo " or: `basename $0` group gid" >&2 exit 1 ;; esac if [ "$interactive" = "true" ] then clrhome mecho -info "Add group" echo fi if [ "$gid" = "" ] then oldifs="$IFS" IFS=':' gid=200 while read line do set -- $line if [ $3 -gt $gid -a $3 -lt 300 ] then gid=$3 fi done /tmp/ask.$$ rc=$? group=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi fi echo case "$group" in ?????????*) mecho -warn "name of group is too long" echo anykey exit 1 ;; "") mecho -warn "no group added" echo anykey exit 1 ;; *) grep "^$group:" /etc/group >/dev/null if [ $? = 0 ] then mecho -warn "group $group already exists" echo anykey exit 1 else /usr/sbin/groupadd -g "$gid" "$group" fi ;; esac if [ "$interactive" = "true" ] then echo anykey fi