pptpd.init 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. description='PoPToP Point to Point Tunneling Server'
  13. name=pptpd
  14. daemon="/usr/sbin/$name"
  15. DAEMON_OPTS=''
  16. pid_file='/var/run/pptpd.pid'
  17. script_name="/etc/init.d/$name"
  18. [ -x "$daemon" ] || exit 0
  19. # shellcheck source=debian/pptpd.default
  20. [ -r "/etc/default/$name" ] && . "/etc/default/$name"
  21. . /lib/init/vars.sh
  22. . /lib/lsb/init-functions
  23. do_start() {
  24. start-stop-daemon --start --quiet \
  25. --pidfile "$pid_file" --exec "$daemon" --test >/dev/null ||
  26. return 1
  27. # shellcheck disable=SC2086 # We have to trust the default file
  28. start-stop-daemon --start --quiet \
  29. --pidfile "$pid_file" --exec "$daemon" -- $DAEMON_OPTS ||
  30. return 2
  31. }
  32. do_stop() {
  33. local retval
  34. [ -f "$pid_file" ] || return 1
  35. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
  36. --pidfile "$pid_file" --name "$name"
  37. retval="$?"
  38. [ "$retval" = 2 ] && return 2
  39. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 \
  40. --exec "$daemon"
  41. [ "$?" = 2 ] && return 2
  42. # Many daemons don't delete their pidfiles when they exit.
  43. rm -f "$pid_file"
  44. return "$retval"
  45. }
  46. case "$1" in
  47. start)
  48. [ "$VERBOSE" != 'no' ] && log_daemon_msg "Starting $description" "$name"
  49. do_start
  50. case "$?" in
  51. 0 | 1)
  52. [ "$VERBOSE" != 'no' ] && log_end_msg 0
  53. ;;
  54. 2)
  55. [ "$VERBOSE" != 'no' ] && log_end_msg 1
  56. ;;
  57. esac
  58. ;;
  59. stop)
  60. [ "$VERBOSE" != 'no' ] && log_daemon_msg "Stopping $description" "$name"
  61. do_stop
  62. case "$?" in
  63. 0 | 1)
  64. [ "$VERBOSE" != 'no' ] && log_end_msg 0
  65. ;;
  66. 2)
  67. [ "$VERBOSE" != 'no' ] && log_end_msg 1
  68. ;;
  69. esac
  70. ;;
  71. status)
  72. status_of_proc -p "$pid_file" "$daemon" "$name" && exit 0 || exit $?
  73. ;;
  74. restart | force-reload)
  75. log_daemon_msg "Restarting $description" "$name"
  76. do_stop
  77. case "$?" in
  78. 0 | 1)
  79. do_start
  80. case "$?" in
  81. 0) log_end_msg 0 ;;
  82. 1) log_end_msg 1 ;; # Old process is still running
  83. *) log_end_msg 1 ;; # Failed to start
  84. esac
  85. ;;
  86. *)
  87. # Failed to stop
  88. log_end_msg 1
  89. ;;
  90. esac
  91. ;;
  92. *)
  93. echo "Usage: $script_name {start|stop|status|restart|force-reload}" >&2
  94. exit 3
  95. ;;
  96. esac
  97. exit 0