Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Display the UID and username of the user executing this script.
  4. #Display if the user is vagrant or not
  5.  
  6. echo "Your UID is ${UID}"
  7.  
  8. UID_TO_TEST_FOR='1000'
  9.  
  10. if [[ "${UID}" -ne "${UID_TO_TEST_FOR}" ]]
  11. then
  12. echo "Your UID does not match ${UID_TO_TEST_FOR}"
  13. exit 1
  14. fi
  15.  
  16.  
  17. USER_NAME=$(id -un)
  18.  
  19. if [[ "${?}" -ne 0 ]]
  20. then
  21. echo 'The id command did not execute succesfully.'
  22. exit 1
  23. fi
  24. echo "Your username is ${USER_NAME}"
  25.  
  26. USER_NAME_TO_TEST_FOR='vagrant'
  27. if [[ "${USER_NAME}" = "${USER_NAME_TO_TEST_FOR}" ]]
  28. then
  29. echo "Your username matches ${USER_NAME_TO_TEST_FOR}."
  30. fi
  31.  
  32. if [[ "${USER_NAME}" != "${USER_NAME_TO_TEST_FOR}" ]]
  33. then
  34. echo "Your username does not match ${USER_NAME_TO_TEST_FOR}."
  35. exit 1
  36. fi
  37.  
  38. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement