summaryrefslogtreecommitdiff
path: root/localadduser
diff options
context:
space:
mode:
Diffstat (limited to 'localadduser')
-rwxr-xr-xlocaladduser9
1 files changed, 6 insertions, 3 deletions
diff --git a/localadduser b/localadduser
index 213d4d9..576714b 100755
--- a/localadduser
+++ b/localadduser
@@ -120,12 +120,15 @@ if [ ! "$interactive" -gt 0 ]; then
quiet="--quiet"
fi
+sudo=sudo
+[ "$(id -u)" -ne 0 ] || sudo=
+
# adduser is too pessimistic on --gecos size
-eval $simulate sudo "/usr/sbin/adduser $quiet --disabled-login --gecos \"\" \"$u\""
-eval $simulate sudo "/usr/sbin/usermod -c \"$fullname,$office,$office_phone,$home_phone,$other\" \"$u\""
+eval $simulate $sudo "/usr/sbin/adduser $quiet --disabled-login --gecos \"\" \"$u\""
+eval $simulate $sudo "/usr/sbin/usermod -c \"$fullname,$office,$office_phone,$home_phone,$other\" \"$u\""
for group in $groups; do
- eval $simulate sudo "/usr/sbin/adduser $quiet \"$u\" \"$group\""
+ eval $simulate $sudo "/usr/sbin/adduser $quiet \"$u\" \"$group\""
done
eval $simulate localresetpasswd "$u"