Advertisement
ucomesdag

rmate-install

Apr 22nd, 2022
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.36 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3.  
  4. # The script will connect back to Sublime Text so you should setup
  5. # an ssh tunnel: ssh -R 52698:localhost:52698 user@example.org
  6.  
  7. # Required: RemoteSubl package installed in Sublime Text
  8.  
  9. if [ $# -eq 0 ]
  10. then
  11.     echo "no remote suplied" >/dev/stderr
  12.     exit 1
  13. fi
  14.  
  15. # Check if we can access the remote host
  16. ssh $@ "exit" || exit 1
  17.  
  18. clear
  19. echo "Installing rmate on remote..."
  20. if command -v wget >/dev/null 2>&1
  21. then
  22.     wget -qO- https://raw.githubusercontent.com/aurora/rmate/master/rmate | ssh $@ "cat > ~/rmate"
  23.  
  24. else
  25.     curl -s https://raw.githubusercontent.com/aurora/rmate/master/rmate | ssh $@ "cat > ~/rmate"
  26. fi
  27.  
  28. if ! ssh $@ "sudo mv ~/rmate /usr/local/bin && sudo chmod +x /usr/local/bin/rmate || (rm ~/rmate; exit 1)"  >/dev/null 2>&1
  29. then
  30.     echo "Sorry, installing rmate failed."
  31.     exit 1
  32. fi
  33.  
  34. PROFILE=$(ssh $@ "ls .*profile")
  35. if [ $(ssh $@ "grep -c 'alias subl' $PROFILE") -eq 0 ]
  36. then
  37.     echo "Creating aliases ..."
  38.     ssh $@ "echo >> $PROFILE"
  39.     ssh $@ "echo \"alias rmate='/usr/local/bin/rmate' \" >> $PROFILE"
  40.     ssh $@ "echo \"alias rsubl='rmate' \" >> $PROFILE"
  41.     ssh $@ "echo \"alias subl='rmate' \" >> $PROFILE"
  42.     ssh $@ "echo \"alias sudo='sudo '\" >> $PROFILE"
  43. fi
  44.  
  45. if [ $? -eq 0 ]
  46. then
  47.     echo
  48.     echo "Setup an ssh tunnel with:"
  49.     echo
  50.     echo "  ssh -R 52698:localhost:52698 $@"
  51.     echo
  52.     echo "Done!"
  53.     exit 0
  54. else
  55.     exit 1
  56. fi
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement