Advertisement
Fs0usa

Untitled

Oct 29th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.67 KB | None | 0 0
  1. #!/bin/bash
  2. # Autor: @Fs0usa
  3. # Data de criação/update: 29/10/17
  4. # Objetivo:
  5. # Descrição:
  6. # Projeto: Fechado
  7. # Utilize por sua conta e risco, não modifique o script com o intuito
  8. # de ganhar em cima de tal.
  9.  
  10. # Tabelas de cores que eu utilizo.
  11. fim="tput sgr0"
  12. bold="tput bold"
  13. vermelho="tput setaf 1"
  14. verde="tput setaf 2"
  15. amarelo="tput setaf 3"
  16. azul="tput setaf 4"
  17. roxo="tput setaf 5"
  18. ciano="tput setaf 6"
  19. branco="tput setaf 7"
  20. limpa="tput setaf 9"
  21. # Inicio do script
  22.  
  23. # Funcoes
  24. verify() {
  25. awk -F":" '{print $1}' /etc/passwd > /bin/users.txt
  26.     if grep -Fxq $usuario /bin/users.txt
  27.     then
  28.         $vermelho; $bold; echo -e "\nO usuário $1 já  existe,  por favor digite um usuário que não exista a seguir.\n"; $branco; $bold
  29.         read -p ":: "  usuario
  30.    
  31.         if grep -Fxq $usuario /bin/users.txt
  32.         then
  33.             $vermelho; $bold; echo -e "\nVocê  digitou um nome de usuário existente duas vezes.\n"; $fim
  34.         exit 2
  35.         fi
  36.     fi
  37. }
  38. add() {
  39. useradd $1 && echo $1:$2 | chpasswd
  40. passwd -x $3 $1
  41. }
  42. verify_two() {
  43. awk -F":" '{print $1}' /etc/passwd > /bin/users.txt
  44.     if grep -Fxq $usuario /bin/users.txt
  45.     then
  46.         $verde; $bold; echo -e "\nO usuário $1 foi criado com sucesso!!![Pressione qualquer botão para  sair]\n"; $branco; $bold
  47.         read nada
  48.         exit 3
  49.     fi
  50. }
  51. #
  52. user=`uname -n`
  53. clear
  54. $branco; $bold; echo -e "Bem vindo(a) $user - V.01\n\n"; $fim
  55. read -p "Deseja criar um usuário normal[Y/n]: " condition
  56. case $condition in
  57. y|Y)
  58. echo " "
  59. read -p "Nome do usuário: " usuario
  60. verify "$usuario"
  61. read -p "Senha: " senha
  62. read -p "Dias válido: " dias
  63. add "$usuario" "$senha" "$dias"
  64. verify_two "$usuario"
  65. ;;
  66. n|N) exit ;;
  67. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement