Add gluon-core package

This is the most basic core of the Gluon framework. Most upgrade scripts will
have to be rewritten and/or moved to other packages.
This commit is contained in:
Matthias Schiffer 2013-01-31 10:23:27 +01:00
parent d9902c0664
commit 19b611f8ab
18 changed files with 402 additions and 0 deletions

View File

@ -0,0 +1,35 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-core
PKG_VERSION:=0.3.2.99
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/gluon-core
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Base files of Gluon
endef
define Package/gluon-core/description
The core of the Gluon community wifi mesh firmware framework
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/gluon-core/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,gluon-core))

View File

@ -0,0 +1,69 @@
#!/bin/sh
UPGRADE_DIR=/lib/gluon/upgrade
VERSION_DIR=/lib/gluon/version
version_of() {
opkg status "gluon-$1" | grep '^Version: ' | cut -d' ' -f 2
}
oldversion_of() {
oldversion="$(cat "$VERSION_DIR"/"$1" 2>/dev/null)"
# Legacy support
if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.freifunk_version_keep 2>/dev/null)"; fi
if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.lff_version_keep 2>/dev/null)"; fi
if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.kff_version_keep 2>/dev/null)"; fi
echo "$oldversion"
}
do_dir() {
if [ -d "$1" ]; then
local s
for s in "$1"/*; do "$s"; done
fi
}
version="$(version_of gluon-core)"
oldversion="$(cat "$VERSION_FILE" 2>/dev/null)"
if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_FREIFUNK" 2>/dev/null)"; fi
if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_LFF" 2>/dev/null)"; fi
if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_KFF" 2>/dev/null)"; fi
(
cd "$UPGRADE_DIR"
for component in *; do (
local version="$(version_of "$component")"
if [ -z "$version" ]; then continue; fi
cd "$component"
local oldversion="$(oldversion_of "$component")"
if [ -z "$oldversion" ]; then
do_dir initial
else
local v
for v in *; do
if [ "$v" = initial -o "$v" = invariant -o "$v" = version ]; then continue; fi
# The return value of opkg compare-versions is negated
if ! opkg compare-versions "$v" '>>' "$oldversion"; then
do_dir "$v"
fi
done
fi
do_dir invariant
echo "$version" > "$VERSION_DIR"/"$component"
) done
)
rm -f "$VERSION_FILE_FREIFUNK" "$VERSION_FILE_LFF" "$VERSION_FILE_KFF"

View File

@ -0,0 +1,16 @@
#!/bin/sh
[ -r /etc/config/ffhl ] || exit 0
cp /etc/config/ffhl /etc/config/config_mode
mv /etc/config/ffhl /etc/config/freifunk
uci -q batch <<EOF
delete config_mode.@bandwidth[0]
commit config_mode
delete freifunk.@wizard[0]
commit freifunk
EOF

View File

@ -0,0 +1,4 @@
#!/bin/sh
/etc/init.d/dnsmasq disable
/etc/init.d/telnet disable

View File

@ -0,0 +1,18 @@
#!/bin/sh
get_main_address() {
case "$board" in
tl-wdr3600|tl-wdr4300)
uci get wireless.radio1.macaddr
;;
*)
uci get wireless.radio0.macaddr
;;
esac
}
uci set network.freifunk.proto='none'
uci set network.freifunk.auto='1'
uci set network.freifunk.accept_ra='1'
uci set network.freifunk.macaddr=$(get_main_address)
uci commit network

View File

@ -0,0 +1,17 @@
#!/bin/sh
local interfaces=''
local interfaces_old="$(uci get batman-adv.bat0.interfaces)"
for interface in $interfaces_old; do
if [ $interface != br-wan ]; then interfaces="${interfaces:+${interfaces} }$interface"; fi
done
uci set batman-adv.bat0.interfaces="$interfaces"
old_interval="$(uci -q get batman-adv.bat0.orig_interval)"
if [ -z "$old_interval" -o "$old_interval" = 1000 ]; then
uci set batman-adv.bat0.orig_interval=5000
fi
uci commit batman-adv

View File

@ -0,0 +1,6 @@
#!/bin/sh
uci -q batch <<EOF
set wireless.wifi_freifunk.ssid='luebeck.freifunk.net'
commit wireless
EOF

View File

@ -0,0 +1,9 @@
#!/bin/sh
uci -q batch <<EOF
delete fastd.ffhl_mesh_vpn.config
add_list fastd.ffhl_mesh_vpn.config=/lib/freifunk/mesh-vpn-up.conf
commit fastd
EOF

View File

@ -0,0 +1,5 @@
#!/bin/sh
uci set batman-adv.bat0.interfaces="mesh-vpn $(uci -q get batman-adv.bat0.interfaces)"
uci commit batman-adv

View File

@ -0,0 +1,6 @@
#!/bin/sh
if [ "$(md5sum /etc/avahi/avahi-daemon.conf | cut -d ' ' -f 1)" = e63b3d69311b496c0a06555ea04bc20b ]; then
cp /rom/etc/avahi/avahi-daemon.conf /etc/avahi/avahi-daemon.conf
fi

View File

@ -0,0 +1,33 @@
#!/bin/sh
uci rename fastd.ffhl_mesh_vpn=mesh_vpn
bind="$(uci -q get fastd.mesh_vpn.bind)"
uci -q delete fastd.mesh_vpn.bind
if [ "$bind" -a "$bind" != '0.0.0.0' ]; then
uci add_list fastd.mesh_vpn.bind="$bind"
fi
method="$(uci -q get fastd.mesh_vpn.method)"
uci -q delete fastd.mesh_vpn.method
if [ "$method" ]; then
uci add_list fastd.mesh_vpn.method="$method"
fi
uci -q batch <<EOF
set fastd.mesh_vpn.interface=mesh-vpn
delete fastd.mesh_vpn.config
add_list fastd.mesh_vpn.config=/lib/freifunk/mesh-vpn/fastd.conf
delete fastd.mesh_vpn.config_peer_dir
add_list fastd.mesh_vpn.config_peer_dir=/etc/fastd/mesh-vpn/peers
commit fastd
EOF

View File

@ -0,0 +1,11 @@
#!/bin/sh
(
cd /etc/fastd/ffhl-mesh-vpn/peers
rm -f burgtor holstentor muehlentor huextertor
mv * /etc/fastd/mesh-vpn/peers/ 2>/dev/null || true
)
rmdir -p /etc/fastd/ffhl-mesh-vpn/peers 2>/dev/null || true

View File

@ -0,0 +1,38 @@
#!/bin/sh
. /lib/ar71xx.sh
local board="$(ar71xx_board_name)"
uci -q batch <<EOF
set network.mesh.proto='batadv'
set network.mesh.mesh='bat0'
set network.mesh_vpn='interface'
set network.mesh_vpn.ifname='mesh-vpn'
set network.mesh_vpn.proto='batadv'
set network.mesh_vpn.mesh='bat0'
EOF
get_main_address() {
case "$board" in
tl-wdr3600|tl-wdr4300)
uci get wireless.radio1.macaddr
;;
*)
uci get wireless.radio0.macaddr
;;
esac
}
local mainaddr=$(get_main_address)
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
local b2mask=0x02
local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
uci set network.mesh_vpn.macaddr="$vpnaddr"
uci commit network
uci delete batman-adv.bat0.interfaces
uci commit batman-adv

View File

@ -0,0 +1,40 @@
#!/bin/sh
. /lib/ar71xx.sh
board="$(ar71xx_board_name)"
case "$board" in
tl-wdr3600|\
tl-wdr4300)
macaddr="$(uci get wireless.radio1.macaddr)"
uci -q batch <<EOF
set system.led_wlan2g.trigger='netdev'
set system.led_wlan2g.dev='wlan0'
set system.led_wlan2g.mode='link'
set system.led_wlan5='led'
set system.led_wlan5.name='WLAN5'
set system.led_wlan5.sysfs='ath9k-phy1'
set system.led_wlan5.trigger='netdev'
set system.led_wlan5.dev='wlan1'
set system.led_wlan5.mode='link'
EOF
;;
*)
macaddr="$(uci get wireless.radio0.macaddr)"
uci -q batch <<EOF
set system.led_wlan.trigger='netdev'
set system.led_wlan.dev='wlan0'
set system.led_wlan.mode='link'
EOF
;;
esac
uci -q batch <<EOF
set system.@system[0].hostname='Freifunk-${macaddr//:/}'
set system.@system[0].timezone='CET-1CEST,M3.5.0,M10.5.0/3'
commit system
EOF

View File

@ -0,0 +1,64 @@
#!/bin/sh
. /lib/ar71xx.sh
local lan_ifname="$(uci get network.lan.ifname)"
local board="$(ar71xx_board_name)"
uci -q batch <<EOF
delete network.lan
set network.wan.type='bridge'
set network.wan.proto='dhcp'
set network.wan.accept_ra='0'
set network.wan.auto='1'
set network.freifunk='interface'
set network.freifunk.ifname='$lan_ifname bat0'
set network.freifunk.type='bridge'
set network.freifunk.proto='none'
set network.freifunk.auto='1'
set network.freifunk.accept_ra='1'
set network.mesh='interface'
set network.mesh.proto='batadv'
set network.mesh.mtu='1528'
set network.mesh.mesh='bat0'
set network.mesh_vpn='interface'
set network.mesh_vpn.ifname='mesh-vpn'
set network.mesh_vpn.proto='batadv'
set network.mesh_vpn.mesh='bat0'
EOF
get_main_address() {
case "$board" in
tl-wdr3600|tl-wdr4300)
uci get wireless.radio1.macaddr
;;
*)
uci get wireless.radio0.macaddr
;;
esac
}
local mainaddr=$(get_main_address)
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
local b2mask=0x02
local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
uci set network.freifunk.macaddr="$mainaddr"
uci set network.mesh_vpn.macaddr="$vpnaddr"
case "$board" in
tl-wr1043nd|\
tl-wdr3600|\
tl-wdr4300) # fix up duplicate mac addresses
local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) )
uci set network.wan.macaddr="$wanaddr"
;;
esac
uci commit network

View File

@ -0,0 +1,5 @@
#!/bin/sh
/etc/init.d/dnsmasq disable
/etc/init.d/telnet disable
/etc/init.d/uhttpd disable

View File

@ -0,0 +1,25 @@
#!/bin/sh
uci -q batch <<EOF
delete wireless.radio0.disabled
delete wireless.@wifi-iface[0]
set wireless.radio0.channel='1'
set wireless.radio0.htmode='HT40+'
set wireless.radio0.country='DE'
set wireless.wifi_freifunk='wifi-iface'
set wireless.wifi_freifunk.device='radio0'
set wireless.wifi_freifunk.network='freifunk'
set wireless.wifi_freifunk.mode='ap'
set wireless.wifi_freifunk.ssid='luebeck.freifunk.net'
set wireless.wifi_mesh='wifi-iface'
set wireless.wifi_mesh.device='radio0'
set wireless.wifi_mesh.network='mesh'
set wireless.wifi_mesh.mode='adhoc'
set wireless.wifi_mesh.ssid='02:d1:11:37:fc:38'
set wireless.wifi_mesh.bssid='02:d1:11:37:fc:38'
commit wireless
EOF

View File

@ -0,0 +1 @@
/lib/gluon/version/