Skip to content
Snippets Groups Projects
Commit ba16b8bd authored by root's avatar root
Browse files

Added ossibility to set MTU.

parent 5452ccc8
No related branches found
No related tags found
No related merge requests found
#!/bin/sh #!/bin/sh
if [ $(ps | grep -c "{$(basename $0)}") -gt 4 ]; then if [ $(ps | grep -c "{$(basename $0)}") -gt 4 ]; then
echo started twice
exit 1 exit 1
fi fi
if [ $(ps | grep -c "fastd") -lt 2 ]; then if [ $(ps | grep -c "fastd") -lt 2 ]; then
echo fastd not running
exit 0 exit 0
fi fi
if [ "$(uci get fastd.mesh_vpn_backbone.auto_segment)" = "0" ]; then if [ "$(uci get fastd.mesh_vpn_backbone.auto_segment)" = "0" ]; then
echo auto_segment disabled
exit 0 exit 0
fi fi
NODEID=`uci get network.bat0.macaddr` NODEID=`uci get network.bat0.macaddr | sed 's/://g'`
for i in `seq 1 5`; PUBKEY=`/etc/init.d/fastd show_key mesh_vpn | cut -c1-12`
do SEGINFO=`nslookup ffs-$NODEID-$PUBKEY.segassign.freifunk-stuttgart.de [::1]:54 | tail -n1`
NODEID=${NODEID/\:/} if [ -z "$SEGINFO" ]; then
done echo Node not known
NODEID=ffs-$NODEID
SEGMENT=`nslookup $NODEID.segassign.freifunk-stuttgart.de [::1]:54 |tail -n1 `
if [[ -z "${SEGMENT// }" ]]; then
exit 1 exit 1
fi fi
SEGMENT=${SEGMENT/Address 1: 2001:2:0:711::/} SEGINFO=${SEGINFO/Address 1: 2001:2:0:711::/}
NEWMTU=$(echo $SEGINFO | cut -d':' -s -f1)
SEGMENT=$(echo $SEGINFO | cut -d':' -f2)
let PORT=SEGMENT+10040 let PORT=SEGMENT+10040
SEGNUM=$(printf "%02d" $SEGMENT) SEGNUM=$(printf "%02d" $SEGMENT)
CHANGED=0 CHANGED=0
for i in `seq 1 10`; for i in `seq 1 10`;
do do
...@@ -38,6 +40,17 @@ do ...@@ -38,6 +40,17 @@ do
fi fi
done done
if [ -n "$NEWMTU" ]; then
OLDMTU=`uci get fastd.mesh_vpn.mtu`
if [ "$NEWMTU" != "$OLDMTU" ]; then
uci set fastd.mesh_vpn.mtu="$NEWMTU"
CHANGED=1
fi
fi
if [ "$CHANGED" = "1" ]; then if [ "$CHANGED" = "1" ]; then
/etc/init.d/fastd restart /etc/init.d/fastd restart
echo Set Segment: $SEGNUM, MTU: $NEWMTU
else
echo No changes
fi fi
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