[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Script de recadastramento Help
From: |
wagner oliveira |
Subject: |
Script de recadastramento Help |
Date: |
Fri, 14 Nov 2003 17:00:16 -0300 (ART) |
estou fazendo um script de recadastramento de todos os usuarios,que muda seu id
para seu numero de matricula, so que estou sentindo um pouco de
dificuldade,primeiro pq quando recadastro um usuario ele perde todos os seus
e-mails, sendo que os e-mail dos usuarios esta em uma partiçao separa , em
/var/spool/mail e tb ele nao esta alterando as permissoes do homeDir do usuario.
abaixo esta o script:
# Script para recadastramento geral
#
#!/bin/bash
BACKTITLE='Recadastramento Geral de 2003'
dialog\
--title 'Sistema de Recadastramento'\
--backtitle "$BACKTITLE"\
--msgbox 'Bem vindo ao Sistema de\nRecadastramento geral do LCC.' \
6 40
EXIT=0
while [ $EXIT == 0 ]
do
USER=$( dialog --stdout --backtitle "$BACKTITLE" --title 'Usuário'
--inputbox 'Digite o login do usuário:' 8 35 )
EXIT=$?
( cat /etc/passwd | cut -d : -f 1 | grep $USER 2> /dev/null )
if [ $? == 0 ]
then
MATRIC=$( dialog --stdout --title 'Matrícula' --backtitle "$BACKTITLE"
--inputbox 'Digite a matricula do usuário:' 9 30 )
EXIT=$?
if [ $MATRIC != NULL ]
then
ID=$(id -u $USER)
USERGROUP=$( grep $ID /etc/passwd | cut -d : -f 4 )
USERCOMP=$( grep $ID /etc/passwd | cut -d : -f 5 )
USERHOME=$( grep $ID /etc/passwd | cut -d : -f 6 )
USERSHELL=$( grep $ID /etc/passwd | cut -d : -f 7 )
touch -f /tmp/recpass.tmp
grep -v $ID /etc/passwd > /tmp/recpass.tmp
echo
"$USER:x:$MATRIC:$USERGROUP:$USERCOMP:$USERHOME:$USERSHELL"|cat >>
/tmp/recpass.tmp
dialog --title 'Confimação' --backtitle "$BACKTITLE" --yesno
"Usuário: $USERCOMP \nLogin: $USER \nMatrícula: $MATRIC" 8 50
if [ $? == 0 ]
then
cp -f /etc/passwd /root/passwd.BKP_REC
cp -f /tmp/recpass.tmp /etc/passwd
rm -f /tmp/recpass.tmp
chown -R $USER $USERHOME
useradd -e 2004-08-30 $USER
( echo $USER $USERHOME | cat >>
/root/usuarios_cadastrados.2003 )
fi
else
if [ $EXIT == 0 ]
then
dialog --title "ERROR" --backtitle "$BACKTITLE" --msgbox
"Matrícula inválida" 7 30
fi
fi
else
if [ $EXIT == 0 ]
then
dialog --title "ERROR" --msgbox "Usuário inexistente" 7 30
fi
fi
done
clear
PS:estou usando dialog so para enfeitar mesmo.
Wagner de Oliveira
Membro do PET - Ciências Da Computação
Administrador de Redes Linux - LCC_UFRN
Linux User -> #309543
Homepage -> www.lcc.ufrn.br/~wagnerol
---------------------------------
Yahoo! Mail - 6MB, anti-spam e antivírus gratuito. Crie sua conta agora!
[As partes desta mensagem que não continham texto foram removidas]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Script de recadastramento Help,
wagner oliveira <=