mirror of
https://github.com/kenzok8/small-package
synced 2025-01-05 11:36:47 +08:00
update 2024-12-09 20:42:59
This commit is contained in:
parent
08ce0bb47f
commit
8ea888f6fd
@ -7,7 +7,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=floatip
|
||||
PKG_VERSION:=1.0.6
|
||||
PKG_VERSION:=1.0.8
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
|
||||
|
||||
|
@ -64,19 +64,25 @@ set_lan_ping() {
|
||||
/etc/init.d/firewall reload 2>&1
|
||||
}
|
||||
|
||||
safe_sleep() {
|
||||
local sec="$1"
|
||||
[[ "$sec" -lt 1 ]] && sec=1
|
||||
sleep $sec
|
||||
}
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
fallback_loop() {
|
||||
local set_ip check_ip set_net set_prefix
|
||||
config_get set_ip "main" set_ip
|
||||
config_get check_ip "main" check_ip
|
||||
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32"
|
||||
[[ -n "$set_ip" ]] || return 1
|
||||
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX"
|
||||
eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP
|
||||
[[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0
|
||||
[[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX
|
||||
[[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3
|
||||
local ipaddr="$set_ip/$set_prefix"
|
||||
echo "ipaddr=$ipaddr"
|
||||
|
||||
local valid_check_ip cip
|
||||
config_get check_ip "main" check_ip
|
||||
for cip in $check_ip; do
|
||||
eval "$(ipcalc.sh $cip/$set_prefix )"
|
||||
[[ "$NETWORK" = "$set_net" ]] && valid_check_ip="$valid_check_ip $cip"
|
||||
@ -108,16 +114,16 @@ fallback_loop() {
|
||||
else
|
||||
dead_counter=0
|
||||
fi
|
||||
[[ $consume_time -lt 10 ]] && sleep $((10 - $consume_time))
|
||||
safe_sleep $((10 - $consume_time))
|
||||
continue
|
||||
fi
|
||||
if [[ $floatip_up = 1 ]]; then
|
||||
[[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time))
|
||||
safe_sleep $((5 - $consume_time))
|
||||
continue
|
||||
fi
|
||||
dead_counter=$(($dead_counter + 1))
|
||||
if [[ $dead_counter -lt 3 ]]; then
|
||||
[[ $consume_time -lt 10 ]] && sleep $((10 - $consume_time))
|
||||
safe_sleep $((10 - $consume_time))
|
||||
continue
|
||||
fi
|
||||
echo "no host alive, set up floatip $ipaddr" >&2
|
||||
@ -128,14 +134,13 @@ fallback_loop() {
|
||||
}
|
||||
|
||||
main_loop() {
|
||||
local set_ip set_net set_prefix
|
||||
local set_ip set_prefix
|
||||
config_get set_ip "main" set_ip
|
||||
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32"
|
||||
eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP
|
||||
[[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0
|
||||
[[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX
|
||||
[[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3
|
||||
[[ -n "$set_ip" ]] || return 1
|
||||
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX"
|
||||
eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP
|
||||
local ipaddr="$set_ip/$set_prefix"
|
||||
echo "ipaddr=$ipaddr"
|
||||
|
||||
local check_urls check_url_timeout
|
||||
config_get check_urls "main" check_url
|
||||
@ -177,14 +182,16 @@ main_loop() {
|
||||
set_up "$ipaddr"
|
||||
floatip_up=1
|
||||
fi
|
||||
else
|
||||
set_lan_ping 0
|
||||
fi
|
||||
[[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time))
|
||||
safe_sleep $((5 - $consume_time))
|
||||
continue
|
||||
else
|
||||
if [[ $url_pass = 0 ]]; then
|
||||
dead_counter=$(($dead_counter + 1))
|
||||
if [[ $dead_counter -lt 3 ]]; then
|
||||
[[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time))
|
||||
safe_sleep $((5 - $consume_time))
|
||||
continue
|
||||
fi
|
||||
echo "set down floatip, and disable ping" >&2
|
||||
|
@ -1,12 +1,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=geoview
|
||||
PKG_VERSION:=0.0.9
|
||||
PKG_VERSION:=0.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/snowie2000/geoview/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=ba0af14cd7a6ce457584ab4754331848ed78240ae39abdf65fef646df0130c2e
|
||||
PKG_HASH:=f957ccda8177657ce386c2a823cdf0d2746a0c03ce2e1a767cf9da12dccc476b
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
Loading…
Reference in New Issue
Block a user