LouisDK

Untitled

Jan 26th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #!/bin/bash
  2. SSHCMD='ssh -fND 8080 [email protected] -p5000'
  3. CURPRO=$(ps -eo pid,command | sed 's/^ //' | grep -v 'grep' | grep "$SSHCMD" | cut -d' ' -f1 | tr '\n' ' ')
  4. *()
  5. {
  6.     echo 'wrong or missing argument. Exiting.'
  7. }
  8. start()
  9. {
  10.     if [[ $CURPRO -eq 0 ]]
  11.     then
  12.         echo 'starting ssh socks proxy'
  13.         $CURPRO
  14.     else
  15.         CONTINUE=no
  16.         echo 'ssh socks proxy seems to be started already. Restart? (y/N)'
  17.         read CONTINUE
  18.         if [[ $CONTINUE == y ]]
  19.         then
  20.             restart
  21.         else
  22.             exit
  23.         fi
  24.     fi
  25.        
  26. }
  27.  
  28. restart()
  29. {
  30.     echo restart        
  31. }
  32.  
  33. stop()
  34. {
  35.         echo stop
  36. }
  37.  
  38. case $1 in
  39.     start|restart|stop) "$1" ;;
  40.     *) echo 'wrong or missing argument. Exiting.'
  41.    
  42. esac
Advertisement
Add Comment
Please, Sign In to add comment