Developing lightweight computation at the DSG edge

Commit 6a9c063f authored by Pau Escrich's avatar Pau Escrich
Browse files

Improve the autoconfiguration system

Make it compatible with OpenWRT BB
parent fd36f16c
......@@ -32,9 +32,8 @@ QMP_KEY="/tmp/qmp_key"
QMP_LOG="/root/qmp_autoconf.log"
log() {
echo "$@" > /dev/console
echo "$@"
echo "$@" >> $QMP_LOG
echo -e "$@" > /dev/console
echo -e "$@"
}
exechooks() {
......@@ -43,70 +42,65 @@ exechooks() {
qmp_hooks_exec $stage
}
stop_services() {
/etc/init.d/dnsmasq stop
/etc/init.d/gwck stop
/etc/init.d/bmx6 stop
/etc/init.d/radvd stop
/etc/init.d/uhttpd stop
}
prepare_wifi() {
finish=0
i=0
while [ $finish -eq 0 ]; do
radios=$(uci show wireless | grep wireless\.radio.*wifi-device -c)
while [ $i -lt $radios ]; do
uci set wireless.radio${i}.disabled="0" 2>/dev/null
uci set wireless.radio${i}.country="$country" 2>/dev/null
finish=$?
i=$(($i+1))
done
uci commit wireless
uci commit wireless
wifi up
sleep 10
log WiFi devices:
log --------------------------------------------------
log $(iwinfo | egrep "ESSID|Mode|Type")
log $(iwinfo)
log --------------------------------------------------
#To be sure channel is set...
iw reg set $country || iw reg set 00
}
configure() {
stop_services
log Redirecting stderr to $QMP_LOG
exec 2>>$QMP_LOG
exec 2>>$QMP_LOG 1>&2
log Starting qmp configuration...
log Waiting 30 seconds to be sure all is configured
sleep 30
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"
# Execute firstboot hooks
log "[Executing hooks]"
exechooks firstboot
#Generating default wifi configuration
# Generating default wifi configuration
log "[Configuring wifi]"
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
log Using countrycode $country
#Configuring wifi using QMP
prepare_wifi
. $QMP_DIR/qmp_wireless.sh
. $QMP_DIR/qmp_functions.sh
log "[Configuring initial system]"
qmp_configure_wifi_initial
qmp_configure_wifi
#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
sleep 1
# Configuring networking and everything else
log "[Configuring full system]"
qmp_configure_initial
qmp_configure
log Rebooting
touch "$CONTROL_FILE"
[ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE
}
......
......@@ -267,11 +267,11 @@ qmp_configure_smart_network() {
} && continue
# if there is already LAN device and it is not wifi, use as WAN
[ -z "$wan" ] && wan="$dev" && continue
# else use as LAN and MESH
lan="$dev $lan"
mesh="$dev $mesh"
[ -z "$wan" ] && wan="$dev" || {
# else use as LAN and MESH
lan="$dev $lan"
mesh="$dev $mesh"
}
done
echo "Network devices found:"
......
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