/init.d/fancontrol

http://github.com/brinkman83/bashrc · Shell · 66 lines · 50 code · 6 blank · 10 comment · 11 complexity · d007dfb8c2b450d8cb44b2e37f11d6c9 MD5 · raw file

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: fancontrol
  4. # Required-Start: $remote_fs
  5. # Required-Stop: $remote_fs
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop:
  8. # Short-Description: fancontrol
  9. # Description: fan speed regulator
  10. ### END INIT INFO
  11. . /lib/lsb/init-functions
  12. [ -f /etc/default/rcS ] && . /etc/default/rcS
  13. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  14. DAEMON=/usr/sbin/fancontrol
  15. DESC="fan speed regulator"
  16. NAME="fancontrol"
  17. PIDFILE=/var/run/fancontrol.pid
  18. CONF=/etc/fancontrol
  19. test -x $DAEMON || exit 0
  20. case "$1" in
  21. start)
  22. if [ -f $CONF ] && [ -n "`grep INTERVAL $CONF | cut -d= -f2`" ]; then
  23. if [ -n "`grep DEVPATH $CONF | cut -d= -f2`" ] && [ -n "`grep DEVNAME $CONF | cut -d= -f2`" ] ; then
  24. log_daemon_msg "Starting $DESC" "$NAME"
  25. start-stop-daemon --start --quiet --background --pidfile $PIDFILE --startas $DAEMON
  26. log_end_msg $?
  27. else
  28. log_failure_msg "Not starting fancontrol, outdated configuration file; please re-run pwmconfig."
  29. fi
  30. else
  31. if [ "$VERBOSE" != no ]; then
  32. log_warning_msg "Not starting fancontrol; run pwmconfig first."
  33. fi
  34. fi
  35. ;;
  36. stop)
  37. log_daemon_msg "Stopping $DESC" "$NAME"
  38. start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON
  39. rm -f $PIDFILE
  40. log_end_msg $?
  41. ;;
  42. restart)
  43. $0 stop
  44. sleep 3
  45. $0 start
  46. ;;
  47. force-reload)
  48. if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON ; then
  49. $0 restart
  50. fi
  51. ;;
  52. status)
  53. status_of_proc $DAEMON $NAME && exit 0 || exit $?
  54. ;;
  55. *)
  56. log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}"
  57. exit 1
  58. ;;
  59. esac
  60. exit 0