freifunk-watchdog.init 886 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh /etc/rc.common
  2. START=99
  3. PID=/var/run/ffwatchd.pid
  4. BIN=/usr/sbin/ffwatchd
  5. boot()
  6. {
  7. # If watchdog service is enabled, install cronjob, create device node and start daemon
  8. if /etc/init.d/freifunk-watchdog enabled 2>/dev/null; then
  9. if ! grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
  10. echo "* * * * * $BIN running || /etc/init.d/freifunk-watchdog restart" >> /etc/crontabs/root
  11. fi
  12. mknod /dev/watchdog c 10 130
  13. start
  14. # If service is disabled, find and remove related cronjob
  15. elif grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
  16. sed -i -e "\\'$BIN'd" /etc/crontabs/root
  17. fi
  18. }
  19. start()
  20. {
  21. start-stop-daemon -q -b -m -p $PID -x $BIN -S
  22. }
  23. stop()
  24. {
  25. start-stop-daemon -q -p $PID -x $BIN -K
  26. if ! /etc/init.d/freifunk-watchdog enabled; then
  27. if grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
  28. sed -i -e "\\'$BIN'd" /etc/crontabs/root
  29. fi
  30. fi
  31. }