diff previous-work/more_control_helpers/sbin/groupadd @ 1:d6bef198ae71

add work by Matthias S. Benkmann which is the inspiration for this project.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 Jan 2013 11:45:01 +0000
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/previous-work/more_control_helpers/sbin/groupadd	Tue Jan 08 11:45:01 2013 +0000
     1.3 @@ -0,0 +1,26 @@
     1.4 +#!/bin/bash
     1.5 +# Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>
     1.6 +# You may do everything with this code except misrepresent its origin.
     1.7 +# PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
     1.8 +
     1.9 +#
    1.10 +# This is a primitive script to serve as groupadd until the real groupadd
    1.11 +# has been installed. It has little error checking, so don't pass it anything
    1.12 +# stupid or it'll mess up your /etc/group file.
    1.13 +#
    1.14 +
    1.15 +if [ $# -ne 3 -o z$1 != z-g ]; then
    1.16 +echo 1>&2 USAGE: groupadd -g gid groupname
    1.17 +exit 1
    1.18 +fi
    1.19 +
    1.20 +#test if group already exists
    1.21 +grep "^${3}:.*" /etc/group 
    1.22 +if [ $? -eq 0 ]; then
    1.23 +  echo 1>&2 $0: Group does already exist
    1.24 +  exit 1
    1.25 +fi       
    1.26 +
    1.27 +cp /etc/group /tmp/group123456
    1.28 +echo ${3}:x:${2}: | sort -t : -k3,3n -m /tmp/group123456 - > /etc/group
    1.29 +