#! /bin/sh #---------------------------------------------------------------------------- # add-group - add a group # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-2010 the eisfair team, team(at)eisfair(dot)org # # usage: add-group # or: add-group group gid # # 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. #---------------------------------------------------------------------------- . /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" then clrhome mecho --info "Add group" echo fi if [ -z "$gid" ] then 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 case "$group" in ?????????*) echo mecho --warn "name of group is too long" ;; "") mecho --warn "no group added" ;; *) grep "^$group:" /etc/group >/dev/null if [ $? = 0 ] then echo mecho --warn "group $group already exists" else echo "$group:x:$gid:" >>/etc/group fi ;; esac if "$interactive" then echo anykey fi