diff options
Diffstat (limited to 'contrib/package/freifunk-common')
9 files changed, 320 insertions, 0 deletions
diff --git a/contrib/package/freifunk-common/Makefile b/contrib/package/freifunk-common/Makefile new file mode 100644 index 0000000000..9c05ed4101 --- /dev/null +++ b/contrib/package/freifunk-common/Makefile @@ -0,0 +1,43 @@ +# 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-common +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/freifunk-common + SECTION:=luci + CATEGORY:=LuCI + SUBMENU:=Freifunk + TITLE:=Freifunk common files + DEPENDS:=freifunk-common +endef + +define Package/freifunk-common/description + Common files and scripts that are needed to run free wireless mesh networks. +endef + +define Package/luci-mod-freifunk/conffiles +/etc/config/freifunk +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/freifunk-common/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,freifunk-common)) diff --git a/contrib/package/freifunk-common/files/etc/config/freifunk b/contrib/package/freifunk-common/files/etc/config/freifunk new file mode 100644 index 0000000000..09d92d92b3 --- /dev/null +++ b/contrib/package/freifunk-common/files/etc/config/freifunk @@ -0,0 +1,129 @@ +package 'freifunk' + +config 'public' 'contact' + option 'nickname' '' + option 'name' '' + option 'mail' '' + option 'phone' '' + option 'location' '' + option 'note' '' + +config 'public' 'community' + option 'name' 'Freifunk' + option 'homepage' 'http://freifunk.net' + +config 'fw_zone' 'zone_freifunk' + option 'name' 'freifunk' + option 'input' 'REJECT' + option 'forward' 'REJECT' + option 'output' 'ACCEPT' + +config 'fw_rule' 'fficmp' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'icmp' + +config 'fw_rule' 'ffhttp' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + option 'dest_port' '80' + +config 'fw_rule' 'ffhttps' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + option 'dest_port' '443' + +config 'fw_rule' 'ffssh' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + option 'dest_port' '22' + +config 'fw_rule' 'ffolsr' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'udp' + option 'dest_port' '698' + +config 'fw_rule' 'ffwprobe' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + option 'dest_port' '17990' + +config 'fw_rule' 'ffdns' + option 'dest_port' '53' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'udp' + +config 'fw_rule' 'ffdhcp' + option 'src_port' '68' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'dest_port' '67' + option 'proto' 'udp' + option 'leasetime' '30m' + +config 'fw_rule' 'ffsplash' + option 'dest_port' '8082' + option 'src' 'freifunk' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + +config 'fw_forwarding' 'lanfffwd' + option 'src' 'lan' + option 'dest' 'freifunk' + +config 'fw_forwarding' 'ffwanfwd' + option 'src' 'freifunk' + option 'dest' 'wan' + +config 'fw_forwarding' 'fffwd' + option 'src' 'freifunk' + option 'dest' 'freifunk' + +config 'include' 'freifunk' + option 'path' '/etc/firewall.freifunk' + +config 'defaults' 'system' + option 'zonename' 'Europe/Berlin' + option 'timezone' 'CET-1CEST,M3.5.0,M10.5.0/3' + +config 'defaults' 'wifi_device' + option 'channel' '1' + option 'diversity' '1' + option 'disabled' '0' + option 'country' 'DE' + option 'hwmode' '11g' + option 'distance' '1000' + +config 'defaults' 'wifi_iface' + option 'mode' 'adhoc' + option 'encryption' 'none' + option 'bgscan' '0' + option 'bssid' '12:CA:FF:EE:BA:BE' + option 'sw_merge' '1' + option 'mcast_rate' '5500' + option 'probereq' '1' + +config 'defaults' 'interface' + option 'netmask' '255.255.0.0' + option 'dns' '8.8.8.8 212.204.49.83 141.1.1.1' + +config 'defaults' 'alias' + option 'netmask' '255.255.255.0' + +config 'defaults' 'dhcp' + option 'leasetime' '30m' + option 'force' '1' + +config 'defaults' 'olsr_interfacedefaults' + option 'Ip4Broadcast' '255.255.255.255' + +config 'defaults' 'upgrade' + option 'repository' 'http://dev.luci.freifunk-halle.net/freifunk-snapshots' + option 'rssfeed' 'http://firmware.leipzig.freifunk.net/kamikaze/.rss.xml' + diff --git a/contrib/package/freifunk-common/files/etc/init.d/freifunk b/contrib/package/freifunk-common/files/etc/init.d/freifunk new file mode 100755 index 0000000000..5ffec43e83 --- /dev/null +++ b/contrib/package/freifunk-common/files/etc/init.d/freifunk @@ -0,0 +1,29 @@ +#!/bin/sh /etc/rc.common +# Freifunk Init +# $Id$ + +START=99 + +boot() { + test -f /etc/crontabs/root || touch /etc/crontabs/root + + grep -q 'killall -HUP dnsmasq' /etc/crontabs/root || { + echo "*/5 * * * * killall -HUP dnsmasq" >> /etc/crontabs/root + } + + grep -q '/usr/sbin/ff_olsr_watchdog' /etc/crontabs/root || { + echo "*/5 * * * * /usr/sbin/ff_olsr_watchdog" >> /etc/crontabs/root + } + + grep -q '/usr/sbin/ff_rdate' /etc/crontabs/root || { + echo "0 */4 * * * /usr/sbin/ff_rdate" >> /etc/crontabs/root + } + + [ -d /etc/rc.local.d ] && { + for file in /etc/rc.local.d/*; do + test -f "$file" && . "$file" + done + } + + ( sleep 40; /usr/sbin/ff_rdate; /etc/init.d/cron restart ) & +} diff --git a/contrib/package/freifunk-common/files/etc/rc.local.d/01-config-migration b/contrib/package/freifunk-common/files/etc/rc.local.d/01-config-migration new file mode 100644 index 0000000000..11f1ad60bc --- /dev/null +++ b/contrib/package/freifunk-common/files/etc/rc.local.d/01-config-migration @@ -0,0 +1,51 @@ +# Fixup various configurations to remove quirks +# from former versions. + +_log() { + logger -t "Config Migration" "$1" +} + +_uci() { + uci ${2:+-c $2} get "$1" 2>/dev/null +} + + +# Splash redirector had a wrong virtual url match +# which resulted in "No such handler" + +[ "$(_uci lucid.splashredir.virtual)" == "/" ] && { + _log "Fix splash redirector configuration" + uci set lucid.splashredir.virtual='' + uci commit lucid + /etc/init.d/lucid restart +} + + +# Newer OLSR versions have the MinTCVtime hack active, +# ensure proper timings or olsrd won't start + +FIX=0 +for i in 0 1 2 3 4; do + [ -z "$(_uci olsrd.@Interface[$i].TcInterval)" ] && \ + [ -z "$(_uci olsrd.@Interface[$i].TcValidityTime)" ] || { + uci delete olsrd.@Interface[$i].TcInterval + uci delete olsrd.@Interface[$i].TcValidityTime + FIX=1 + } +done + +[ "$FIX" == 1 ] && { + _log "Fix olsrd configuration for MinTCVTime hack" + uci commit olsrd + /etc/init.d/olsrd restart +} + + +# Ensure that the community definitions are in the +# new format + +[ -z "$(_uci freifunk.leipzig.mesh_network)" ] && \ +[ -n "$(_uci freifunk.leipzig.mesh_network /rom/etc/config)" ] && { + _log "Converting freifunk configuration to new format" + cp /rom/etc/config/freifunk /etc/config/freifunk +} diff --git a/contrib/package/freifunk-common/files/usr/bin/ffdzero b/contrib/package/freifunk-common/files/usr/bin/ffdzero new file mode 100755 index 0000000000..24e8c2e181 --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/bin/ffdzero @@ -0,0 +1,10 @@ +#!/bin/sh + +test "$1" = "-h" && echo -e "Usage:\n\t$0 -h\n\t$0 [ { ip | hostname } ]" >&2 && exit 1 + +host="${1:-leipzig.freifunk.net}" + +wget -O /dev/null http://$host/cgi-bin-dev-zero.bin +test "$?" = "1" && wget -O /dev/null http://$host/cgi-bin/dev-zero.bin +test "$?" = "1" && wget -O /dev/null http://$host/cgi-bin/luci/freifunk/status/zeroes +test "$?" = "1" && echo "$host: no zero download found..." && exit 1 diff --git a/contrib/package/freifunk-common/files/usr/bin/neigh.sh b/contrib/package/freifunk-common/files/usr/bin/neigh.sh new file mode 100755 index 0000000000..723b813b76 --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/bin/neigh.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +wget -q -O - http://localhost:2006/neighbours|sed -e's/LinkQuality/LQ/;s/Hysteresis/Hyst./;s/Willingness/Will./' diff --git a/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog b/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog new file mode 100755 index 0000000000..aa8de61622 --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog @@ -0,0 +1,29 @@ +#!/usr/bin/lua + +require "os" +require "io" +require "uci" +local fs = require "nixio.fs" + +if fs.access("/var/run/olsrd.pid") then + local stamp, intv + local x = uci.cursor() + + x:foreach("olsrd", "LoadPlugin", + function(s) + if s.library == "olsrd_watchdog.so.0.1" then + intv = tonumber(s.interval) + stamp = s.file + end + end) + + if intv and fs.access(stamp) then + local systime = os.time() + local wdgtime = tonumber(io.lines(stamp)()) + + if not wdgtime or ( systime - wdgtime ) > ( intv * 2 ) then + os.execute("logger -t 'OLSR watchdog' 'Process died - restarting!'") + os.execute("/etc/init.d/olsrd restart") + end + end +end diff --git a/contrib/package/freifunk-common/files/usr/sbin/ff_rdate b/contrib/package/freifunk-common/files/usr/sbin/ff_rdate new file mode 100755 index 0000000000..dc2c7b2d2c --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/sbin/ff_rdate @@ -0,0 +1,20 @@ +#!/bin/sh + +uci_get_one() { + for var in "$@"; do + uci -P /var/state get "$var" 2>/dev/null && break + done +} + +local servers="$(uci_get_one 'network.wan.lease_timesrv') $(uci show timeserver | sed -ne 's/.*hostname=//p')" + +if [ -n "$servers" ]; then + for server in $servers; do + rdate -s $server >/dev/null 2>/dev/null && \ + logger -t rdate "Synced with $server" && break + + logger -t rdate "Failed to sync with $server" + done +else + logger -t rdate "No usable time server found" +fi diff --git a/contrib/package/freifunk-common/ipkg/postinst b/contrib/package/freifunk-common/ipkg/postinst new file mode 100755 index 0000000000..52bedb2d4a --- /dev/null +++ b/contrib/package/freifunk-common/ipkg/postinst @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -n "${IPKG_INSTROOT}" ] || { + /etc/init.d/freifunk enabled || /etc/init.d/freifunk enable + exit 0 +} |