diff options
author | Guillaume Rousse <guillomovitch@mandriva.org> | 2009-03-29 17:54:26 +0000 |
---|---|---|
committer | Guillaume Rousse <guillomovitch@mandriva.org> | 2009-03-29 17:54:26 +0000 |
commit | d7e965af2545b4a3783b652d15fb74b4abca662b (patch) | |
tree | 3f80d5199eb062eb18b4262fac8646325560c640 /add-group | |
parent | 0fc0ce3e353bba96cb46d1589a3cf1cc2f932209 (diff) | |
download | rpm-helper-d7e965af2545b4a3783b652d15fb74b4abca662b.tar rpm-helper-d7e965af2545b4a3783b652d15fb74b4abca662b.tar.gz rpm-helper-d7e965af2545b4a3783b652d15fb74b4abca662b.tar.bz2 rpm-helper-d7e965af2545b4a3783b652d15fb74b4abca662b.tar.xz rpm-helper-d7e965af2545b4a3783b652d15fb74b4abca662b.zip |
only add user or group if not already existing
Diffstat (limited to 'add-group')
-rwxr-xr-x | add-group | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -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 |