aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xadd-group28
-rwxr-xr-xadd-user5
2 files changed, 19 insertions, 14 deletions
diff --git a/add-group b/add-group
index 2867c90..ea9e920 100755
--- a/add-group
+++ b/add-group
@@ -20,21 +20,23 @@ num=$2 # number of packages installed
name=$3 # name of the group
users=$4 # users to add to this group
-/usr/sbin/groupadd -r $name > /dev/null
+if ! getent group $name /dev/null 2>&1; then
+ /usr/sbin/groupadd -r $name > /dev/null
-if [ -n "$users" ]; then
- SAVED_IFS="$IFS"
- export IFS="$IFS",
- set $users
- IFS="$SAVED_IFS"
+ if [ -n "$users" ]; then
+ SAVED_IFS="$IFS"
+ export IFS="$IFS",
+ set $users
+ IFS="$SAVED_IFS"
- for u in $*; do
- old=`egrep "[:,]$u(,|$)" /etc/group | cut -d : -f 1 | xargs echo`
- if [ -n "$old" ]; then
- old=`echo ",$old" | sed 's/ /,/g'`
- fi
- /usr/sbin/usermod -G $name$old $u > /dev/null
- done
+ for u in $*; do
+ old=`egrep "[:,]$u(,|$)" /etc/group | cut -d : -f 1 | xargs echo`
+ if [ -n "$old" ]; then
+ old=`echo ",$old" | sed 's/ /,/g'`
+ fi
+ /usr/sbin/usermod -G $name$old $u > /dev/null
+ done
+ fi
fi
exit 0
diff --git a/add-user b/add-user
index 563b105..4b761e2 100755
--- a/add-user
+++ b/add-user
@@ -21,7 +21,10 @@ name=$3 # name of the user
dir=$4 # home directory
shell=$5 # shell
-/usr/sbin/useradd -r -M -s $shell -d $dir -c "system user for $pkg" $name > /dev/null
+if ! id $name /dev/null 2>&1; then
+ /usr/sbin/useradd -r -M \
+ -s $shell -d $dir -c "system user for $pkg" $name > /dev/null
+fi
exit 0