diff options
Diffstat (limited to 'contrib/package/freifunk-policyrouting')
5 files changed, 0 insertions, 337 deletions
diff --git a/contrib/package/freifunk-policyrouting/Makefile b/contrib/package/freifunk-policyrouting/Makefile deleted file mode 100644 index a9301cef31..0000000000 --- a/contrib/package/freifunk-policyrouting/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2011 Manuel Munz <freifunk at somakoma de> -# This is free software, licensed under the Apache 2.0 license. - -include $(TOPDIR)/rules.mk - -PKG_NAME:=freifunk-policyrouting -PKG_RELEASE:=6 - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) - -include $(INCLUDE_DIR)/package.mk - -define Package/freifunk-policyrouting - SECTION:=luci - CATEGORY:=LuCI - SUBMENU:=9. Freifunk - TITLE:=Freifunk policy routing addon - DEPENDS:=+ip -endef - -define Package/freifunk-policyrouting/description - Allows you to send your own traffic via your own default gateway while sending traffic received from the mesh to a gateway in the mesh. -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Package/freifunk-policyrouting/install - $(CP) ./files/* $(1)/ -endef - -define Package/freifunk-policyrouting/postinst -#!/bin/sh -[ -n "$${IPKG_INSTROOT}" ] || { - /etc/init.d/freifunk-policyrouting enabled || /etc/init.d/freifunk-policyrouting enable - exit 0 -} -endef - -$(eval $(call BuildPackage,freifunk-policyrouting)) diff --git a/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting deleted file mode 100644 index 3dd2998f9f..0000000000 --- a/contrib/package/freifunk-policyrouting/files/etc/config/freifunk-policyrouting +++ /dev/null @@ -1,7 +0,0 @@ - -config 'settings' 'pr' - option 'enable' '0' - option 'strict' '1' - option 'fallback' '1' - option 'zones' '' - diff --git a/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting deleted file mode 100644 index 327e8793be..0000000000 --- a/contrib/package/freifunk-policyrouting/files/etc/hotplug.d/iface/30-policyrouting +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh -. /lib/functions/network.sh - -proto="4" -[ -f /proc/net/ipv6_route ] && proto="4 6" - -config_load freifunk-policyrouting -config_get enable pr enable -config_get fallback pr fallback -config_get strict pr strict -config_get zones pr zones - -if [ "$ACTION" = "ifup" ] && [ "$enable" = "1" ]; then - network_get_subnet net $INTERFACE - network_get_subnet6 net6 $INTERFACE - network_get_physdev dev $INTERFACE - - if [ "$net" != "" -a -n "$dev" ]; then - eval $(/bin/ipcalc.sh $net) - if [ "$PREFIX" != "0" -a "$NETWORK" != "127.0.0.0" ]; then - if [ ! "$(ip r s t localnets |grep "$NETWORK/$PREFIX dev")" ]; then - cmd="ip r a $NETWORK/$PREFIX dev $dev table localnets" - $cmd - if [ "$?" = 0 ]; then - logger -s -t policyrouting "Add route: $cmd" - else - logger -s -t policyrouting "Error! Could not add route: $cmd" - fi - fi - - fi - - if [ -n "$net6" ]; then - cmd="ip -6 r a $net6 dev $dev table localnets" - $cmd 2>&1 > /dev/null - if [ "$?" = 0 ]; then - logger -s -t policyrouting "Add route: $cmd (IPv6)" - fi - - fi - - networks="" - for z in $zones; do - network_zone="$(uci -q get firewall.zone_${z}.network)" - if [ -z "$network_zone" ]; then - network_zone="$z" - fi - networks="$networks $network_zone" - done - for n in $networks; do - if [ "$INTERFACE" = "$n" ]; then - for p in $proto; do - if [ ! "$(ip -$p ru s | grep "from all iif $dev lookup olsr-default")" ]; then - ip -$p rule add dev "$dev" lookup olsr-default prio 20000 - if [ "$strict" != 0 ]; then - ip -$p rule add dev "$dev" unreachable prio 20001 - fi - if [ "$?" = 0 ]; then - logger -s -t policyrouting "Use mesh gateway for interface $dev (IPv$p)" - if [ -z "$(uci -P /var/state get freifunk-policyrouting.${INTERFACE})" ]; then - uci -P /var/state set freifunk-policyrouting.${INTERFACE}="state" - fi - uci -P /var/state set freifunk-policyrouting.${INTERFACE}.device="$dev" - else - logger -s -t policyrouting "Error: Could not add rule: dev "$dev" lookup olsr-default prio 20000 (IPv$p)" - fi - fi - done - fi - done - fi - -fi - -if [ "$ACTION" = "ifdown" ]; then - dev="$(uci -q -P /var/state get freifunk-policyrouting.${INTERFACE}.device)" - if [ -n "$dev" ]; then - networks="" - for z in $zones; do - network_zone="$(uci -q get firewall.zone_${z}.network)" - if [ -z "$network_zone" ]; then - network_zone="$z" - fi - networks="$networks $network_zone" - done - for n in $networks; do - if [ "$INTERFACE" = "$n" ]; then - for p in $proto; do - if [ "$(ip -$p ru s | grep "from all iif $dev lookup olsr-default")" ]; then - ip -$p rule del dev "$dev" lookup olsr-default prio 20000 - ip -$p rule del dev "$dev" unreachable prio 20001 - if [ "$?" = 0 ]; then - logger -s -t policyrouting "Remove rule: dev "$dev" lookup olsr-default prio 20000 (IPv$p)" - else - logger -s -t policyrouting "Error! Could not remove rule: dev "$dev" lookup olsr-default prio 20000 (IPv$p)" - fi - fi - done - fi - done - fi -fi diff --git a/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting deleted file mode 100755 index 4c9172427c..0000000000 --- a/contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=15 -. /lib/functions/network.sh -. /lib/functions.sh - -proto="4" -[ -f /proc/net/ipv6_route ] && proto="4 6" -[ -f /etc/config/olsrd ] && cfgs="olsrd" -[ -f /etc/config/olsrd6 ] && cfgs="$cfgs olsrd6" - -config_load freifunk-policyrouting -config_get enable pr enable -config_get fallback pr fallback -config_get zones pr zones - - -olsrd_rmtables() { - for cfg in $cfgs; do - # Remove custom routing tables from olsrd - if [ "`uci -q get $cfg.@olsrd[0].RtTable`" == "111" ] || [ "`uci -q get $cfg.@olsrd[0].RtTableDefault`" == "112" ]; then - uci delete $cfg.@olsrd[0].RtTable - uci delete $cfg.@olsrd[0].RtTableDefault - uci commit - fi - done -} - -olsrd_intalltables() { - for cfg in $cfgs; do - if [ ! "`uci -q get $cfg.@olsrd[0].RtTable`" == "111" ] || [ ! "`uci -q get $cfg.@olsrd[0].RtTableDefault`" == "112" ]; then - uci set $cfg.@olsrd[0].RtTable='111' - uci set $cfg.@olsrd[0].RtTableDefault='112' - uci commit $cfg - /etc/init.d/$cfg restart 2&> /dev/null - fi - done -} - -rt_tables() { - tables="/etc/iproute2/rt_tables" - if [ -z "`grep "110" $tables`" ]; then - echo "110 localnets" >> $tables - fi - if [ -z "`grep "111" $tables`" ]; then - echo "111 olsr" >> $tables - fi - if [ -z "`grep "112" $tables`" ]; then - echo "112 olsr-default" >> $tables - fi - -} - -handle_disable_dyngw() { - local cfg="$1" - local olsrd_cfg="$2" - config_get library "$cfg" library - case "$library" in - olsrd_dyn_gw_plain*) - config_get RtTable "$cfg" RtTable - if [ -z "$RtTable" ] || [ "$RtTable" = "254" ]; then - config_set "$cfg" ignore '1' - uci set $olsrd_cfg.$cfg.ignore="1" - uci commit $olsrd_cfg - logger -s -t policyrouting -p info "dyngw_plain plugin disabled." - fi - ;; - olsrd_dyn_gw.so*) - logger -s -t policyrouting -p info "$cfg" - uci set $olsrd_cfg.$cfg.ignore="1" - uci commit $olsrd_cfg - logger -s -t policyrouting -p info "dyngw plugin disabled." - ;; - esac -} - -disable_dyngw() { - for olsrd_cfg in $cfgs; do - config_load $olsrd_cfg - config_foreach handle_disable_dyngw LoadPlugin $olsrd_cfg - done -} - -restart_services() { - logger -s -t policyrouting -p info "Restarting services" - /etc/init.d/network restart 2&> /dev/null - for cfg in $cfgs; do - /etc/init.d/$cfg restart 2&> /dev/null - done -} - -boot() { - if [ "$enable" = "1" ]; then - [ -d /var/state ] || mkdir -p /var/state - touch /var/state/freifunk-policyrouting - start noservicerestart - else - olsrd_rmtables - fi -} - -add_lookup_rule() { - name=${1/-/_} - lookup=$2 - prio=$3 - - if [ -z "$name" -o -z "$lookup" -o -z "$prio" ]; then - logger -s -t policyrouting "Missing parameters for add_rule!" - else - for p in $proto; do - if [ "$p" = "6" ]; then - rule="rule6" - else - rule="rule" - fi - - uci batch <<- EOF - set network.${name}ipv${p}="$rule" - set network.${name}ipv${p}.lookup="$lookup" - set network.${name}ipv${p}.priority="$prio" - EOF - done - fi -} - -del_lookup_rule() { - name=${1/-/_} - for p in $proto; do - uci -q delete network.${name}ipv${p} - done -} - -start() { - if [ $enable = "1" ]; then - logger -s -t policyrouting "Starting policy routing." - rt_tables - olsrd_intalltables - disable_dyngw - - add_lookup_rule olsr olsr 1000 - add_lookup_rule localnets localnets 2000 - - if [ "$fallback" = 1 ]; then - add_lookup_rule olsr-default olsr-default 100000 - fi - fi - uci commit network - if [ ! "$1" = "noservicerestart" ]; then - restart_services - fi -} - -stop() { - logger -s -t policyrouting "Stopping policy routing" - olsrd_rmtables - del_lookup_rule olsr-default - del_lookup_rule olsr - del_lookup_rule localnets - uci commit network - restart_services - echo "Hint: To completely disable freifunk-policyrouting set enable=0 in /etc/config/freifunk-policyrouting." -} - -restart() { - logger -s -t policyrouting "Restarting policy routing" - olsrd_rmtables - del_lookup_rule olsr-default - del_lookup_rule olsr - del_lookup_rule localnets - uci commit network - start -} diff --git a/contrib/package/freifunk-policyrouting/files/etc/uci-defaults/freifunk-policyrouting b/contrib/package/freifunk-policyrouting/files/etc/uci-defaults/freifunk-policyrouting deleted file mode 100644 index a1e631015c..0000000000 --- a/contrib/package/freifunk-policyrouting/files/etc/uci-defaults/freifunk-policyrouting +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -uci batch <<-EOF - add ucitrack freifunk-policyrouting - add_list ucitrack.@freifunk-policyrouting[-1].exec="/etc/init.d/freifunk-policyrouting restart" - commit ucitrack -EOF - |