#!/bin/sh #---------------------------------------------------------------------------- # add-group - add a group # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ 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 oldifs=${IFS} gid=200 while read line do IFS=':' set -- ${line} if [ ${3} -gt ${gid} -a ${3} -lt 300 ] then gid=${3} fi IFS="${oldifs}" done ${_ask_tmpfile} rc=${?} read group < ${_ask_tmpfile} rm -f ${_ask_tmpfile} if [ ${rc} = 255 ] then exit 1 fi fi case "${group}" in '') mecho --warn "no group added" ;; *) if [ "${#group}" -gt 32 ] then echo mecho --warn "name of group is too long" elif getent group "${group}" >/dev/null then echo mecho -n --warn 'group ' mecho -n --std "'${group}' " mecho --warn 'already exists' else /usr/sbin/groupadd -g "${gid}" "${group}" fi ;; esac if "${interactive}" then echo anykey fi