Developing lightweight computation at the DSG edge

qmp_autoconf 2.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/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
}