pptpd.init 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: pptpd
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 1
  8. # Short-Description: pptpd
  9. # Description: PoPToP Point to Point Tunneling Server
  10. ### END INIT INFO
  11. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  12. DESC='PoPToP Point to Point Tunneling Server'
  13. NAME=pptpd
  14. DAEMON="/usr/sbin/$NAME"
  15. DAEMON_OPTS=''
  16. PIDFILE='/var/run/pptpd.pid'
  17. SCRIPTNAME="/etc/init.d/$NAME"
  18. [ -x "$DAEMON" ] || exit 0
  19. [ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"
  20. . /lib/init/vars.sh
  21. . /lib/lsb/init-functions
  22. do_start()
  23. {
  24. start-stop-daemon --start --quiet \
  25. --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null \
  26. || return 1
  27. start-stop-daemon --start --quiet \
  28. --pidfile "$PIDFILE" --exec "$DAEMON" -- $DAEMON_OPTS \
  29. || return 2
  30. }
  31. do_stop()
  32. {
  33. [ -f "$PIDFILE" ] || return 1
  34. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
  35. --pidfile "$PIDFILE" --name "$NAME"
  36. RETVAL="$?"
  37. [ "$RETVAL" = 2 ] && return 2
  38. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 \
  39. --exec "$DAEMON"
  40. [ "$?" = 2 ] && return 2
  41. # Many daemons don't delete their pidfiles when they exit.
  42. rm -f "$PIDFILE"
  43. return "$RETVAL"
  44. }
  45. case "$1" in
  46. start)
  47. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  48. do_start
  49. case "$?" in
  50. 0|1)
  51. [ "$VERBOSE" != 'no' ] && log_end_msg 0
  52. ;;
  53. 2)
  54. [ "$VERBOSE" != 'no' ] && log_end_msg 1
  55. ;;
  56. esac
  57. ;;
  58. stop)
  59. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  60. do_stop
  61. case "$?" in
  62. 0|1)
  63. [ "$VERBOSE" != 'no' ] && log_end_msg 0
  64. ;;
  65. 2)
  66. [ "$VERBOSE" != 'no' ] && log_end_msg 1
  67. ;;
  68. esac
  69. ;;
  70. status)
  71. status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
  72. ;;
  73. restart|force-reload)
  74. log_daemon_msg "Restarting $DESC" "$NAME"
  75. do_stop
  76. case "$?" in
  77. 0|1)
  78. do_start
  79. case "$?" in
  80. 0) log_end_msg 0 ;;
  81. 1) log_end_msg 1 ;; # Old process is still running
  82. *) log_end_msg 1 ;; # Failed to start
  83. esac
  84. ;;
  85. *)
  86. # Failed to stop
  87. log_end_msg 1
  88. ;;
  89. esac
  90. ;;
  91. *)
  92. echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
  93. exit 3
  94. ;;
  95. esac
  96. exit 0