Administração de usuários em shell script
Publicado por Perfil removido 01/08/2009
[ Hits: 7.650 ]
Um script interativo para administração de usuários. Caso alguém queria utilizar, por favor verifique o código, pois este está adaptado exclusivamente para mim, fazendo uma busca por um usuário chamado danilocc, isso deve ser trocado dependendo do caso.
Acredito que o código possa ajudar algumas pessoas iniciantes em shell.
Qualquer sugestão, duvida ou reclamação por favor me comunicar.
dcapeloc@gmail.com
#!/bin/bash clear lokao=0 Principal() { clear echo "BY Danilo Capelo De Castro " echo echo " UNIX SCRIPT" echo echo "------------------------------------------" echo "Options:" echo echo "1. Add a new user (UNIX)" echo "2. Change the password" echo "3. Ownership change" echo "4. Lock the user" echo "5. Change directory " echo "6. Find user" echo "7. Support groups" echo "8. Delete user " echo "9. Exit" echo echo "Please, choose an option! " read opcao case $opcao in 1) add ;; 2) chang ;; 3) owner ;; 4) lock ;; 5) home ;; 6) find ;; 7) Group ;; 8) Delete ;; 9) exit ;; 10) xau ;; *) "This option don't exist" ; echo ; Principal ;; esac } add(){ clear echo echo echo " The groups to be added is Elevate access? (y/n)" read show if [ $show = "n" ]; then clear echo " #################" echo " # NORMAL ACCESS #" echo " #################" echo echo " GROUP ROLE" echo " -------- ---------------------------------" echo "1. appadm Applications" echo "2. appsupp Applications Availability Support" echo "3. accadm Access Admin" echo "4. backups Backups" echo "5. database Database" echo "6. migrate Code Migration" echo "7. infra Infrastructure" echo "8. infraapp Infrastructure Application Support Administrator" echo "9. monitor Monitoring" echo "10. storage Storage" echo "11. sysacct System Account" echo echo "12. Back main menu" echo "13. Other group" echo " -----------------------------------------------------------------------" echo echo "Which group do you need to assign to? " read op case $op in 1) appadm ;; 2) appsupp ;; 3) accadm ;; 4) backups ;; 5) database ;; 6) migrate ;; 7) infra ;; 8) infraapp ;; 9) monitor ;; 10) storage ;; 11) sysacct ;; 12) back ;; 13) other ;; *) "This option don't exist" ; echo ; Principal ;; esac else clear echo " ###################" echo " # ELEVATED ACCESS #" echo " ###################" echo echo echo " GROUP ROLE" echo " -------- ---------------------------------" echo echo "1. eappsupp Applications Availability Support Elevated" echo "2. ebackups Backups Elevated" echo "3. emigrate Code Migration Elevated" echo "4. edatabas Database Elevated" echo "5. einfraapp Infrastructure Application Support Elevated" echo "6. estorage Storage Elevated" echo echo echo "7. Back main menu" echo "8. Other group" echo echo "Which group do you need to assign to? " read op case $op in 1) eappsupp ;; 2) ebackups ;; 3) emigrate ;; 4) edatabas ;; 5) einfraapp ;; 6) estorage ;; 7) back ;; 8) other ;; *) "This option don't exist" ; echo ; Principal ;; esac fi } infra (){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g infra -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } appadm(){ echo " What's the ID that you want to be add?" read figo echo " What's the comment that you want? e.g FirstName LastName(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g appadm -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" sleep 2 echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" sleep 2 sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } appsupp(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g appsupp -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" sleep 2 echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" sleep 2 sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } accadm(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g accadm -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" sleep 2 echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" sleep 2 sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } backups(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g backups -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" sleep 2 echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" sleep 2 sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo sleep 2 echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } database(){ echo " What's the handle that you want to be add?" read figo echo "What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g database -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } migrate(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " addinguser ..... 0%" sudo /usr/sbin/useradd -g migrate -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } infraapp(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g infraapp -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } monitor(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g monitor -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } storage(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g storage -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } sysacct(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g sysacct -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi } eappsupp(){ echo "What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g eappsupp -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } ebackups(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g ebackups -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } emigrate(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adicionando user ..... 0%" sudo /usr/sbin/useradd -g emigrate -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } edatabas(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g edatabas -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } einfraapp(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID) " read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g einfraapp -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } estorage(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " adding user ..... 0%" sudo /usr/sbin/useradd -g estorage -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal else echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" echo echo echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" Principal fi echo " #Remeber to send a e-mail to GHD to add this user into the sudores file" } back(){ Principal } other(){ echo " What's the handle that you want to be add?" read figo echo " What's the comment that you want? e.g Name(HRID)" read com echo " What's the group to be add? " read xoxola grep $xoxola /etc/group > love rsrs=`cat love` ; echo $rsrs | cut -d ":" -f 1 > love rsrs=`cat love` ; rm -r love if [ $rsrs = "$xoxola" ];then clear echo " adding user ..... 0%" sudo /usr/sbin/useradd -g $xoxola -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi else sudo groupadd $xoxola sleep 2 echo " adding user ..... 0%" sudo /usr/sbin/useradd -g $xoxola -s `grep danilocc /etc/passwd|cut -d ":" -f 7` -c "$com" -d `grep danilocc /etc/passwd|cut -d ":" -f 6|sed "s/danilocc/$figo/"` -m $figo > maibe 2>&1 lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo "This user already exist into this server, Do you want reset the passwd? (y/n)" read lelo if [ $lelo = "y" ]; then sudo passwd $figo echo " adding user ..... 25%" echo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo sleep 2 echo "Done - - 100%" Principal else Principal fi else clear echo " adding user ..... 25%" echo sudo passwd $figo echo " adding user ..... 50%" sudo /usr/sbin/usermod -f 120 $figo echo " adding user ..... 75%" sudo passwd -w 7 -n 7 -x 90 $figo echo " adding user ..... 99,9%" echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo passwd -f $figo echo "Done - - 100%" sleep 3 Principal fi fi } chang() { clear echo "What's the ID of the user that you want to be reset? " read handle echo sudo passwd -s $handle > maibe 2>&1 echo lokao=`cat maibe` ; echo $lokao | cut -d ":" -f 3 > maibe lokao=`cat maibe` ; rm -r maibe if [ $lokao = "ERROR" ]; then clear echo echo " This user there is NOT into this server, hit enter to back to main menu" read enter Principal else clear echo " Some information " echo grep $handle /etc/passwd echo sudo passwd -s $handle read enter echo " Type the new passwd " echo echo sudo passwd $handle sudo /usr/sbin/usermod -f 0 $handle clear echo " Please, try to connect using this account and the passwd that has been set, and after hit enter" read enter sudo /usr/sbin/usermod -f 120 $handle sudo passwd -f $handle clear echo " Done " sleep 4 Principal fi } owner() { clear echo "What's the ID of the user that you want to change the owner? " read nome echo echo " Some information " echo grep $nome /etc/passwd echo sudo passwd -s $nome echo echo "Who is the new onwer? --> Name Lastname(HRID)" read new sudo /usr/sbin/usermod -c "$new" $nome clear grep $nome /etc/passwd echo " Would like to reset the passwd from this account? (y/n) " read ss if [ $ss = "y" ]; then sudo passwd $nome sudo /usr/sbin/usermod -f 0 $nome echo " Please, try to conncet using this account and the passwd that has been set, and after hit enter" read enter sudo /usr/sbin/usermod -f 120 $nome sudo passwd -f $nome else Principal fi Principal } lock(){ clear echo "What's the ID to be locked ? " read nome echo "------------------------------| Basic |-------------------------------------" echo grep $nome /etc/passwd echo echo "----------------------------| Passwd status |-------------------------------" echo sudo passwd -s $nome echo echo "--------------------------| More information |------------------------------" echo finger $nome echo echo "-----------------------------| Groups |-------------------------------------" groups $nome echo echo "Do you really want to lock this user? (y/n)" read conf if [ $conf = "y" ]; then grep $nome /etc/passwd | cut -d ":" -f 5 |read oi sudo /usr/sbin/usermod -c "##LKD## $oi " $nome echo echo "------------------------------| Basic |-------------------------------------" echo grep $nome /etc/passwd echo echo "----------------------------| Passwd status |-------------------------------" echo sudo passwd -s $nome echo echo "--------------------------| More information |------------------------------" echo finger $nome echo echo "-----------------------------| Groups |-------------------------------------" groups $nome echo echo " After check, hit enter" read enter else Principal fi Principal } home(){ echo "What's the ID you want to change the directory ? " read nome echo echo "------Home atual--------" grep $nome /etc/passwd | cut -d ":" -f 6 echo echo " Do you really want to change the directory ? (y/n)" read conf if [ $conf = "y" ]; then echo " What's the home ?" read $xuxu sudo /usr/sbin/usermod -d $xuxu $nome else Principal fi Principal } find(){ echo "What is the user's ID ? " read nome clear echo "--------------------------| Basic |-----------------------------------------" echo grep $nome /etc/passwd echo echo "----------------------------| Passwd status |-------------------------------" echo sudo passwd -s $nome echo echo "--------------------------| More information |------------------------------" echo finger $nome echo echo "-----------------------------| Groups |-------------------------------------" groups $nome echo echo " After check, hit enter" read enter Principal } Delete(){ clear echo " What is the user's ID that you want remove?" read loka echo " Are you SURE that want to remove this user? (y/n)" read caka if [ $caka = "y" ]; then echo " Removing" sudo /usr/sbin/userdel $loka sudo /usr/sbin/userdel -r $loka echo " " echo " " echo " The user has been removed sucessfull " Principal else echo " " echo " " echo " The action has been cancelled by the user" sleep 5 Principal fi Principal } xau(){ ^D EXIT } Group(){ clear echo "BY Danilo Capelo De Castro " echo echo echo "------------------------------------------" echo "Options:" echo echo "1. Change pricipal group (-g)" echo "2. Change secondary group (-G)" echo "3. Remove secondary group " echo "4. Back to main menu" echo echo echo "Please, choose an option! " read ttt case $ttt in 1) mege ;; 2) oxum ;; 3) ogum ;; 4) lalala ;; *) "This option don't exist" ; echo ; Principal ;; esac } mege(){ clear echo echo echo "What's the user's ID that you want to change the primary group ?" read xxx clear echo " Now" echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group echo echo " which group do want to change $xxx ? (4587 or appadm)" read GG clear echo " " echo " " echo " Changing the principal group " echo " " sudo /usr/sbin/usermod -g $GG $xxx echo " After " echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group echo " After check, hit enter" read enter Principal } oxum(){ clear echo echo echo "What's the user's ID that you want to change the secondary group ?" read xxx clear echo " Now" echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group echo echo " which group do want to change $xxx ? (4587 or appadm)" echo " more than one, please use commas " read GG clear echo echo echo " Changing the secondary group " echo sudo /usr/sbin/usermod -G $GG $xxx echo " After " echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group sleep 10 Principal } ogum(){ clear echo echo echo "What's the user's ID that you want to remove the secondary group ?" read xxx clear echo " Now" echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group echo " " clear sudo /usr/sbin/usermod -G $tr $xxx echo " " echo " " echo " Removing the secondary group " echo " " echo " After " echo grep $xxx /etc/passwd | cut -d ":" -f 4 | read tr grep $xxx /etc/passwd groups $xxx grep $tr /etc/group sleep 10 Principal } lalala(){ Principal } Principal
Gerar TinyURL (URL curta) para postar no Twitter
IP E MAC ( ESSE FUNCIONA PERFEITAMENTE)
Calculo da Baskara em Shell Script (Super Comentado)
Script simples para pegar informações sobre placa de rede
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Meu Fork do Plugin de Integração do CVS para o KDevelop
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
Criando uma VPC na AWS via CLI
Multifuncional HP imprime mas não digitaliza
Dica básica para escrever um Artigo.
Como Exibir Imagens Aleatórias no Neofetch para Personalizar seu Terminal
Mint começou a apresentar varios erros (3)