Developing lightweight computation at the DSG edge

Commit c65d9013 authored by p4u's avatar p4u
Browse files

Removed unecessari files from qmp-small-node (now they are in qmp-system...

Removed unecessari files from qmp-small-node (now they are in qmp-system package). Modified Makefiles from small and big nodes according to the new package structure
parent 81e8c98e
......@@ -18,6 +18,7 @@
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
......@@ -33,14 +34,13 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-big-node
SECTION:=net
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
DEPENDS:= \
+qmp-small-node \
+qmp-tinyproxy \
+qmp-tinyproxy +tinymce \
+babeld \
+openvpn \
+openssl-util \
+openssl-util +luci-ssl \
+tcptraceroute6 \
+iperf +mtr +netcat \
+tcpdump \
......@@ -48,13 +48,11 @@ define Package/qmp-big-node
+hostapd \
+wget +horst \
+bmon +bwm +ebtables +pv \
+b6m \
+qmp-quagga +qmp-quagga-bgpd +qmp-quagga-ospfd +qmp-quagga-zebra \
+bmx6-qmp-quagga \
+wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \
+ndisc6 +rdisc6 +rdnssd \
+ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath \
+cgi-bin-zero
+ipv6calc +iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath
endef
define Package/qmp-big-node/description
......
......@@ -18,6 +18,7 @@
# the file called "COPYING".
#
# Contributors:
# Pau Escrich <p4u@dabax.net>
# Simó Albert i Beltran
#
......@@ -25,10 +26,10 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-small-node
PKG_RELEASE:=8
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia
QMP_RELEASE:=1.0beta
QMP_RELEASE:=2.0beta
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk
......@@ -36,29 +37,18 @@ include $(INCLUDE_DIR)/package.mk
define Package/qmp-small-node
SECTION:=net
CATEGORY:=qMp
TITLE:=Required addons for small qmp mesh nodes ( 4MByte )
TITLE:=Required addons for small qMp mesh node
URL:=http://qmp.cat
DEPENDS:= \
+uhttpd +luci +luci-lib-nixio \
+luci-ssl +iwinfo \
+qmp-tiny-node \
+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 \
+gwck-qmp +luci-theme-qmp \
+firewall \
+ip \
+6in4 +6to4 \
+ip6tables +ip6tables-utils \
+firewall +synctincvpn \
+kmod-ipip \
+kmod-ip6-tunnel +kmod-iptunnel6 \
+cgi-bin-zero \
+kmod-tun \
+kmod-dummy \
+gwck-qmp \
+b6m-spread \
+b6m +b6m-spread
endef
......@@ -67,11 +57,9 @@ define Package/qmp-small-node/description
endef
define Package/qmp-small-node/conffiles
/etc/config/qmp
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
......@@ -81,24 +69,6 @@ define Build/Compile
endef
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
$(eval $(call BuildPackage,qmp-small-node))
## this config should work for Routerstation(PRO), Alix, Fonera, ...
#
# Contributors:
# Simó Albert i Beltran
#
config 'qmp' 'interfaces'
# option 'configure_switch' 'eth0' # (uncomment line if available, e.g. WGT634U)
option 'lan_devices' 'eth0 wlan1 dummy0' # will be used as is!
option 'wan_devices' 'eth1' # will be used as is!
option 'mesh_devices' 'wlan0 wlan2 eth0 eth1' # will be extended by vlan tag!
config 'qmp' 'node'
option 'primary_device' 'eth0'
option 'community_id' 'qMp'
option 'community_node_id' ''
option 'key' '/tmp/qmp_key'
config 'qmp' 'update'
option 'url' 'http://fw.qmp.cat/testing'
option 'images' 'IMAGES'
option 'devices' 'DEVICES'
option 'filter' 'sysupgrade'
option 'preserve' '/etc/config/qmp /etc/shadow /etc/passwd /etc/rc.local /etc/firewall.user /etc/dropbear/* /etc/config/b6m-spread'
config 'qmp' 'non_overlapping'
option 'ignore' '0' # Each node assings a non-overlapping DHCP IPv4 ranges over a /16 network on lan device
option 'dhcp_offset' '2'
option 'qmp_leasetime' '1h'
config 'qmp' 'networks'
option 'dns' '141.1.1.1 85.126.4.170 202.83.95.227'
option 'lan_address' '172.30.22.1'
option 'lan_netmask' '255.255.255.0'
#option 'publish_lan' '0'
#option 'niit_prefix96' '0:0:0:0:0:ffff' # omit trailing 32 ipv4 bits !
option 'mesh_protocol_vids' 'olsr6:1 bmx6:2' # means olsr6 use vlantag 10+1, bmx6 use vlantag 10+2
option 'mesh_vid_offset' '10'
option 'rescue_prefix24' '169.254' # rescue network prefix, the 16 missing bits are taken from device MAC
option 'olsr6_mesh_prefix48' 'fd01:0:0'
option 'olsr6_ripe_prefix48' '2011:0:0'
option 'olsr6_ipv4_prefix24' '10.201'
# option 'olsr6_ipv4_address' '10.201.9.01'
# option 'olsr6_ipv4_netmask' '255.255.255.0'
# option 'olsr6_6to4_netmask' '120'
option 'bmx6_mesh_prefix48' 'fd02:0:0'
option 'bmx6_ripe_prefix48' '2012:0:0' # suffix is autoconfigured based on community_node_id
option 'bmx6_ipv4_prefix24' '10.202'
# option 'bmx6_ipv4_address' '10.202.9.01/24' # if commented out then option is autoconfigured based on
# community_node_id and bmx6_ipv4_prefix
option 'bmx6_tablePrefTuns' '7000'
option 'bmx6_tableTuns' '70'
option 'bmx6_throwRules' '1'
option 'babel_mesh_prefix48' 'fd03:0:0'
option 'netserver' '1'
config 'qmp' 'tunnels'
option 'search_ipv4_tunnel' '0.0.0.0/0'
option 'search_ipv6_tunnel' '::/0'
# option 'offer_ipv4_tunnel' '0.0.0.0/0'
# option 'offer_ipv6_tunnel' '::/0'
config 'qmp' 'wireless'
option 'driver' 'mac80211'
option 'country' 'SP'
option 'bssid' '02:CA:FF:EE:BA:BE'
#!/bin/sh /etc/rc.common
# 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".
START=99
CONTROL_FILE="/qmp_configured"
QMP_DIR="/etc/qmp"
QMP_KEY="/tmp/qmp_key"
configure() {
echo "Starting qmp configuration..."
echo "Starting qmp configuration..." > /dev/console
echo "[Configuring wireless]"
#Generating default wifi configuration
iw reg set $(uci get qmp.wireless.country) || iw reg set 00
sleep 1
mv /etc/config/wireless /tmp/wireless.old
wifi detect | grep -v disabled > /etc/config/wireless
wifi
#Configuring wifi using QMP
. $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial
qmp_configure_wifi
wifi
#Configuring networking
echo "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh
qmp_configure
#/etc/init.d/network restart
#sleep 3
#QMP_HOSTNAME=$(uci get system.@system[0].hostname)
#echo "Update hostname for: '$QMP_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"
reboot
}
#This function is executed in each boot
startup() {
# Set HostName
. $QMP_DIR/qmp_functions.sh
qmp_set_hosts
# Start/Stop netserver
$QMP_DIR/qmp_control.sh apply_netserver
# Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY
# Hack to enable wifi when channel is not standar
wifi
}
start() {
startup
if [ ! -f "$CONTROL_FILE" ]; then
configure
else
echo "QMP configured. Remove $CONTROL_FILE to force reconfiguration"
fi
}
stop() {
echo "Nothing to do"
}
restart() {
stop
start
}
#!/bin/sh
# Copyright © 2012 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, see <http://www.gnu.org/licenses/>.
#
# Contributors:
# Simó Albert i Beltran
#
# Check if bmx6 is stoped
[ ! -f /proc/$(cat /var/run/bmx6/pid)/status ] && {
echo "[$(date)] Starting bmx6, it was down."
logread > /tmp/bmx6_crash_$(date +%Y%m%d_%H%M).log
/etc/init.d/bmx6 restart
} || {
# Check if there is some interface working
[ $(bmx6 -c show=interfaces| grep -c UP) -le 0 ] && {
echo "[$(date)] There is no interface working, restarting network and bmx6."
logread > /tmp/bmx6_crash_$(date +%Y%m%d_%H%M).log
/etc/init.d/network restart
/etc/init.d/bmx6 restart
}
}
__ _ /\/\ _ __
/ _` |/ \| '_ \
| (_| / /\/\ \ |_) |
\__, \/ \/ .__/
|_| |_|
quick MESH project
#!/bin/sh
# 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".
SOURCE_COMMON=1
#DEBUG="/tmp/qmp_common.debug"
#######################
# UCI related commands
#######################
qmp_uci_get() {
u="$(uci -q get qmp.$1)"
r=$?
echo "$u"
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci get qmp.$1)"
qmp_debug "qmp_uci_get: uci -q get qmp.$1"
return $r
}
qmp_uci_get_raw() {
u="$(uci -q get $@)"
r=$?
echo "$u"
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci get $@)"
qmp_debug "qmp_uci_get_raw: uci -q get $@"
return $r
}
qmp_uci_set() {
uci -q set qmp.$1=$2 > /dev/null
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci set qmp.$1=$2)"
qmp_debug "qmp_uci_set: uci -q set qmp.$1=$2"
return $r
}
qmp_uci_set_raw() {
uci -q set $@ > /dev/null
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci set $@)"
qmp_debug "qmp_uci_set_raw: uci -q set $@"
return $r
}
qmp_uci_del() {
uci -q del qmp.$1
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci del qmp.$1)"
qmp_debug "qmp_uci_del: uci -q del qmp.$1"
return $r
}
qmp_uci_del_raw() {
uci -q del $@
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci del $@)"
qmp_debug "qmp_uci_del_raw uci -q del $@"
return $r
}
qmp_uci_add() {
uci -q add qmp $1 > /dev/null
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci add qmp $1)"
qmp_debug "qmp_uci_add: uci -q add qmp $1"
return $r
}
qmp_uci_add_raw_get_cfg() {
cfg=$(uci -q add $@)
r=$?
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci add $@)"
echo "$cfg"
qmp_debug "qmp_uci_add_raw_get_cfg: uci -q add $@"
return $r
}
qmp_uci_set_cfg() {
uci -q set $@ >/dev/null
qmp_debug "qmp_uci_set_cfg: uci -q set $@"
return $?
}
qmp_uci_commit() {
uci commit $1
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci commit $1)"
qmp_debug "qmp_uci_commit: uci commit $1"
return $r
}
qmp_uci_add_raw() {
uci -q add $@ > /dev/null
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci add $@)"
qmp_debug "qmp_uci_add_raw: uci -q add $@"
return $r
}
qmp_uci_add_list_raw() {
uci -q add_list $@ > /dev/null
r=$?
uci commit
r=$(( $r + $? ))
[ $r -ne 0 ] && logger -t qMp "UCI returned an error (uci add_list $@)"
qmp_debug "qmp_uci_add_list_raw: uci -q add_list $@"
return $r
}
qmp_uci_import() {
cat "$1" | while read v; do
[ ! -z "$v" ] && { uci set $v; qmp_debug "qmp_uci_import: uci set $v"; }
done
uci commit
return $?
}
qmp_uci_test() {
option=$1
u="$(uci get $option > /dev/null 2>&1)"
r=$?
return $r
}
##################################
# Log and errors related commnads
##################################
# Exit from execution and shows an error
# qmp_error The device is burning
qmp_error() {
logger -s -t qMp "ERROR: $@"
exit 1
}
# Send info to system log
# qmp_log qMp is the best
qmp_log() {
logger -s -t qMp "$@"
}
qmp_debug() {
[ ! -z "$DEBUG" ] && echo "$@" >> $DEBUG
}
#######################################
# Networking and Wifi related commands
#######################################
# Returns the names of the wifi devices from the system
qmp_get_wifi_devices() {
echo "$(ip link | grep -E ": (wifi|wlan).: "| cut -d: -f2)"
}
# Returns the MAC address of the wifi devices
qmp_get_wifi_mac_devices() {
echo "$(ip link | grep -A1 -E ": (wifi|wlan).: " | grep link | cut -d' ' -f6)"
}
# 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() {
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|br|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
}
# Returns the mac address of the device
# qmp_get_mac_for_dev eth0
qmp_get_mac_for_dev() {
mac="$(ip link show dev $1 | grep -m 1 "link/ether" | awk '{print $2}')"
[ -z "$mac" ] && mac="00:00:00:00:00:00"
echo "$mac"
}
#########################
# Other kind of commands
#########################
# Print the content of the parameters in reverse order (separed by spaces)
qmp_reverse_order() {
echo "$@" | awk '{for (i=NF; i>0; i--) printf("%s ",$i);print ""}'
}
# Print the output of the command parameter in reverse order (separed by lines)
qmp_tac() {
$@ | awk '{a[NR]=$0} END {for(i=NR;i>0;i--)print a[i]}'
}
qmp_get_dec_node_id() {
PRIMARY_MESH_DEVICE="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
LSB_PRIM_MAC="$( qmp_get_mac_for_dev $PRIMARY_MESH_DEVICE | awk -F':' '{print $6}' )"
if qmp_uci_test qmp.node.community_node_id; then
COMMUNITY_NODE_ID="$(uci get qmp.node.community_node_id)"
elif ! [ -z "$PRIMARY_MESH_DEVICE" ] ; then
COMMUNITY_NODE_ID=$LSB_PRIM_MAC
fi
echo $(printf %d 0x$COMMUNITY_NODE_ID)
}
# Returns the prefix /XX from netmask
qmp_get_prefix_from_netmask() {
echo "$(ipcalc.sh 1.1.1.1 $1| grep PREFIX | cut -d= -f2)"
}
# Returns the netid from IP NETMASK
qmp_get_netid_from_network() {
echo "$(ipcalc.sh $1 $2 | grep NETWORK | cut -d= -f2)"
}
# 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
#
QMP_PATH="/etc/qmp"
. $QMP_PATH/qmp_common.sh
. $QMP_PATH/qmp_functions.sh
. $QMP_PATH/qmp_gw.sh
. $QMP_PATH/qmp_wireless.sh