2013-03-06 13:37:15 +01:00
|
|
|
#!/bin/bash
|
2013-03-13 13:35:15 +01:00
|
|
|
# $NetBSD: groupadd.sh,v 1.3 2013/03/13 12:35:16 obache Exp $
|
2013-03-06 13:37:15 +01:00
|
|
|
|
2013-03-12 06:41:39 +01:00
|
|
|
export PATH=/bin:"$(/bin/cygpath -S)"
|
2013-03-06 13:37:15 +01:00
|
|
|
|
|
|
|
show_usage () {
|
|
|
|
echo "usage: $0 [-v] group" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
verbose=false
|
|
|
|
run_cmd () {
|
2013-03-13 13:35:15 +01:00
|
|
|
if $verbose; then printf '%s\n' "+ $*" >&2; fi
|
2013-03-06 13:37:15 +01:00
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts 'g:ov' f; do
|
|
|
|
case $f in
|
|
|
|
g) echo "$0: numeric gid cannot be set manually; ignoring" >&2;;
|
|
|
|
o) echo "$0: cannot reuse numeric gid of another group; aborting" >&2; exit 1;;
|
|
|
|
v) verbose=true;;
|
|
|
|
\?) show_usage;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then show_usage; fi
|
|
|
|
$verbose || exec >/dev/null
|
|
|
|
|
|
|
|
run_cmd net localgroup $1 /add /comment:"Group added by Cygwin groupadd command" || exit 1
|
|
|
|
### regenerate cygwin /etc/group
|
2013-03-13 13:35:15 +01:00
|
|
|
run_cmd /bin/mkgroup -l -g "$1" >> /etc/group || exit 1
|