Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Declare Session Variable
  4. SESSION="ey"
  5.  
  6. function hassession {
  7. tmux has-session -t ey 2>/dev/null
  8. }
  9.  
  10. # Change to the Webshop 4 Project Dir
  11. cd /Users/$USER/Projects/webshop4/
  12.  
  13. # # Get the servers addresses
  14. SERVERS=($(ey servers --environment="Production" | awk '{print $1}'))
  15. SERVERS=("${SERVERS[@]:2}")
  16.  
  17. # Create tmux session
  18. if ! hassession ; then
  19. echo "Starting new session for ey"
  20. tmux new -s $SESSION -d
  21.  
  22. # Handle first host.
  23. host=${SERVERS[0]}
  24. echo "Creating window split for host: $host"
  25. tmux send-key "ssh deploy@$host" C-m
  26. tmux send-key "htop" C-m
  27. unset SERVERS[0]
  28.  
  29. # Loop through the other hosts
  30. for host in "${SERVERS[@]}"
  31. do
  32. echo "Creating window split for host: $host"
  33. tmux split-window -v
  34. tmux select-layout tiled > /dev/null
  35. tmux send-key "ssh deploy@$host" C-m
  36. tmux send-key "htop" C-m
  37. done
  38. fi
  39.  
  40. tmux attach -t $SESSION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement