#!/bin/bash # # Add group script. If a new group is created, output the gid to stdout. # # Michiel Broek # # Based on an example from the Samba HOWTO collection. # # This script 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, or (at your option) any # later version. # # This script is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with MB BBS; see the file COPYING. If not, write to the Free # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # GROUP=$@ if [ "`/usr/bin/grep \"$GROUP\" /etc/group`" != "" ]; then echo "Group '$GROUP' already exists" exit -1 fi /usr/sbin/groupadd smbtmpgrp00 thegid=`/usr/bin/cat /etc/group | /usr/bin/grep ^smbtmpgrp00 | /usr/bin/cut -d ":" -f3` # Now change the name to what we want for the MS Windows networking end /usr/bin/cp /etc/group /etc/group.bak /usr/bin/cat /etc/group.bak | /usr/bin/sed "s/^smbtmpgrp00/$GROUP/g" > /etc/group # Also update group shadow file /usr/bin/cp /etc/gshadow /etc/gshadow.bak /usr/bin/cat /etc/gshadow.bak | /usr/bin/sed "s/^smbtmpgrp00/$GROUP/g" > /etc/gshadow # Now return the GID as would normally happen. echo $thegid exit 0