Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. list=()
  4.  
  5. function torles() {
  6. read -p "Enter the User name: " username
  7. sed -i "/$username/d" ./users.txt
  8. echo $username torolve!
  9.  
  10. }
  11. function givegid(){
  12. # előző gid-et adja vissza
  13. elozogid=$( tail -n 1 users.txt | cut -d':' -f 4 )
  14. #új gid
  15. gid=$(($elozogid+1))
  16. }
  17.  
  18. function giveuid(){
  19. # előző uid-et adja vissza
  20. elozouid=$( tail -n 1 users.txt | cut -d':' -f 3 )
  21. #új uid
  22. uid=$(($elozouid+1))
  23. }
  24.  
  25. function readusers(){
  26. while IFS= read -r line; do
  27. list+=("$line");
  28. done < users.txt
  29. }
  30.  
  31. function listusers(){
  32. for i in "${list[@]}"
  33. do
  34. echo "${i}"
  35. done
  36. }
  37.  
  38. while true
  39. do
  40. valasz='Mit szeretnel?'
  41. options=("Listazas" "Hozzaadas" "Torles" "Zarolas" "Engedelyezes" "Jelszovaltas" "Shellvaltas" "Quit")
  42. select opt in "${options[@]}"
  43. do
  44. case $opt in
  45. "Listazas")
  46. readusers
  47. listusers
  48. break;;
  49. "Torles")
  50. torles
  51. break;;
  52. "Zarolas")
  53. break;;
  54. "Engedelyezes")
  55. break;;
  56. "Jelszovaltas")
  57. break;;
  58. "Shellvaltas")
  59. break;;
  60. "Hozzaadas")
  61. ###########
  62. read -p "Enter a User name: " username
  63. read -p "Enter a Full name: " fullname
  64. read -p "Enter a Home directory: " homedir
  65. read -p "Enter a Bash name: " bashname
  66. read -p "Enter a Password: " password
  67.  
  68.  
  69.  
  70.  
  71. password="$(echo "$password" | md5sum | cut -d' ' -f1 )"
  72. giveuid
  73. givegid
  74. echo "$username:$password:$uid:$gid:$fullname:$homedir:$bashname" >> ./users.txt
  75. ###########
  76. break;;
  77. "Quit")
  78. exit;;
  79. *) echo "helytelen valasz";;
  80. esac
  81. done
  82. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement