Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/watchcat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=watchcat
PKG_VERSION:=1
PKG_RELEASE:=19
PKG_RELEASE:=20

PKG_MAINTAINER:=Roger D <[email protected]>
PKG_LICENSE:=GPL-2.0
Expand Down
37 changes: 18 additions & 19 deletions utils/watchcat/files/watchcat.init
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ time_to_seconds() {

config_watchcat() {
# Read config
config_get_bool enabled "$1" enabled 1
config_get period "$1" period "120"
config_get mode "$1" mode "ping_reboot"
config_get pinghosts "$1" pinghosts "8.8.8.8"
Expand All @@ -44,6 +45,9 @@ config_watchcat() {
config_get addressfamily "$1" addressfamily "any"
config_get script "$1" script

# Skip disabled instances
[ "$enabled" = 1 ] || return

# Fix potential typo in mode and provide backward compatibility.
[ "$mode" = "allways" ] && mode="periodic_reboot"
[ "$mode" = "always" ] && mode="periodic_reboot"
Expand Down Expand Up @@ -90,40 +94,35 @@ config_watchcat() {

[ -n "$warn" ] && logger -p user.warn -t "watchcat" "$1: $warn"
[ -n "$error" ] && {
logger -p user.err -t "watchcat" "reboot program $1 not started - $error"
logger -s -p user.err -t "watchcat" "reboot program $1 not started - $error"
return
}

procd_open_instance "watchcat_${1}"

# Need to conditionally run mode functions because they have different signatures
case "$mode" in
periodic_reboot)
procd_open_instance "watchcat_${1}"
procd_set_param command /usr/bin/watchcat.sh "periodic_reboot" "$period" "$forcedelay"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
;;
ping_reboot)
procd_open_instance "watchcat_${1}"
procd_set_param command /usr/bin/watchcat.sh "ping_reboot" "$period" "$forcedelay" \"$pinghosts\" "$pingperiod" "$pingsize" "$addressfamily" "$interface"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
procd_set_param command /usr/bin/watchcat.sh "ping_reboot" "$period" "$forcedelay" "$pinghosts" "$pingperiod" "$pingsize" "$addressfamily" "$interface"
;;
restart_iface)
procd_open_instance "watchcat_${1}"
procd_set_param command /usr/bin/watchcat.sh "restart_iface" "$period" \"$pinghosts\" "$pingperiod" "$pingsize" "$interface" "$mmifacename" "$unlockbands" "$addressfamily"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
procd_set_param command /usr/bin/watchcat.sh "restart_iface" "$period" "$pinghosts" "$pingperiod" "$pingsize" "$interface" "$mmifacename" "$unlockbands" "$addressfamily"
;;
run_script)
procd_open_instance "watchcat_${1}"
procd_set_param command /usr/bin/watchcat.sh "run_script" "$period" \"$pinghosts\" "$pingperiod" "$pingsize" "$interface" "$addressfamily" "$script"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
;;
*)
echo "Error starting Watchcat service. Invalid mode selection: $mode"
procd_set_param command /usr/bin/watchcat.sh "run_script" "$period" "$pinghosts" "$pingperiod" "$pingsize" "$interface" "$addressfamily" "$script"
;;
# *) # impossible case, mode checked above.
# ;;
esac

procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
# simplify debugging
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}

start_service() {
Expand Down