summaryrefslogblamecommitdiff
path: root/addgroup
blob: 051df3696acf27c7aa3788fedd0593a301b6ef02 (plain) (tree)



































                                                           
#!/bin/sh
# addgroup - BusyBox compatibility shim
# bbshim
# 
# Copyright © 2017 A. Wilcox.  All rights reserved.
# Licensed under the terms of the NCSA Open Source license.
#

ARG=
CMDLINE=

while getopts :g:S ARG
do
    case $ARG in
        g)  CMDLINE="$CMDLINE -g \"$OPTARG\"" ;;
        S)  CMDLINE="$CMDLINE -r" ;;
        :)  exit 1 ;;
        \?) exit 1 ;;
    esac
done

shift $(($OPTIND - 1))

if [ -z "$*" ]; then
    echo "$0: group name is required" >&2
    exit 1
fi

set "$@"


if [ -n "$2" ]; then
    exec usermod -a -G $2 $1
fi

groupadd $CMDLINE $1