2022-01-06 21:03:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# check if wireguard
|
|
|
|
if [ "${DEVTYPE}" != "wireguard" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if correct naming
|
|
|
|
slicedint=$(echo $INTERFACE | cut -c1-3)
|
|
|
|
if [ "${slicedint}" != "wg_" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${ACTION}" == "add" ]; then
|
|
|
|
uci add olsrd Interface
|
|
|
|
uci set olsrd.@Interface[-1].ignore=0
|
|
|
|
uci set olsrd.@Interface[-1].interface="${INTERFACE}"
|
|
|
|
uci set olsrd.@Interface[-1].Mode="ether"
|
2022-01-11 11:18:49 +00:00
|
|
|
uci get wgserver.@olsrd_hotplug[0].LinkQualityMult
|
|
|
|
if [ $? ]; then
|
|
|
|
olsrd_LinkQualityMult="$(uci get wgserver.@olsrd_hotplug[0].LinkQualityMult)"
|
|
|
|
uci set olsrd.@Interface[-1].LinkQualityMult="$olsrd_LinkQualityMult"
|
|
|
|
fi
|
2022-01-10 22:56:36 +00:00
|
|
|
uci -c "$(dirname $(realpath /etc/config/olsrd))" commit olsrd
|
2022-01-06 21:03:18 +00:00
|
|
|
/etc/init.d/olsrd reload
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${ACTION}" == "remove" ]; then
|
|
|
|
i=0
|
|
|
|
while uci get olsrd.@Interface[$i] &> /dev/null ; do
|
|
|
|
if [ "$(uci get olsrd.@Interface[$i].interface)" == "${INTERFACE}" ]; then
|
|
|
|
uci delete olsrd.@Interface[$i]
|
|
|
|
fi
|
|
|
|
i=$((i+1));
|
|
|
|
done
|
2022-01-10 22:56:36 +00:00
|
|
|
uci -c "$(dirname $(realpath /etc/config/olsrd))" commit olsrd
|
2022-01-06 21:03:18 +00:00
|
|
|
/etc/init.d/olsrd reload
|
|
|
|
fi
|