Developing lightweight computation at the DSG edge

Commit 20904212 authored by Isaac Wilder's avatar Isaac Wilder
Browse files

Commiting qmp-fnf-vbox, which checks whether a node is running inside of vbox...

Commiting qmp-fnf-vbox, which checks whether a node is running inside of vbox in uci-defaults, and runs an alternate (working) qmp_autoconf if node is a vbox container
parent 5bc9c186
......@@ -25,7 +25,7 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qmp-fnf-vbox-node
PKG_NAME:=qmp-fnf-vbox
PKG_RELEASE:=2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
QMP_CODENAME:=Ratafia
......@@ -34,7 +34,7 @@ QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
include $(INCLUDE_DIR)/package.mk
define Package/qmp-fnf-vbox-node
define Package/qmp-fnf-vbox
SECTION:=net
CATEGORY:=qMp
TITLE:=vbox mods for qmp-fnf-node
......@@ -53,7 +53,7 @@ define Package/qmp-fnf-vbox-node
+tcpdump-mini +igmpproxy +bwm +collectd
endef
define Package/qmp-fnf-vbox-node/description
define Package/qmp-fnf-vbox/description
Required addons for qMp fnf node (only needed and basic stuff)
endef
......@@ -67,9 +67,10 @@ endef
define Build/Compile
endef
define Package/qmp-fnf-vbox-node/install
define Package/qmp-fnf-vbox/install
$(INSTALL_DIR) $(1)/etc/config
$(CP) ./files/etc/config/qmp $(1)/etc/config/qmp
$(CP) ./files/* $(1)/
chmod 755 $(1)/etc/init.d/qmp_autoconf_no_wireless
endef
$(eval $(call BuildPackage,qmp-fnf-vbox-node))
$(eval $(call BuildPackage,qmp-fnf-vbox))
#!/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".
#
# Contributors:
# Simó Albert i Beltran
#
START=99
STOP=99
SERVICE_DAEMONIZE=1
CONTROL_FILE="/qmp_configured"
BIRTH_FILE="/etc/qmp/.birth"
QMP_DIR="/etc/qmp"
QMP_KEY="/tmp/qmp_key"
QMP_LOG="/root/qmp_autoconf.log"
log() {
echo "$@" > /dev/console
echo "$@"
echo "$@" >> $QMP_LOG
}
exechooks() {
local stage=${1:-anyboot}
. $QMP_DIR/qmp_common.sh
qmp_hooks_exec $stage
}
prepare_wifi() {
# Wifi is complicated...
mv /etc/config/wireless /tmp/wireless.old
# It is a quick hack, because each time ath9k is loaded the phyX counter increases
# and openwrt wifi scripts take the device namw (i.e wlan0) from this counter
# It only works for ath9k
#rmmod ath9k 2>/dev/null
#insmod ath9k 2>/dev/null
#sleep 1
local index=0
iw phy | grep Wiphy | awk '{print $2}' | while read d
do
iw phy $d set name $index
index=$(($index+1))
done
wifi detect | sed s/"disabled 1"/"country $country"/g > /etc/config/wireless
wifi down
wifi up
log WiFi devices:
log --------------------------------------------------
log $(iwinfo | egrep "ESSID|Mode|Type")
log --------------------------------------------------
#To be sure channel is set...
iw reg set $country || iw reg set 00
}
configure() {
log Redirecting stderr to $QMP_LOG
exec 2>>$QMP_LOG
log Starting qmp configuration...
log Waiting 10 seconds to be sure all is configured
sleep 10
# Execute birth hooks if it is the first boot of the device
[ ! -e "$BIRTH_FILE" ] && exechooks birth && touch "$BIRTH_FILE" && log "[First Boot]"
# Execute firstboot hooks
log "[Executing hooks]"
exechooks firstboot
#Reloading network to avoid problems with next functions
log Reloading network
/etc/init.d/network reload
if /etc/init.d/gwck enabled
then
/etc/init.d/gwck restart
fi
#Configuring networking
log "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh
qmp_configure_initial
qmp_configure
log Rebooting
touch "$CONTROL_FILE"
[ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE
}
# This function is executed in each boot
startup() {
# Set HostName
. $QMP_DIR/qmp_system.sh
qmp_set_hosts
[ $(qmp_uci_get services.bwtest) -eq 1 ] && qmp_enable_netserver
# Run hooks
exechooks anyboot
# Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY
}
start() {
if [ ! -e "$CONTROL_FILE" ]; then
configure
else
echo "qMp already configured. Remove $CONTROL_FILE to force reconfiguration"
fi
startup
}
stop() {
log Nothing to do
}
restart() {
stop
start
}
#!/bin/sh
if dmesg | grep VirtualBox; then
rm /etc/rc.d/S99qmp_autoconf
ln -s /etc/init.d/qmp_autoconf_no_wireless /etc/rc.d/S99qmp_autoconf
else
echo "I'm a real node!"
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment