Skip to content

Commit

Permalink
Merge pull request #592 from freifunk-berlin/tunnelberlin-tunneldigger
Browse files Browse the repository at this point in the history
add uplink type tunneldigger to the build environment
  • Loading branch information
booo authored Oct 21, 2018
2 parents 4155686 + f6bad3a commit 2ec1d77
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# default parameters for Makefile
SHELL:=$(shell which bash)
TARGET=ar71xx-generic
PACKAGES_LIST_DEFAULT=default tunnel-berlin backbone
PACKAGES_LIST_DEFAULT=default tunnel-berlin-openvpn tunnel-berlin-tunneldigger backbone
OPENWRT_SRC=https://git.openwrt.org/openwrt/openwrt.git
OPENWRT_COMMIT=5f23d0f3db94155ad4b621f68c18de7ad34d598d
SET_BUILDBOT=env
Expand Down
1 change: 1 addition & 0 deletions configs/common.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CONFIG_PACKAGE_freifunk-berlin-statistics-defaults=m
CONFIG_PACKAGE_freifunk-berlin-uhttpd-defaults=m
CONFIG_PACKAGE_freifunk-berlin-uplink-notunnel-files=m
CONFIG_PACKAGE_freifunk-berlin-uplink-tunnelberlin-files=m
CONFIG_PACKAGE_freifunk-berlin-uplink-tunnelberlin-tunneldigger-files=m
CONFIG_PACKAGE_freifunk-common=m
CONFIG_PACKAGE_freifunk-firewall=m
CONFIG_PACKAGE_freifunk-gwcheck=m
Expand Down
2 changes: 1 addition & 1 deletion feeds.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
src-git packages https://github.com/openwrt/packages.git^327a03e8f0c61f8ee98adbee5bd37ce7bccbb049
src-git luci https://github.com/openwrt/luci.git^5ec72617eede467c932642b60291d627fca70342
src-git routing https://github.com/openwrt-routing/packages.git^1b9d1c419f0ecefda51922a7845ab2183d6acd76
src-git packages_berlin https://github.com/freifunk-berlin/firmware-packages.git^bf91159d4fc7df2da5a65dbd67b49d968662eb4e
src-git packages_berlin https://github.com/freifunk-berlin/firmware-packages.git^74ad6ff7e2c7f046eec6b86aa5b5adbd7e0836a0
src-git gluon https://github.com/freifunk-gluon/packages.git^c34d129afb48f225741b683127beee6ba3c169d2

##
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 85 additions & 0 deletions packages/tunnel-berlin-tunneldigger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
-ppp
-ppp-mod-pppoe
-wpad-mini
wpad

# Defaults
freifunk-berlin-dhcp-defaults
freifunk-berlin-firewall-defaults
freifunk-berlin-freifunk-defaults
freifunk-berlin-migration
freifunk-berlin-network-defaults
freifunk-berlin-olsrd-defaults
freifunk-berlin-statistics-defaults
freifunk-berlin-system-defaults
freifunk-berlin-uhttpd-defaults
community-profiles

# Common
mtr
ip
iperf
tmux
vnstat
ethtool
dnsmasq
qos-scripts
firewall
iwinfo
libiwinfo-lua
tcpdump

# GUI-basics
uhttpd
uhttpd-mod-ubus
px5g-mbedtls
libustream-mbedtls
luci-app-ffwizard-berlin
luci-mod-freifunk-ui
luci-app-olsr
luci-app-firewall
luci-app-olsr-services
luci-app-owm
luci-app-owm-ant
luci-app-owm-cmd
luci-app-owm-gui
luci-theme-bootstrap
# GUI addon
luci-i18n-base-de
luci-i18n-base-en
luci-i18n-firewall-de
luci-i18n-firewall-en
luci-i18n-olsr-de
luci-i18n-olsr-en
luci-i18n-statistics-de
luci-i18n-statistics-en

# OLSR
olsrd
olsrd-mod-arprefresh
olsrd-mod-dyn-gw
olsrd-mod-jsoninfo
olsrd-mod-txtinfo
olsrd-mod-nameservice
olsrd-mod-watchdog
kmod-ipip

# BATMAN
kmod-batman-adv
alfred
batctl

# Uplink
freifunk-berlin-uplink-tunnelberlin-tunneldigger-files

# Statistics
luci-app-statistics
collectd
collectd-mod-interface
collectd-mod-iwinfo
collectd-mod-network
collectd-mod-olsrd
collectd-mod-rrdtool
collectd-mod-ping
collectd-mod-uptime
collectd-mod-memory
63 changes: 63 additions & 0 deletions packages/tunnel-berlin-tunneldigger_4MB.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# This is a custom postinst script that gets run by a (patched)
# ImageBuilder Makefile in the target root after installing OpenWrt
# packages, just before building the SquashFS image.

echo "Deleting OLSR i18n files..."
rm -vf usr/lib/lua/luci/i18n/olsr.*

# see https://github.com/freifunk-berlin/firmware/pull/341 &
# https://github.com/freifunk-berlin/firmware/issues/262
cat > lib/upgrade/freiunk-berlin_no-opkg-info-on-4mb-workaround.sh <<'KEEPLIST'
# check for opkg-conffiles that have changed
# this is a workaround for removing opkg from the image and having something
# similar to "opkg list-changed-conffiles"
add_opkg_fix_conffiles()
{
local filelist="$1"
# find the separator line (### opkg conffiles ###) and check all files listed there
# it's just the list of conffiles extracted from opkg-/status during image-creation
content_separator_line=`sed -n '/^### opkg conffiles ###/=' /lib/upgrade/freiunk-berlin_no-opkg-info-on-4mb-workaround.sh`
let content_separator_line++
# iterate over all lines after "separator line"
tail -n +$content_separator_line /lib/upgrade/freiunk-berlin_no-opkg-info-on-4mb-workaround.sh | \
while read filename; do
file_has_changed ${filename} && echo ${filename} >> $filelist
done
}
file_has_changed() {
if cmp -s "$@" "/rom/$@"; then
return 1
else
# modified
return 0
fi
}
sysupgrade_init_conffiles="$sysupgrade_init_conffiles add_opkg_fix_conffiles"
# to exit before going down to the filelist
return 0
### opkg conffiles ###
KEEPLIST

# this is run during firmware-image creation
# add all conffiles known to opkg
echo "adding opkg-conffiles to sysupgrade-hook"
for file in `cat usr/lib/opkg/info/*.conffiles`; do
grep ${file} usr/lib/opkg/status | awk '{ print $1 }' >>lib/upgrade/freiunk-berlin_no-opkg-info-on-4mb-workaround.sh
done

echo "deleting opkg status-files ..."
rm -rf usr/lib/opkg
rm -rf etc/opkg*
# as this will be included into image for some reason, even it's
# not listed for inclusion
echo "manually removing usign ..."
rm usr/bin/usign
rm usr/bin/signify
50 changes: 50 additions & 0 deletions packages/tunnel-berlin-tunneldigger_4MB.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-kmod-usb-core
-kmod-usb2
-kmod-ledtrig-usbdev
-kmod-usb-ohci
-kmod-ppp
-kmod-usb-serial
-ppp
-ppp-mod-pppoe
-wpad
-opkg
-usign

# Defaults
freifunk-berlin-dhcp-defaults
freifunk-berlin-firewall-defaults
freifunk-berlin-freifunk-defaults
freifunk-berlin-migration
freifunk-berlin-network-defaults
freifunk-berlin-olsrd-defaults
freifunk-berlin-system-defaults
community-profiles

# Common
dnsmasq
qos-scripts
firewall
iwinfo
libiwinfo-lua

# GUI
uhttpd
uhttpd-mod-ubus
luci-app-ffwizard-berlin
luci-mod-freifunk-ui
luci-app-olsr
luci-app-olsr-services
luci-app-owm
luci-app-owm-cmd
luci-theme-bootstrap

# OLSR
olsrd
olsrd-mod-arprefresh
olsrd-mod-dyn-gw
olsrd-mod-jsoninfo
olsrd-mod-nameservice
kmod-ipip

# Uplink
freifunk-berlin-uplink-tunnelberlin-tunneldigger-files
141 changes: 141 additions & 0 deletions patches/101-tunneldigger_init.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
--- a/feeds/gluon/net/tunneldigger/files/tunneldigger.init
+++ b/feeds/gluon/net/tunneldigger/files/tunneldigger.init
@@ -8,72 +8,80 @@ PIDPATH=/var/run
tunnel_id=1

missing() {
- echo "Not starting tunneldigger - missing $1" >&2
+ echo "Not starting tunneldigger \"$1\" - missing $2" >&2
}

-config_cb() {
- local cfg="$CONFIG_SECTION"
- config_get configname "$cfg" TYPE
- case "$configname" in
- broker)
- config_get_bool enabled "$cfg" enabled 1
- config_get addresses "$cfg" address
- config_get uuid "$cfg" uuid
- config_get interface "$cfg" interface
- config_get group "$cfg" group
- config_get limit_bw_down "$cfg" limit_bw_down
- config_get hook_script "$cfg" hook_script
- config_get bind_interface "$cfg" bind_interface
- config_get broker_selection "$cfg" broker_selection
+handle_td() {
+ local cfg=$1
+ local enabled
+ local addresses
+ local uuid
+ local interface
+ local group
+ local limit_bw_down
+ local hook_script
+ local bind_interface
+ local broker_selection
+
+
+ config_get_bool enabled "$cfg" enabled 1
+ config_get addresses "$cfg" address
+ config_get uuid "$cfg" uuid
+ config_get interface "$cfg" interface
+ config_get group "$cfg" group
+ config_get limit_bw_down "$cfg" limit_bw_down
+ config_get hook_script "$cfg" hook_script
+ config_get bind_interface "$cfg" bind_interface
+ config_get broker_selection "$cfg" broker_selection

- [ $enabled -eq 0 ] && return
+ [ $enabled -eq 0 ] && return

- local broker_opts=""
- for address in $addresses; do
- append broker_opts "-b ${address}"
- done
-
- [ ! -z "${limit_bw_down}" ] && append broker_opts "-L ${limit_bw_down}"
- [ ! -z "${hook_script}" ] && append broker_opts "-s ${hook_script}"
- [ ! -z "${bind_interface}" ] && {
- # Resolve logical interface name.
- unset _bind_interface
- network_get_device _bind_interface "${bind_interface}" || _bind_interface="${bind_interface}"
- append broker_opts "-I ${_bind_interface}"
- }
- [ ! -z "${broker_selection}" ] && {
- # Set broker selection.
- case "${broker_selection}" in
- usage)
- append broker_opts "-a"
- ;;
- first)
- append broker_opts "-g"
- ;;
- random)
- append broker_opts "-r"
- ;;
- esac
- }
-
- if [ -z "$uuid" ]; then
- missing uuid
- return
- elif [ -z "$interface" ]; then
- missing interface
- return
- fi
-
- echo "Starting tunneldigger on ${interface}"
- /sbin/start-stop-daemon -S -q -b -m -c root:${group} -p ${PIDPATH}/tunneldigger.${interface}.pid -x /usr/bin/tunneldigger -- -u ${uuid} -i ${interface} -t ${tunnel_id} ${broker_opts}
-
- let tunnel_id++
- ;;
- esac
+ local broker_opts=""
+ local address
+ for address in $addresses; do
+ append broker_opts "-b ${address}"
+ done
+
+ [ ! -z "${limit_bw_down}" ] && append broker_opts "-L ${limit_bw_down}"
+ [ ! -z "${hook_script}" ] && append broker_opts "-s ${hook_script}"
+ [ ! -z "${bind_interface}" ] && {
+ # Resolve logical interface name.
+ unset _bind_interface
+ network_get_device _bind_interface "${bind_interface}" || _bind_interface="${bind_interface}"
+ append broker_opts "-I ${_bind_interface}"
+ }
+ [ ! -z "${broker_selection}" ] && {
+ # Set broker selection.
+ case "${broker_selection}" in
+ usage)
+ append broker_opts "-a"
+ ;;
+ first)
+ append broker_opts "-g"
+ ;;
+ random)
+ append broker_opts "-r"
+ ;;
+ esac
+ }
+
+ if [ -z "$uuid" ]; then
+ missing $cfg uuid
+ return
+ elif [ -z "$interface" ]; then
+ missing $cfg interface
+ return
+ fi
+
+ echo "Starting tunneldigger \"$cfg\" on ${interface}"
+ /sbin/start-stop-daemon -S -q -b -m -c root:${group} -p ${PIDPATH}/tunneldigger.${interface}.pid -x /usr/bin/tunneldigger -- -u ${uuid} -i ${interface} -t ${tunnel_id} ${broker_opts}
+
+ let tunnel_id++
}

start() {
config_load tunneldigger
+ config_foreach handle_td broker
}

stop() {
1 change: 1 addition & 0 deletions patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
002-add_ramips-nexx-image.patch
004-openwrt-release_use_configured_revision.patch
005-hostapd_nolegacy_by_default.patch
101-tunneldigger_init.patch
200-wifi_nolegacy_rates_by_default.patch
201-wifi_no_meshfwding_by_default.patch
600-imagebuilder-custom-postinst-script.patch
Expand Down

0 comments on commit 2ec1d77

Please sign in to comment.