/rc4.d/S20openbsd-inetd

http://github.com/brinkman83/bashrc · Shell · 86 lines · 65 code · 10 blank · 11 comment · 7 complexity · d6c5a849e04ac6def196c326d74faf1b MD5 · raw file

  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides: openbsd-inetd
  4. # Required-Start: $local_fs $remote_fs
  5. # Required-Stop: $local_fs $remote_fs
  6. # Should-Start: $syslog
  7. # Should-Stop: $syslog
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: Start or stop the inetd daemon.
  11. ### END INIT INFO
  12. DAEMON=/usr/sbin/inetd
  13. [ -x $DAEMON -a -e /etc/inetd.conf ] || exit 0
  14. [ -e /etc/default/openbsd-inetd ] && . /etc/default/openbsd-inetd
  15. . /lib/lsb/init-functions
  16. checkportmap () {
  17. if ! grep -v -s "^ *#" /etc/inetd.conf | grep -q -s 'rpc/'; then
  18. return 0
  19. fi
  20. if [ ! -x /usr/bin/rpcinfo ]; then
  21. log_action_msg "WARNING: rpcinfo not available - RPC services may be unavailable!"
  22. log_action_msg " (Commenting out the rpc services in inetd.conf will"
  23. log_action_msg " disable this message)"
  24. elif ! /usr/bin/rpcinfo -u localhost portmapper >/dev/null 2>&1; then
  25. log_action_msg "WARNING: portmapper inactive - RPC services unavailable!"
  26. log_action_msg " (Commenting out the rpc services in inetd.conf will"
  27. log_action_msg " disable this message)"
  28. fi
  29. }
  30. checknoservices () {
  31. if ! grep -q "^[[:alnum:]/]" /etc/inetd.conf; then
  32. log_action_msg "Not starting internet superserver: no services enabled"
  33. exit 0
  34. fi
  35. }
  36. case "$1" in
  37. start)
  38. checknoservices
  39. checkportmap
  40. log_daemon_msg "Starting internet superserver" "inetd"
  41. start-stop-daemon --start --quiet --pidfile /var/run/inetd.pid \
  42. --exec $DAEMON -- $OPTIONS
  43. log_end_msg 0
  44. ;;
  45. stop)
  46. log_daemon_msg "Stopping internet superserver" "inetd"
  47. start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
  48. --oknodo
  49. log_end_msg 0
  50. ;;
  51. reload|force-reload)
  52. log_daemon_msg "Reloading internet superserver" "inetd"
  53. start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
  54. --oknodo --signal 1
  55. log_end_msg 0
  56. ;;
  57. restart)
  58. checkportmap
  59. log_daemon_msg "Restarting internet superserver" "inetd"
  60. start-stop-daemon --stop --quiet --pidfile /var/run/inetd.pid \
  61. --oknodo
  62. checknoservices
  63. sleep 1
  64. start-stop-daemon --start --quiet --pidfile /var/run/inetd.pid \
  65. --exec $DAEMON -- $OPTIONS
  66. log_end_msg 0
  67. ;;
  68. status)
  69. status_of_proc -p /var/run/inetd.pid $DAEMON inetd && exit 0 || exit $?
  70. ;;
  71. *)
  72. echo "Usage: /etc/init.d/openbsd-inetd {start|stop|reload|force-reload|restart|status}"
  73. exit 2
  74. ;;
  75. esac
  76. exit 0