07-18-2006
94,
0
Join Date: Jun 2005
Last Activity: 13 September 2006, 7:51 AM EDT
Posts: 94
Thanks Given: 0
Thanked 0 Times in 0 Posts
pb with chuser ou chgroup
hello
to use a ldap server, i must convert a parition of a P570, and so change id and gid of some users and groups.
So i have do this script :
# Change GID
Fich=/tmp/modgid.log
>$Fich
cp /etc/group /home/scripts/group.old
set -A tab C01sicso C01simca C01simcl C01simso C02sicso C02simca C02simcl CO2simso C03sicso C03simca C03simcl C03simso Dsidca Dsidcl Dsidso Dsirca Dsircl Dsirso adminsir admsidca admsidcl admsidso admsirso controlm dIPsidso dRCsidso dRPsidso invscout ldap mqm nagios snapp sshd sylsidca sylsidcl sylsidso tMusidca tMusidcl tMusidso tUmsidca tUmsidcl tUmsidso usrsas admsid admsirca admsircl adusrsid mdcsidca mdcsidcl mdcsidso mqbrkrs usrpilso usrpilca usrpilcl
i=600
a=0
while [ $i -le 653 ]
do
echo "i = $i" | tee -a $Fich
echo "tab a = $a" | tee -a $Fich
GRP=${tab[$a]}
echo "appartenance au groupe : $GRP" | tee -a $Fich
ID=`cat /etc/group | grep "${GRP}:" | awk -F":" '{print $3}'`
echo "Ancien GID : $ID" | tee -a $Fich
Verif=`cat /etc/group | grep "${GRP}:" | wc -c`
if [ $Verif -ge 10 ]
then
echo "Conversion !" | tee -a $Fich
chgroup id=$i ${GRP}
echo "Modification effectuee"
echo "Changement des fichiers concernes..."
find / -group ${ID} -exec chgrp $i {} \;
else
echo " Inexistant sur cette partition" | tee -a $Fich
fi
i=`expr $i + 1`
a=`expr $a + 1`
echo "--------------\n" | tee -a $Fich
done
# Change ID
Fich=/tmp/modid.log
>$Fich
cp /etc/passwd /home/scripts/passwd.old
set -A tab Menu auditeur ctmagent invscout k0xx01 ldap lsfadmin madminca madmincl madminso madsirca madsircl madsirso mqm nagios nuucp psipra r0xx01 s0xx01 s13084 s26301 s99999 sas9 sasguest sastrust stpadmin tina v0xx01 wadminso webadmin padminso padminca padmincl
i=600
a=0
while [ $i -le 632 ]
do
echo "i = $i" | tee -a $Fich
echo "tab a = $a" | tee -a $Fich
User=${tab[$a]}
echo "Utilisateur : $User" | tee -a $Fich
ID=`cat /etc/passwd | grep "${User}:" | awk -F":" '{print $3}'`
echo "Ancien ID : $ID" | tee -a $Fich
Verif=`cat /etc/passwd | grep "${User}:" | wc -c`
if [ $Verif -ge 10 ]
then
echo "Conversion !" | tee -a $Fich
chuser id=$i ${User}
echo "Conversion effectuee"
echo "Modification des fichiers en cours ..."
find / -user ${ID} -exec chown $i {} \;
else
echo " Inexistant sur cette partition" | tee -a $Fich
fi
i=`expr $i + 1`
a=`expr $a + 1`
echo "--------------\n" | tee -a $Fich
done
And when i have execute this script, the PRIMARY group for ALL user has been changed !!!!!!! i don't understand why ???!!!!
Thank you for your help.