Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #!/bin/bash
  2. # at the top are all the functions at the bottem is the execution order
  3. username()
  4. {
  5. echo Enter the username.
  6. read USERNAME
  7. echo
  8. echo
  9. echo
  10.  
  11. if [ -n "$USERNAME" ]; then
  12. :
  13. else
  14. echo "You didn't supply a username"
  15. username
  16. exit 1
  17. fi
  18. echo "the username you have selected is " $USERNAME
  19. read -p "Is this the username you would like to use? Yy/Nn " yn
  20. case $yn in
  21. [Yy]* ) echo ;;
  22. [Nn]* ) username;;
  23. * ) echo "Please answer yes or no."; username;;
  24. esac
  25. }
  26. groups()
  27. {
  28. groeps=($(cat /etc/group | grep ftponly)) #productie
  29. #groeps=($(cat group | grep ftponly)) #local test
  30. read -p "$(
  31. f=0
  32. for groepname in "${groeps[@]}" ; do
  33. # echo "$((++f)): $groepname"
  34. echo "$((++f)): ${groepname:0:8}"
  35. done
  36.  
  37.  
  38. echo -ne 'Please select the groep you would like to use > '
  39. )"
  40. selection
  41.  
  42. selected_groep="${groeps[$((selection-1))]}"
  43. echo "you have selected " ${selected_groep:0:8}
  44. read -p "is this the right group? Yy/Nn " yn
  45. case $yn in
  46. [Yy]* ) echo " " ;;
  47. [Nn]* ) groups;;
  48. * ) echo "Please answer yes or no."; groups;;
  49. esac
  50. }
  51.  
  52. ticket()
  53. {
  54. echo "Enter the ticket number"
  55. read TICKET
  56. echo
  57. echo
  58. if [ -n "$TICKET" ]; then
  59. :
  60. else
  61. echo "you didnt supply a ticket number, to execute this you need to have a ticket number."
  62. ticket
  63. fi
  64. }
  65. endcommand()
  66.  
  67. {
  68. echo
  69. echo
  70. DIR=/data/xchangeremote
  71. final="/usr/sbin/useradd -g ${selected_groep:10:4} -c "$USERNAME + $TICKET" -d $DIR/./"$USERNAME" -s /usr/sbin/nologin "$USERNAME""
  72. echo $final
  73. echo "To check if the command is correct see example on: "
  74.  
  75. read -p "is the command correct now? Answer with: Yy/Nn " yn
  76. case $yn in
  77. [Yy]* ) echo ;;
  78. [Nn]* ) echo "please enter the correct username"; username; groups; ticket; endcommand;;
  79. * ) echo "Please answer yes or no."; endcommand;;
  80. esac
  81. PASSWORD=$(< /dev/urandom tr -dc '1234567890!@#$%qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM' | head -c12; echo "")
  82. echo " the password for this account will be" $PASSWORD
  83. $final
  84. $USERNAME:$PASSWORD | chpasswd
  85. }
  86. #here are the functions called
  87. username
  88. groups
  89. ticket
  90. endcommand
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement