mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Initial add of omr-tracker package
This commit is contained in:
parent
34e4384401
commit
17f046fc2a
4 changed files with 244 additions and 0 deletions
10
omr-tracker/files/etc/config/omr-tracker
Normal file
10
omr-tracker/files/etc/config/omr-tracker
Normal file
|
@ -0,0 +1,10 @@
|
|||
config defaults 'defaults'
|
||||
list hosts '51.254.49.132'
|
||||
list hosts '51.254.49.133'
|
||||
option timeout '1'
|
||||
option tries '3'
|
||||
option interval '2'
|
||||
option options 'tracker.overthebox.ovh'
|
||||
|
||||
config rule_type 'tunnel'
|
||||
option tries '5'
|
75
omr-tracker/files/etc/init.d/omr-tracker
Executable file
75
omr-tracker/files/etc/init.d/omr-tracker
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# shellcheck disable=SC2039
|
||||
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
{
|
||||
START=90
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
}
|
||||
|
||||
_validate_section() {
|
||||
local tmp_hosts=$hosts tmp_timeout=$timeout tmp_tries=$tries
|
||||
local tmp_interval=$interval tmp_options=$options
|
||||
|
||||
uci_validate_section omr-tracker "$1" "$2" \
|
||||
'hosts:list(host)' \
|
||||
'timeout:uinteger' \
|
||||
'tries:uinteger' \
|
||||
'interval:uinteger' \
|
||||
'options:string'
|
||||
|
||||
[ -z "$hosts" ] && hosts=$tmp_hosts
|
||||
[ -z "$timeout" ] && timeout=$tmp_timeout
|
||||
[ -z "$tries" ] && tries=$tmp_tries
|
||||
[ -z "$interval" ] && interval=$tmp_interval
|
||||
[ -z "$options" ] && options=$tmp_options
|
||||
}
|
||||
|
||||
_launch_tracker() {
|
||||
case "$1" in
|
||||
loopback|lan*|if0*|glorytun*) return;;
|
||||
esac
|
||||
|
||||
local interface_type
|
||||
config_get interface_type "$1" type
|
||||
|
||||
local hosts timeout tries interval options
|
||||
_validate_section "defaults" "defaults"
|
||||
_validate_section "rule_type" "$interface_type"
|
||||
_validate_section "interface" "$1"
|
||||
|
||||
local ifname ip4table
|
||||
config_get ifname "$1" ifname
|
||||
config_get multipath "$1" multipath
|
||||
|
||||
[ -z "$ifname" ] || [ -z "$multipath" ] || [ "$multipath" = "off" ] && return
|
||||
|
||||
procd_open_instance
|
||||
# shellcheck disable=SC2086
|
||||
procd_set_param command /bin/omr-tracker "$1" $options
|
||||
procd_append_param env "OMR_TRACKER_HOSTS=$hosts"
|
||||
procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout"
|
||||
procd_append_param env "OMR_TRACKER_TRIES=$tries"
|
||||
procd_append_param env "OMR_TRACKER_INTERVAL=$interval"
|
||||
procd_append_param env "OMR_TRACKER_TABLE=$ip4table"
|
||||
procd_append_param env "OMR_TRACKER_DEVICE=$ifname"
|
||||
procd_set_param respawn 0 10 0
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load network
|
||||
config_foreach _launch_tracker interface
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger omr-tracker network
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue