2007-06-08 15:41:12 +00:00
|
|
|
cat "$2" | while true; do
|
|
|
|
read name || break
|
|
|
|
read gid
|
|
|
|
|
|
|
|
if ! curEnt=$(getent group "$name"); then
|
|
|
|
echo "creating group $name..."
|
|
|
|
groupadd --system \
|
|
|
|
"$name" \
|
|
|
|
${gid:+--gid $gid}
|
|
|
|
else
|
2008-02-05 14:33:21 +00:00
|
|
|
#echo "updating group $name..."
|
2007-06-08 15:41:12 +00:00
|
|
|
oldIFS="$IFS"; IFS=:; set -- $curEnt; IFS="$oldIFS"
|
|
|
|
prevGid=$3
|
2007-11-19 16:56:40 +00:00
|
|
|
if test -n "$gid" -a "$prevGid" != "$gid"; then
|
2007-06-08 15:41:12 +00:00
|
|
|
groupmod "$name" --gid $gid
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
cat "$1" | while true; do
|
|
|
|
read name || break
|
|
|
|
read description
|
|
|
|
read uid
|
|
|
|
read group
|
|
|
|
read extraGroups
|
|
|
|
read home
|
|
|
|
read shell
|
2007-11-16 13:26:34 +00:00
|
|
|
read createHome
|
2007-06-08 15:41:12 +00:00
|
|
|
|
|
|
|
if ! curEnt=$(getent passwd "$name"); then
|
|
|
|
echo "creating user $name..."
|
|
|
|
useradd --system \
|
|
|
|
"$name" \
|
|
|
|
--comment "$description" \
|
|
|
|
${uid:+--uid $uid} \
|
|
|
|
--gid "$group" \
|
|
|
|
--groups "$extraGroups" \
|
|
|
|
--home "$home" \
|
2007-11-16 13:26:34 +00:00
|
|
|
--shell "$shell" \
|
|
|
|
${createHome:+--create-home}
|
2007-06-08 15:41:12 +00:00
|
|
|
else
|
2008-02-05 14:33:21 +00:00
|
|
|
#echo "updating user $name..."
|
2007-06-08 15:41:12 +00:00
|
|
|
oldIFS="$IFS"; IFS=:; set -- $curEnt; IFS="$oldIFS"
|
|
|
|
prevUid=$3
|
|
|
|
prevHome=$6
|
|
|
|
# Don't change the UID if it's the same, otherwise usermod
|
|
|
|
# will complain.
|
|
|
|
if test "$prevUid" = "$uid"; then unset uid; fi
|
|
|
|
# Don't change the home directory if it's the same to prevent
|
|
|
|
# unnecessary warnings about logged in users.
|
|
|
|
if test "$prevHome" = "$home"; then unset home; fi
|
|
|
|
usermod \
|
|
|
|
"$name" \
|
|
|
|
--comment "$description" \
|
|
|
|
${uid:+--uid $uid} \
|
|
|
|
--gid "$group" \
|
|
|
|
--groups "$extraGroups" \
|
|
|
|
${home:+--home "$home"} \
|
|
|
|
--shell "$shell"
|
|
|
|
fi
|
|
|
|
done
|