summaryrefslogtreecommitdiff
path: root/localadduser
diff options
context:
space:
mode:
Diffstat (limited to 'localadduser')
-rwxr-xr-xlocaladduser18
1 files changed, 10 insertions, 8 deletions
diff --git a/localadduser b/localadduser
index 010afe6..4d62ed4 100755
--- a/localadduser
+++ b/localadduser
@@ -23,6 +23,12 @@ vecho() {
test -n "$verbose" && echo "$@" >&2
}
+exit1() {
+ response="${1:+Error: }${1:-Internal error!}"
+ echo "$response"
+ exit 1
+}
+
u=$1
shift
@@ -36,12 +42,10 @@ for chunk in $@; do
;;
0*|1*|2*|3*|4*|5*|6*|7*|8*|9*)
if [ -z "$phone_area" ]; then
- echo "E: Phone number provided without leading area code" >&2
- exit 1
+ exit1 "Phone number provided without leading area code!"
fi
if [ -n "$home_phone" ]; then
- echo "E: More than 2 phone numbers provided" >&2
- exit 1
+ exit1 "More than 2 phone numbers provided!"
elif [ -n "$office_phone" ]; then
office_phone="$phone_area $chunk"
else
@@ -56,8 +60,7 @@ for chunk in $@; do
done
if [ -n "$phone_area" ]; then
- echo "E: Area code provided without trailing phonenumber" >&2
- exit 1
+ exit1 "Area code provided without trailing phonenumber!"
fi
if [ ! "$interactive" -gt 0 ]; then
@@ -67,8 +70,7 @@ if [ -n "$fullname$office_phone$home_phone$other" ]; then
eval $simulate sudo "/usr/sbin/adduser $quiet --disabled-login --gecos \"$fullname,,$office_phone,$home_phone,$other\" \"$u\""
else
if [ ! "$interactive" -gt 0 ]; then
- echo "E: Not enough info provided to create account for \"$u\"" >&2
- exit 1
+ exit1 "Not enough info provided to create account for \"$u\"!"
fi
eval $simulate sudo "/usr/sbin/adduser --disabled-login \"$u\""
fi