#! /bin/sh #---------------------------------------------------------------------------- # add-user-to-additional-group - add user to additional group # # Copyright (c) 2001-2003 Frank Meyer # # Creation: 20.07.2003 fm # Last Update: 20.07.2003 fm # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- clrhome colecho "Add user to additional group" gn echo tty=`tty` echo echo echo -e "User: \c" read user IFS=':' if [ "$user" != "" ] then echo line=`grep "^$user:" /etc/passwd` if [ "$line" != "" ] then groups='' free_groups='' IFS=':' while read line do set -- $line g="$1" u="$4" IFS=',' set -- $u group_found=false for j in $* do if [ $j = $user ] then group_found=true break fi done if [ $group_found = true ] then groups="$groups "$g else free_groups="$free_groups "$g fi IFS=':' done /etc/group-$$ cp /etc/group /etc/group.old # save old group file cp /etc/group-$$ /etc/group # keep permissions rm -f /etc/group-$$ unset IFS else colecho "additional group $ag for user $user not found!" br x br fi else colecho "Command aborted" br x br fi else colecho "No additional group for $user found!" br x br fi echo else echo colecho "User $user does not exist!" br x br fi else echo colecho "Command aborted" br x br fi echo /var/install/bin/anykey