summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocaladduser20
1 files changed, 18 insertions, 2 deletions
diff --git a/localadduser b/localadduser
index e3cd3a1..292608b 100755
--- a/localadduser
+++ b/localadduser
@@ -8,15 +8,31 @@
# Execute adduser noninteractively through sudo
#
# TODO: Check for bad arguments
-# TODO: Use getopts to offer help
+# TODO: Implement --help option
# TODO: Support overriding options in /etc/local file
#
set -e
+PRG=$(basename "$0")
+
+TEMP="`getopt -s sh -o vqin -l verbose,quiet,interactive,noninteractive,dry-run -n "$PRG" -- "$@"`"
+if [ $? != 0 ] ; then echo >&2 "ERROR: Internal getopt error." ; exit 1 ; fi
+eval set -- "$TEMP"
+
verbose=1
-#simulate=true
interactive=0
+while true ; do
+ case "$1" in
+ -v|--verbose) verbose=1; shift ;;
+ -q|--quiet) verbose=0; shift ;;
+ -i|--interactive) interactive=1; shift ;;
+ -n|--noninteractive) interactive=0; shift ;;
+ --dry-run) simulate=true; shift ;;
+ --) shift ; break ;;
+ *) echo >&2 "ERROR: Internal error resolving options." ; exit 1 ;;
+ esac
+done
# echo something, but only if in verbose mode
vecho() {