Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. source ~/.crawl.secret # Get $USERNAME and $PASSWORD
  4. # Example
  5. # $ cat .crawl.secret
  6. # USERNAME=myusername
  7. # PASSWORD=mypassword
  8.  
  9. # name of tmux session
  10. export SESSION="crawl"
  11.  
  12. # if session already running, attach it.
  13. tmux has-session -t $SESSION 2> /dev/null
  14. if [ $? -eq 0 ]; then
  15. echo "Session $SESSION already exists. Attaching."
  16. else
  17. # else create it, and detach it to work on it a bit
  18. tmux new-session -d -s $SESSION
  19. tmux new-window -t $SESSION:1 -k -n "crawl" "$SHELL"
  20. fi
  21.  
  22. # if not already connected, connect and login
  23. if ! netstat -at |grep crawl.akrasiac.org |grep ESTABLISHED ; then
  24. tmux send-keys -t $SESSION:1 "ssh -i ~/.ssh/id_rsa.cao joshua@crawl.akrasiac.org" Enter
  25. sleep 1
  26. tmux send-keys -t $SESSION:1 "l"
  27. sleep 1
  28. tmux send-keys -t $SESSION:1 "$USERNAME" Enter
  29. sleep 1
  30. tmux send-keys -t $SESSION:1 "$PASSWORD" Enter
  31. tmux send-keys -t $SESSION:1 "p"
  32. fi
  33.  
  34. tmux select-window -t $SESSION:1
  35. tmux attach -dt $SESSION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement