summaryrefslogtreecommitdiff
path: root/system/adelie-base/addgroup
blob: 27a523d7555d89e24eec8a74a80cde76a8f43e81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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