Guest User

Untitled

a guest
May 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # Copy this script to your bin directory and connect faster to your
  5. # pods running the this script:
  6. #
  7. # $ ocrsh <aprtial pod name>
  8. #
  9. # Example:
  10. # Avalilable pods: consumer, workbench, rabbitmq, memcached
  11. #
  12. # $ ocrsh cons
  13. # $ ocrsh wo
  14. # $ ocrsh rab
  15. # $ ocrsh mem
  16. #
  17.  
  18. printUsage()
  19. {
  20. echo ""
  21. echo " Usage: $0 <pod name>"
  22. echo ""
  23. }
  24.  
  25. printAvailablePods()
  26. {
  27. oc get pods | awk 'NR != 1 {print $1}' | awk '{print substr($0, 1, length($0)-6)}'
  28. }
  29.  
  30. if [ -z "$1" ]
  31. then
  32. printUsage
  33. exit
  34. fi
  35.  
  36. POD=`oc get pods | grep $1 | awk 'NR==1{print $1}'`
  37.  
  38. if [ $POD ]
  39. then
  40. oc rsh $POD
  41. else
  42. echo "No pods available for '$1'"
  43. echo
  44. printAvailablePods
  45. echo
  46. exit 1
  47. fi
Add Comment
Please, Sign In to add comment