Browse Source

Merge pull request #579 from oskar456/fix_aiccu

Rework AICCU proto hook
lilik-openwrt-22.03
Steven Barth 10 years ago
parent
commit
c21aa25974
3 changed files with 33 additions and 13 deletions
  1. +3
    -2
      ipv6/aiccu/Makefile
  2. +3
    -0
      ipv6/aiccu/files/aiccu.hotplug
  3. +27
    -11
      ipv6/aiccu/files/aiccu.sh

+ 3
- 2
ipv6/aiccu/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=aiccu PKG_NAME:=aiccu
PKG_VERSION:=20070115 PKG_VERSION:=20070115
PKG_RELEASE:=11
PKG_RELEASE:=12
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix PKG_SOURCE_URL:=http://www.sixxs.net/archive/sixxs/aiccu/unix
@ -47,9 +47,10 @@ define Package/aiccu/conffiles
endef endef
define Package/aiccu/install define Package/aiccu/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto
$(INSTALL_DIR) $(1)/usr/sbin $(1)/lib/netifd/proto $(1)/etc/hotplug.d/ntp
$(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/unix-console/$(PKG_NAME) $(1)/usr/sbin/
$(INSTALL_BIN) ./files/aiccu.sh $(1)/lib/netifd/proto/aiccu.sh $(INSTALL_BIN) ./files/aiccu.sh $(1)/lib/netifd/proto/aiccu.sh
$(INSTALL_DATA) ./files/aiccu.hotplug $(1)/etc/hotplug.d/ntp/10-aiccu
endef endef
$(eval $(call BuildPackage,aiccu)) $(eval $(call BuildPackage,aiccu))

+ 3
- 0
ipv6/aiccu/files/aiccu.hotplug View File

@ -0,0 +1,3 @@
#!/bin/sh
NTPSTRATUMFILE="/var/run/aiccu_ntp_stratum"
echo $stratum > "$NTPSTRATUMFILE"

+ 27
- 11
ipv6/aiccu/files/aiccu.sh View File

@ -14,8 +14,8 @@ proto_aiccu_setup() {
local iface="$2" local iface="$2"
local link="aiccu-$cfg" local link="aiccu-$cfg"
local username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
json_get_vars username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr
local username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr ntpsynctimeout
json_get_vars username password protocol server ip6prefix tunnelid requiretls defaultroute nat heartbeat verbose sourcerouting ip6addr ntpsynctimeout
[ -z "$username" -o -z "$password" ] && { [ -z "$username" -o -z "$password" ] && {
proto_notify_error "$cfg" "MISSING_USERNAME_OR_PASSWORD" proto_notify_error "$cfg" "MISSING_USERNAME_OR_PASSWORD"
@ -27,21 +27,32 @@ proto_aiccu_setup() {
CFGFILE="/var/etc/${link}.conf" CFGFILE="/var/etc/${link}.conf"
PIDFILE="/var/run/${link}.pid" PIDFILE="/var/run/${link}.pid"
NTPSTRATUMFILE="/var/run/aiccu_ntp_stratum"
mkdir -p /var/run /var/etc mkdir -p /var/run /var/etc
echo "username $username" > "$CFGFILE" echo "username $username" > "$CFGFILE"
echo "password $password" >> "$CFGFILE" echo "password $password" >> "$CFGFILE"
echo "ipv6_interface $link" >> "$CFGFILE"
echo "ipv6_interface $link" >> "$CFGFILE"
[ -n "$server" ] && echo "server $server" >> "$CFGFILE" [ -n "$server" ] && echo "server $server" >> "$CFGFILE"
[ -n "$protocol" ] && echo "protocol $protocol" >> "$CFGFILE" [ -n "$protocol" ] && echo "protocol $protocol" >> "$CFGFILE"
[ -n "$tunnelid" ] && echo "tunnel_id $tunnelid" >> "$CFGFILE"
[ -n "$requiretls" ] && echo "requiretls $requiretls" >> "$CFGFILE"
[ "$nat" == 1 ] && echo "behindnat true" >> "$CFGFILE"
[ "$heartbeat" == 1 ] && echo "makebeats true" >> "$CFGFILE"
[ -n "$tunnelid" ] && echo "tunnel_id $tunnelid" >> "$CFGFILE"
[ -n "$requiretls" ] && echo "requiretls $requiretls" >> "$CFGFILE"
[ "$nat" == 1 ] && echo "behindnat true" >> "$CFGFILE"
[ "$heartbeat" == 1 ] && echo "makebeats true" >> "$CFGFILE"
[ "$verbose" == 1 ] && echo "verbose true" >> "$CFGFILE" [ "$verbose" == 1 ] && echo "verbose true" >> "$CFGFILE"
echo "defaultroute false" >> "$CFGFILE" echo "defaultroute false" >> "$CFGFILE"
echo "daemonize true" >> "$CFGFILE"
echo "pidfile $PIDFILE" >> "$CFGFILE"
echo "daemonize true" >> "$CFGFILE"
echo "pidfile $PIDFILE" >> "$CFGFILE"
# By default, wait at most 90 seconds for NTP sync
[ -z "$ntpsynctimeout" ] && ntpsynctimeout=90
for i in $(seq 1 $ntpsynctimeout); do
[ -f "$NTPSTRATUMFILE" ] && \
[ "$(cat $NTPSTRATUMFILE)" -lt 16 ] && \
echo "NTP synced, stratum $(cat $NTPSTRATUMFILE)" && break
[ "$(( $i % 10 ))" -eq 0 ] && echo "Waiting ${i} secs for NTP sync..."
sleep 1
done
aiccu start "$CFGFILE" aiccu start "$CFGFILE"
@ -78,8 +89,12 @@ proto_aiccu_teardown() {
local cfg="$1" local cfg="$1"
local link="aiccu-$cfg" local link="aiccu-$cfg"
CFGFILE="/var/etc/${link}.conf" CFGFILE="/var/etc/${link}.conf"
aiccu stop "$CFGFILE"
PIDFILE="/var/run/${link}.pid"
[ -f "$CFGFILE" -a -f "$PIDFILE" ] && {
local pid="$(cat "$PIDFILE")"
[ -d /proc/$pid -a $(cat /proc/$pid/comm) = "aiccu" ] && \
aiccu stop "$CFGFILE"
}
} }
proto_aiccu_init_config() { proto_aiccu_init_config() {
@ -98,6 +113,7 @@ proto_aiccu_init_config() {
proto_config_add_boolean "nat" proto_config_add_boolean "nat"
proto_config_add_boolean "heartbeat" proto_config_add_boolean "heartbeat"
proto_config_add_boolean "verbose" proto_config_add_boolean "verbose"
proto_config_add_int "ntpsynctimeout"
} }
[ -n "$INCLUDE_ONLY" ] || { [ -n "$INCLUDE_ONLY" ] || {


Loading…
Cancel
Save