Guest User

Untitled

a guest
Dec 9th, 2019
370
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #command=$(ls)
  4. #echo $command
  5.  
  6.  
  7.  
  8. #Récupération des users
  9. users=()
  10. while IFS=$'\t' read -r -a myArray; do
  11. users+=($myArray)
  12. done < users
  13. #for i in "${users[@]}"
  14. #do
  15. # echo $i
  16. #done
  17.  
  18. echo "Bienvenue dans le gestionnaire d'utilisateur"
  19.  
  20. action='p'
  21.  
  22. while [ $action != 'q' ]
  23. do
  24. echo "Que voulez-vous faire ?"
  25. echo "a -> Ajouter un user"
  26. echo "p -> Afficher les users"
  27. echo "q -> Quitter"
  28. read -p "Entrez votre choix" action
  29. clear && echo -en "\e[3J"
  30. if [ $action = 'p' ]
  31. then
  32. INPUT=users
  33. OLDIFS=$IFS
  34. IFS=$'\t'
  35. [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
  36. while read login password groups date
  37. do
  38. echo "Login : $login"
  39. echo "Password : $password"
  40. echo "Group : $groups"
  41. echo "Date : $date"
  42. echo ""
  43. done < $INPUT
  44. IFS=$OLDIFS
  45. fi
  46. if [ $action = 'a' ]
  47. then
  48. echo "Vous allez ajouter un user"
  49.  
  50. while [ 1 ]
  51. do
  52. read -p 'Login :' login
  53.  
  54. [[ $login =~ ^$ ]] && break || echo "Veuillez recommencer"
  55. done
  56.  
  57. while [ 1 ]
  58. do
  59. read -p 'Password : ' password
  60. [[ $password =~ ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$*+-=@%&]).{8,}$ ]] && break || echo "Veuillez recommencer"
  61. done
  62.  
  63.  
  64.  
  65. echo $login $Prenom >>users
  66. fi
  67. done
RAW Paste Data