Skip to content
Snippets Groups Projects
Commit b153d1da authored by Roland's avatar Roland
Browse files

Initial code for segment assignment by DNS

parent 99aad335
No related branches found
No related tags found
No related merge requests found
include $(TOPDIR)/rules.mk
PKG_NAME:=ffs-set-segment-patches
PKG_VERSION:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(GLUONDIR)/include/package.mk
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
define Package/ffs-set-segment-patches
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Patch files for setting correct segment
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/ffs-set-segment-patches/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/ffs-set-segment $(1)/etc/init.d/ffs-set-segment
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./files/usr/sbin/ffs-set-segment $(1)/usr/sbin/ffs-set-segment
$(INSTALL_DIR) $(1)/usr/lib/micron.d
$(INSTALL_BIN) ./files/usr/lib/micron.d/ffs-set-segment $(1)/usr/lib/micron.d/ffs-set-segment
endef
$(eval $(call BuildPackage,ffs-set-segment-patches))
#!/bin/sh /etc/rc.common
START=97
start () {
uci set fastd.mesh_vpn.on_connect='/usr/sbin/ffs-set-segment'
uci set fastd.mesh_vpn_backbone.auto_segment='1'
/usr/sbin/ffs-set-segment
/etc/init.d/micrond enable
/etc/init.d/micrond restart
}
stop() {
true
}
* * * * * /usr/sbin/ffs-set-segment
#!/bin/sh
if [ $(ps | grep -c "{$(basename $0)}") -gt 4 ]; then
echo started twice
exit 1
fi
if [ $(ps | grep -c "fastd") -lt 2 ]; then
echo fastd not running
exit 1
fi
if [ "$(uci get fastd.mesh_vpn_backbone.auto_segment)" = "0" ]; then
echo auto_segment disabled
exit 1
fi
NODEID=`uci get network.bat0.macaddr`
for i in `seq 1 5`;
do
NODEID=${NODEID/\:/}
done
NODEID=ffs-$NODEID
SEGMENT=`nslookup $NODEID.configserver.selfhosted.de [::1]:54 |tail -n1 `
if [[ -z "${SEGMENT// }" ]]; then
echo Node not known
exit 1
fi
SEGMENT=${SEGMENT/Address 1: 2001:2::/}
let PORT=SEGMENT+10040
SEGNUM=$(printf "%02d" $SEGMENT)
CHANGED=0
for i in `seq 1 10`;
do
GW=$(printf "gw%02d" $i)
OLDPEER=`uci get fastd.mesh_vpn_backbone_peer_$GW.remote`
NEWPEER="\"${GW}s$SEGNUM.freifunk-stuttgart.de\" port $PORT"
if [ "$NEWPEER" != "$OLDPEER" ]; then
uci set fastd.mesh_vpn_backbone_peer_$GW.remote="$NEWPEER"
CHANGED=1
fi
done
if [ "$CHANGED" = "1" ]; then
/etc/init.d/fastd restart
echo Segment set to $SEGNUM
fi
#!/bin/sh
/etc/init.d/ffs-set-segment enable
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment