init.d 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: softflowd
  4. # Required-Start: $network $local_fs $remote_fs $syslog
  5. # Required-Stop: $network $local_fs $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Flow-based network traffic analyser.
  9. ### END INIT INFO
  10. # skeleton example file to build /etc/init.d/ scripts.
  11. # This file should be used to construct scripts for /etc/init.d.
  12. #
  13. # Written by Miquel van Smoorenburg <miquels@cistron.nl>.
  14. # Modified for Debian
  15. # by Ian Murdock <imurdock@gnu.ai.mit.edu>.
  16. #
  17. # Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
  18. #
  19. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  20. DAEMON=/usr/sbin/softflowd
  21. NAME=softflowd
  22. DESC=softflowd
  23. DEFAULT=/etc/default/softflowd
  24. PRIVDROP_CHROOT_DIR=/var/run/softflowd/chroot
  25. test -x $DAEMON || exit 0
  26. INTERFACE=
  27. OPTIONS=
  28. # Include softflowd defaults if available
  29. if [ -f $DEFAULT ] ; then
  30. . $DEFAULT
  31. fi
  32. if [ "$INTERFACE" = "" ] ; then
  33. echo "Not starting $NAME"
  34. echo "Edit $DEFAULT and define the INTERFACE variable"
  35. exit 0
  36. fi
  37. set -e
  38. [ -d $PRIVDROP_CHROOT_DIR ] || mkdir -p $PRIVDROP_CHROOT_DIR
  39. case "$1" in
  40. start)
  41. echo -n "Starting $DESC: "
  42. start-stop-daemon --start --oknodo --quiet --pidfile /var/run/$NAME.pid \
  43. --exec $DAEMON -- -i "$INTERFACE" $OPTIONS
  44. echo "$NAME."
  45. ;;
  46. stop)
  47. echo -n "Stopping $DESC: "
  48. start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
  49. --exec $DAEMON
  50. echo "$NAME."
  51. ;;
  52. #reload)
  53. #
  54. # If the daemon can reload its config files on the fly
  55. # for example by sending it SIGHUP, do it here.
  56. #
  57. # If the daemon responds to changes in its config file
  58. # directly anyway, make this a do-nothing entry.
  59. #
  60. # echo "Reloading $DESC configuration files."
  61. # start-stop-daemon --stop --signal 1 --quiet --pidfile \
  62. # /var/run/$NAME.pid --exec $DAEMON
  63. #;;
  64. force-reload)
  65. #
  66. # If the "reload" option is implemented, move the "force-reload"
  67. # option to the "reload" entry above. If not, "force-reload" is
  68. # just the same as "restart" except that it does nothing if the
  69. # daemon isn't already running.
  70. # check wether $DAEMON is running. If so, restart
  71. start-stop-daemon --stop --test --quiet --pidfile \
  72. /var/run/$NAME.pid --exec $DAEMON \
  73. && $0 restart \
  74. || exit 0
  75. ;;
  76. restart)
  77. echo -n "Restarting $DESC: "
  78. start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
  79. --exec $DAEMON
  80. sleep 1
  81. start-stop-daemon --start --oknodo --quiet --pidfile /var/run/$NAME.pid \
  82. --exec $DAEMON -- -i "$INTERFACE" $OPTIONS
  83. echo "$NAME."
  84. ;;
  85. *)
  86. N=/etc/init.d/$NAME
  87. # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
  88. echo "Usage: $N {start|stop|restart|force-reload}" >&2
  89. exit 1
  90. ;;
  91. esac
  92. exit 0