Browse Source

watchcat: update to support procd

Signed-off-by: Nicholas Smith <nicholas@nbembedded.com>
lilik-openwrt-22.03
Nicholas Smith 3 years ago
parent
commit
399279b363
5 changed files with 78 additions and 72 deletions
  1. +8
    -6
      utils/watchcat/Makefile
  2. +27
    -0
      utils/watchcat/files/migrate-watchcat
  3. +0
    -10
      utils/watchcat/files/uci_defaults_watchcat
  4. +5
    -0
      utils/watchcat/files/watchcat.config
  5. +38
    -56
      utils/watchcat/files/watchcat.init

+ 8
- 6
utils/watchcat/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=watchcat
PKG_VERSION:=1
PKG_RELEASE:=11
PKG_RELEASE:=12
PKG_MAINTAINER:=Roger D <rogerdammit@gmail.com>
PKG_LICENSE:=GPL-2.0
@ -19,16 +19,16 @@ include $(INCLUDE_DIR)/package.mk
define Package/watchcat
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Enable the configuration of programed reboots
TITLE:=Enable the configuration of programmed reboots or network interface restarts
PKGARCH:=all
endef
define Package/watchcat/description
Allows to configure a periodically reboot, or after losing internet connectivity. Configured trough UCI /etc/config/system.
Restart network interfaces or reboot if pings to hosts fail, or set up periodic reboots. Configured via UCI /etc/config/watchcat
endef
define Package/watchcat/conffiles
/etc/config/system
/etc/config/watchcat
endef
define Build/Compile
@ -36,11 +36,13 @@ endef
define Package/watchcat/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/initd_watchcat $(1)/etc/init.d/watchcat
$(INSTALL_BIN) ./files/watchcat.init $(1)/etc/init.d/watchcat
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/watchcat.sh $(1)/usr/bin/watchcat.sh
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/watchcat.config $(1)/etc/config/watchcat
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/uci_defaults_watchcat $(1)/etc/uci-defaults/50-watchcat
$(INSTALL_BIN) ./files/migrate-watchcat $(1)/etc/uci-defaults/migrate-watchcat
endef
$(eval $(call BuildPackage,watchcat))

+ 27
- 0
utils/watchcat/files/migrate-watchcat View File

@ -0,0 +1,27 @@
#!/bin/sh
. /lib/functions.sh
upgrade_watchcat() {
local cfg="$1"
config_get period "$cfg" period
config_get mode "$cfg" mode
config_get pinghosts "$cfg" pinghosts
config_get forcedelay "$cfg" forcedelay
[ -f "/etc/config/watchcat" ] || touch /etc/config/watchcat
uci_add watchcat watchcat
uci_set watchcat @watchcat[-1] period "$period"
uci_set watchcat @watchcat[-1] mode "$mode"
uci_set watchcat @watchcat[-1] pinghosts "$pinghosts"
uci_set watchcat @watchcat[-1] forcedelay "$forcedelay"
uci_remove system "$cfg"
}
config_load system
config_foreach upgrade_watchcat watchcat
uci_commit watchcat
uci commit system

+ 0
- 10
utils/watchcat/files/uci_defaults_watchcat View File

@ -1,10 +0,0 @@
#!/bin/sh
uci -q show system.@watchcat[0] || {
uci add system watchcat
uci set system.@watchcat[0].period=6h
uci set system.@watchcat[0].mode=ping_reboot
uci set system.@watchcat[0].pinghosts=8.8.8.8
uci set system.@watchcat[0].forcedelay=30
uci commit
}

+ 5
- 0
utils/watchcat/files/watchcat.config View File

@ -0,0 +1,5 @@
config watchcat
option period '6h'
option mode 'ping_reboot'
option pinghosts '8.8.8.8'
option forcedelay '30'

utils/watchcat/files/initd_watchcat → utils/watchcat/files/watchcat.init View File


Loading…
Cancel
Save