Developing lightweight computation at the DSG edge

Commit c02639db authored by Simó Albert i Beltran's avatar Simó Albert i Beltran
Browse files

Adapt to OpenWRT 12.09 Attitude Adjustment.

Conflicts:
	packages/qmp-system/files/etc/qmp/qmp_control.sh
parents 6a8c3a22 4c984d89
...@@ -32,12 +32,12 @@ Public Sources: ...@@ -32,12 +32,12 @@ Public Sources:
#PKG_SOURCE_URL:=git://git.bmx6.net/bmx6.git #PKG_SOURCE_URL:=git://git.bmx6.net/bmx6.git
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
PKG_REV:=6073f94f1c127926f290f3ab619d92cb39aea54c PKG_REV:=7219010098ea67f8ea08a06a68e7a765b114ca16
Private Sources: Private Sources:
#PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6-private.git #PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6-private.git
PKG_VERSION:=r2012120204 PKG_VERSION:=r2013022001
PKG_RELEASE:=4 PKG_RELEASE:=4
#PKG_INSTALL:=1 # this tries to install straight to /usr/sbin/bmx6 #PKG_INSTALL:=1 # this tries to install straight to /usr/sbin/bmx6
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# the file called "COPYING". # the file called "COPYING".
# #
# Contributors: # Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran # Simó Albert i Beltran
# #
...@@ -33,14 +34,13 @@ include $(INCLUDE_DIR)/package.mk ...@@ -33,14 +34,13 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-big-node define Package/qmp-big-node
SECTION:=net SECTION:=net
CATEGORY:=qMp CATEGORY:=qMp
TITLE:=Required addons for big qmp mesh nodes (8MByte flash or more) TITLE:=Addons for big qMp mesh node (8MByte flash or more)
URL:=http://qmp.cat URL:=http://qmp.cat
DEPENDS:= \ DEPENDS:= \
+qmp-small-node \ +qmp-small-node \
+qmp-tinyproxy \ +qmp-tinyproxy +tinymce \
+babeld \ +babeld \
+openvpn \ +openssl-util +luci-ssl \
+openssl-util \
+tcptraceroute6 \ +tcptraceroute6 \
+iperf +mtr +netcat \ +iperf +mtr +netcat \
+tcpdump \ +tcpdump \
...@@ -48,13 +48,11 @@ define Package/qmp-big-node ...@@ -48,13 +48,11 @@ define Package/qmp-big-node
+hostapd \ +hostapd \
+wget +horst \ +wget +horst \
+bmon +bwm +ebtables +pv \ +bmon +bwm +ebtables +pv \
+b6m \
+qmp-quagga +qmp-quagga-bgpd +qmp-quagga-ospfd +qmp-quagga-zebra \ +qmp-quagga +qmp-quagga-bgpd +qmp-quagga-ospfd +qmp-quagga-zebra \
+bmx6-qmp-quagga \ +bmx6-qmp-quagga \
+wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \ +wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \
+ndisc6 +rdisc6 +rdnssd \ +ndisc6 +rdisc6 +rdnssd \
+ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath \ +ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath
+cgi-bin-zero
endef endef
define Package/qmp-big-node/description define Package/qmp-big-node/description
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
# #
# Contributors:
# Simó Albert i Beltran
#
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
...@@ -39,8 +42,8 @@ PKG_INSTALL:=1 ...@@ -39,8 +42,8 @@ PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
define Package/qmp-quagga/Default define Package/qmp-quagga/Default
SECTION:=net SECTION:=qMp
CATEGORY:=Network CATEGORY:=qMp
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
DEPENDS:=qmp-quagga DEPENDS:=qmp-quagga
TITLE:=The Quagga Software Routing Suite TITLE:=The Quagga Software Routing Suite
...@@ -50,7 +53,7 @@ endef ...@@ -50,7 +53,7 @@ endef
define Package/qmp-quagga define Package/qmp-quagga
$(call Package/qmp-quagga/Default) $(call Package/qmp-quagga/Default)
DEPENDS:=+librt DEPENDS:=+qmp-quagga-vtysh +qmp-quagga-bgpd
MENU:=1 MENU:=1
endef endef
...@@ -76,6 +79,7 @@ endef ...@@ -76,6 +79,7 @@ endef
define Package/qmp-quagga-libzebra define Package/qmp-quagga-libzebra
$(call Package/qmp-quagga/Default) $(call Package/qmp-quagga/Default)
DEPENDS+=+librt
TITLE:=zebra library TITLE:=zebra library
endef endef
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# the file called "COPYING". # the file called "COPYING".
# #
# Contributors: # Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran # Simó Albert i Beltran
# #
...@@ -25,10 +26,10 @@ include $(TOPDIR)/rules.mk ...@@ -25,10 +26,10 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-small-node PKG_NAME:=qmp-small-node
PKG_RELEASE:=8 PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia QMP_CODENAME:=Ratafia
QMP_RELEASE:=1.0beta QMP_RELEASE:=2.0beta
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M) QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
...@@ -36,29 +37,18 @@ include $(INCLUDE_DIR)/package.mk ...@@ -36,29 +37,18 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-small-node define Package/qmp-small-node
SECTION:=net SECTION:=net
CATEGORY:=qMp CATEGORY:=qMp
TITLE:=Required addons for small qmp mesh nodes ( 4MByte ) TITLE:=Required addons for small qMp mesh node
URL:=http://qmp.cat URL:=http://qmp.cat
DEPENDS:= \ DEPENDS:= \
+uhttpd +luci +luci-lib-nixio \ +qmp-tiny-node \
+luci-ssl +iwinfo \
+ahcpd \ +ahcpd \
+radvd \
+hostapd-mini +wpa-supplicant-mini \
+wireless-tools +iw +netperf \
+bmx6-qmp +bmx6-qmp-uci-config +bmx6-qmp-json +bmx6-qmp-sms +bmx6-luci \
+olsrd +olsrd-mod-txtinfo +olsrd-mod-httpinfo +olsrd-mod-watchdog +olsrd-mod-arprefresh \ +olsrd +olsrd-mod-txtinfo +olsrd-mod-httpinfo +olsrd-mod-watchdog +olsrd-mod-arprefresh \
+gwck-qmp +luci-theme-qmp \ +firewall +synctincvpn \
+firewall \
+ip \
+6in4 +6to4 \
+ip6tables +ip6tables-utils \
+kmod-ipip \ +kmod-ipip \
+kmod-ip6-tunnel +kmod-iptunnel6 \ +cgi-bin-zero \
+kmod-tun \ +kmod-tun \
+kmod-dummy \ +kmod-dummy \
+gwck-qmp \ +b6m +b6m-spread
+b6m-spread \
endef endef
...@@ -67,11 +57,9 @@ define Package/qmp-small-node/description ...@@ -67,11 +57,9 @@ define Package/qmp-small-node/description
endef endef
define Package/qmp-small-node/conffiles define Package/qmp-small-node/conffiles
/etc/config/qmp
endef endef
define Build/Prepare define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef endef
define Build/Configure define Build/Configure
...@@ -81,24 +69,6 @@ define Build/Compile ...@@ -81,24 +69,6 @@ define Build/Compile
endef endef
define Package/qmp-small-node/install define Package/qmp-small-node/install
$(CP) ./files/* $(1)/
$(CP) ./files/etc/config/qmp $(1)/etc/config/qmp.orig
$(SED) 's,$$$$BRANCH,$(BRANCH_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REV,$(REV_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$COD,$(QMP_CODENAME),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REL,$(QMP_RELEASE),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$DATE,$(QMP_BUILDDATE),g' $(1)/etc/uci-defaults/qmp_banner
chmod 755 $(1)/etc/init.d/qmp_autoconf
date +%Y%m%d > $(1)/etc/qmp/qmp.version
echo "QMP_ID=qMp" > $(1)/etc/qmp/qmp.release
echo "QMP_CODENAME=$(QMP_CODENAME)" >> $(1)/etc/qmp/qmp.release
echo "QMP_RELEASE=$(QMP_RELEASE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BRANCH=$(BRANCH_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_REVISION=$(REV_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BUILDDATE=$(QMP_BUILDDATE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_DESCRIPTION=\"qMp $(QMP_CODENAME) $(QMP_RELEASE), $(BRANCH_GIT) rev.$(REV_GIT)-$(QMP_BUILDDATE)\"" >> $(1)/etc/qmp/qmp.release
endef endef
$(eval $(call BuildPackage,qmp-small-node)) $(eval $(call BuildPackage,qmp-small-node))
#!/bin/sh
# Temporal script to re-enable wifi after the boot
# this is to fix a temporaly issue when you are using non-standard wifi chanels
if [ $(cat /etc/rc.local | grep -c ^wifi) -lt 1 ]; then
sed -i -e "/^exit 0/d" /etc/rc.local
echo "wifi" >> /etc/rc.local
fi
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-system
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia
QMP_RELEASE:=2.0beta
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk
define Package/qmp-system
TITLE:=Quick Mesh Project system files
SECTION:=net
CATEGORY:=qMp
URL:=http://qmp.cat
DEPENDS:=
endef
define Package/qmp-system/description
System files for qMp node
endef
define Package/qmp-system/conffiles
/etc/config/qmp
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/qmp-system/install
$(CP) ./files/* $(1)/
$(CP) ./files/etc/config/qmp $(1)/etc/config/qmp.orig
$(SED) 's,$$$$BRANCH,$(BRANCH_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REV,$(REV_GIT),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$COD,$(QMP_CODENAME),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$REL,$(QMP_RELEASE),g' $(1)/etc/uci-defaults/qmp_banner
$(SED) 's,$$$$DATE,$(QMP_BUILDDATE),g' $(1)/etc/uci-defaults/qmp_banner
chmod 755 $(1)/etc/init.d/qmp_autoconf
date +%Y%m%d > $(1)/etc/qmp/qmp.version
echo "QMP_ID=qMp" > $(1)/etc/qmp/qmp.release
echo "QMP_CODENAME=$(QMP_CODENAME)" >> $(1)/etc/qmp/qmp.release
echo "QMP_RELEASE=$(QMP_RELEASE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BRANCH=$(BRANCH_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_REVISION=$(REV_GIT)" >> $(1)/etc/qmp/qmp.release
echo "QMP_BUILDDATE=$(QMP_BUILDDATE)" >> $(1)/etc/qmp/qmp.release
echo "QMP_DESCRIPTION=\"qMp $(QMP_CODENAME) $(QMP_RELEASE), $(BRANCH_GIT) rev.$(REV_GIT)-$(QMP_BUILDDATE)\"" >> $(1)/etc/qmp/qmp.release
endef
$(eval $(call BuildPackage,qmp-system))
...@@ -19,44 +19,54 @@ ...@@ -19,44 +19,54 @@
# the file called "COPYING". # the file called "COPYING".
START=99 START=99
STOP=99
SERVICE_DAEMONIZE=1
CONTROL_FILE="/qmp_configured" CONTROL_FILE="/qmp_configured"
QMP_DIR="/etc/qmp" QMP_DIR="/etc/qmp"
QMP_KEY="/tmp/qmp_key" QMP_KEY="/tmp/qmp_key"
log() {
echo "$@" > /dev/console
echo "$@"
echo "$@" > /tmp/qmp_autoconf.log
}
configure() { configure() {
echo "Starting qmp configuration..." log Starting qmp configuration...
echo "Starting qmp configuration..." > /dev/console
log Waiting 10 seconds to be sure all is configured
sleep 10
echo "[Configuring wireless]" log [Configuring wireless]
#Generating default wifi configuration #Generating default wifi configuration
iw reg set $(uci get qmp.wireless.country) || iw reg set 00 country="$(uci get qmp.wireless.country 2>/dev/null)"
sleep 1 country="${country:-00}"
mv /etc/config/wireless /tmp/wireless.old mv /etc/config/wireless /tmp/wireless.old
wifi detect | grep -v disabled > /etc/config/wireless wifi detect | sed s/"disabled 1"/"country $country"/g > /etc/config/wireless
wifi /etc/init.d/network reload
#To be sure channel is set...
iw reg set $country || iw reg set 00
#Configuring wifi using QMP #Configuring wifi using QMP
. $QMP_DIR/qmp_wireless.sh . $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial qmp_configure_wifi_initial
qmp_configure_wifi qmp_configure_wifi
wifi
#Reloading network to avoid problems with next functions
/etc/init.d/network reload
#Configuring networking #Configuring networking
echo "[Configuring networking]" echo "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh . $QMP_DIR/qmp_functions.sh
qmp_configure qmp_configure
#/etc/init.d/network restart
#sleep 3
#QMP_HOSTNAME=$(uci get system.@system[0].hostname)
#echo "Update hostname for: '$QMP_HOSTNAME'" #echo "Update hostname for: '$QMP_HOSTNAME'"
#echo "$QMP_HOSTNAME" > /proc/sys/kernel/hostname #echo "$QMP_HOSTNAME" > /proc/sys/kernel/hostname
#/etc/init.d/olsrd restart
#/etc/init.d/bmx6 restart
#ifup -a
#/etc/init.d/dnsmasq restart
touch "$CONTROL_FILE" touch "$CONTROL_FILE"
reboot [ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE
} }
#This function is executed in each boot #This function is executed in each boot
...@@ -70,22 +80,20 @@ startup() { ...@@ -70,22 +80,20 @@ startup() {
# Generate current qmp key # Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY logread | md5sum | awk '{print $1}' > $QMP_KEY
# Hack to enable wifi when channel is not standar
wifi
} }
start() { start() {
startup
if [ ! -f "$CONTROL_FILE" ]; then if [ ! -f "$CONTROL_FILE" ]; then
configure configure
else else
echo "QMP configured. Remove $CONTROL_FILE to force reconfiguration" log QMP configured. Remove $CONTROL_FILE to force reconfiguration
fi fi
startup
} }
stop() { stop() {
echo "Nothing to do" log Nothing to do
} }
restart() { restart() {
......
...@@ -188,7 +188,7 @@ qmp_get_wifi_mac_devices() { ...@@ -188,7 +188,7 @@ qmp_get_wifi_mac_devices() {
# Returns the device name that corresponds to the MAC address # Returns the device name that corresponds to the MAC address
# qmp_get_dev_from_mac 00:22:11:33:44:55 # qmp_get_dev_from_mac 00:22:11:33:44:55
qmp_get_dev_from_mac() { qmp_get_dev_from_mac() {
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|br|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)" echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
} }
# Returns the mac address of the device # Returns the mac address of the device
...@@ -199,6 +199,14 @@ qmp_get_mac_for_dev() { ...@@ -199,6 +199,14 @@ qmp_get_mac_for_dev() {
echo "$mac" echo "$mac"
} }
# Returns the mac addres for specific device,, only wifi devs are allowed. Useful when eth and wlan have same MAC
# qmp_get_dev_from_wifi_mac 00:22:11:33:44:55
qmp_get_dev_from_wifi_mac() {
mac="$(ip link | grep -A1 -E ": (wifi|wlan|wl).: " | grep -i $1 -B1 | cut -d' ' -f2 | tr -d "\n",:)"
[ -z "$mac" ] && mac="00:00:00:00:00:00"
echo "$mac"
}
######################### #########################
# Other kind of commands # Other kind of commands
######################### #########################
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# the file called "COPYING". # the file called "COPYING".
# #
# Contributors: # Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran # Simó Albert i Beltran
# #
...@@ -48,7 +49,7 @@ disable_default_gw() { ...@@ -48,7 +49,7 @@ disable_default_gw() {
configure_wifi() { configure_wifi() {
qmp_configure_wifi_initial qmp_configure_wifi_initial
qmp_configure_wifi qmp_configure_wifi
wifi /etc/init.d/network reload
} }
apply_netserver() { apply_netserver() {
...@@ -56,19 +57,15 @@ apply_netserver() { ...@@ -56,19 +57,15 @@ apply_netserver() {
} }
configure_network() { configure_network() {
sleep 1
qmp_configure qmp_configure
/etc/init.d/network restart
#qmp_publish_lan
[ -f "/etc/init.d/olsrd" ] && /etc/init.d/olsrd restart [ -f "/etc/init.d/olsrd" ] && /etc/init.d/olsrd restart
bmx6 -c --configReload || /etc/init.d/bmx6 restart bmx6 -c --configReload || /etc/init.d/bmx6 restart
/etc/init.d/network reload
/etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart
apply_netserver apply_netserver
wifi
} }
configure_system() { configure_system() {
sleep 1
qmp_configure_system qmp_configure_system
/etc/init.d/uhttpd restart /etc/init.d/uhttpd restart
} }
......
...@@ -24,13 +24,14 @@ ...@@ -24,13 +24,14 @@
# #
QMP_PATH="/etc/qmp" QMP_PATH="/etc/qmp"
SOURCE_NETWORK=1 SOURCE_FUNCTIONS=1
####################### #######################
# Importing files # Importing files
###################### ######################
. $QMP_PATH/qmp_common.sh . $QMP_PATH/qmp_common.sh
[ -z "$SOURCE_GW" ] && . $QMP_PATH/qmp_gw.sh [ -z "$SOURCE_GW" ] && . $QMP_PATH/qmp_gw.sh
[ -z "$SOURCE_NET" ] && . $QMP_PATH/qmp_network.sh
# requires ip ipv6calc awk sed grep # requires ip ipv6calc awk sed grep
...@@ -54,6 +55,72 @@ qmp_get_primary_device() { ...@@ -54,6 +55,72 @@ qmp_get_primary_device() {
echo "$primary_mesh_device" echo "$primary_mesh_device"
} }
qmp_check_device() {
ip link show $1 1> /dev/null 2>/dev/null
return $?
}
qmp_set_vlan() {
local viface="$1" # lan/wan/meshX