Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: rtunnel
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: This service helps to access a local port from a remote server & port
  10. # Description: This service helps to access a remote port from a remote server & port
  11. ### END INIT INFO
  12.  
  13. # Change the next 3 lines to suit where you install your script and what you want to call it
  14. DIR=/usr/local/bin/rtunnel
  15. DAEMON=$DIR/rtunnel.py
  16. DAEMON_NAME=rtunnel
  17. SSH_USER=ubuntu
  18. KEY_FILE=$DIR/Priyabrata1.pem
  19. SSH_SERVER=<ec2_host>.compute.amazonaws.com
  20. REMOTE_FWD_HOST=127.0.0.1:8001
  21. LOCAL_PORT=8001
  22.  
  23. # Add any command line options for your daemon here
  24. DAEMON_OPTS="-u $SSH_USER -K $KEY_FILE -p $LOCAL_PORT -r $REMOTE_FWD_HOST $SSH_SERVER"
  25.  
  26. # This next line determines what user the script runs as.
  27. # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
  28. DAEMON_USER=root
  29.  
  30. # The process ID of the script when it runs is stored here:
  31. PIDFILE=/var/run/$DAEMON_NAME.pid
  32.  
  33. . /lib/lsb/init-functions
  34.  
  35. do_start () {
  36. log_daemon_msg "Starting system $DAEMON_NAME daemon"
  37. start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
  38. log_end_msg $?
  39. }
  40. do_stop () {
  41. log_daemon_msg "Stopping system $DAEMON_NAME daemon"
  42. start-stop-daemon --stop --pidfile $PIDFILE --retry 10
  43. log_end_msg $?
  44. }
  45.  
  46. case "$1" in
  47.  
  48. start|stop)
  49. do_${1}
  50. ;;
  51.  
  52. restart|reload|force-reload)
  53. do_stop
  54. do_start
  55. ;;
  56.  
  57. status)
  58. status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
  59. ;;
  60.  
  61. *)
  62. echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
  63. exit 1
  64. ;;
  65.  
  66. esac
  67. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement