Advertisement
Guest User

NAS Ubuntu Server Hamachi script

a guest
Jan 6th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.43 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          hamachi
  4. # Required-Start:
  5. # Required-Stop:
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: hamachi init script
  9. # Description:       This file is used to start, stop, restart,
  10. #                    and determined status of the hamachi vpn service.
  11. # Author:            iceflatline <iceflatline@gmail.com>
  12. ### END INIT INFO
  13.  
  14. ### START OF SCRIPT
  15. set -e
  16. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  17. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  18. DESC="hamachi"
  19. NAME=hamachi
  20. DAEMON=/usr/bin/$NAME
  21. SCRIPTNAME=/etc/init.d/$NAME
  22. USER=<your username>
  23.  
  24. # Exit if the hamachi package is not installed
  25. [ -x "$DAEMON" ] || exit 0
  26.  
  27. # Load the VERBOSE setting and other rcS variables
  28. . /lib/init/vars.sh
  29.  
  30. # Define LSB log_* functions.
  31. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  32. . /lib/lsb/init-functions
  33.  
  34. # Function that starts the tuncfg daemon then hamachi
  35. start() {
  36.     tuncfg && su $USER -c "hamachi start"
  37. }
  38.  
  39. # Function that stops hamachi then kills the tuncfg daemon
  40. stop() {
  41.     su $USER -c "hamachi stop" && kill $(pidof tuncfg)
  42. }
  43.  
  44. case "$1" in
  45.   start)
  46.     start
  47.     ;;
  48.   stop)
  49.     stop
  50.     ;;
  51.   restart|force-reload)
  52.     log_daemon_msg "Restarting $DESC"
  53.     stop
  54.     start
  55.     ;;
  56.   status)
  57.     status_of_proc "$DAEMON" "$NAME"
  58.     ;;
  59.   *)
  60.     echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}"
  61.     ;;
  62. esac
  63. exit 0
  64. ### END OF SCRIPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement