Developing lightweight computation at the DSG edge

Commit 2fcbe6b9 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Make qmp_autoconf log more readable


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 99616e6c
...@@ -52,19 +52,24 @@ stop_services() { ...@@ -52,19 +52,24 @@ stop_services() {
prepare_wifi() { prepare_wifi() {
i=0 i=0
radios=$(uci show wireless | grep wireless\.radio.*wifi-device -c) radios=$(uci show wireless | grep wireless\.radio.*wifi-device -c)
log "Detected $radios WiFi device(s)"
while [ $i -lt $radios ]; do while [ $i -lt $radios ]; do
log "Enabling radio${i}"
uci set wireless.radio${i}.disabled="0" 2>/dev/null uci set wireless.radio${i}.disabled="0" 2>/dev/null
uci set wireless.radio${i}.country="$country" 2>/dev/null uci set wireless.radio${i}.country="$country" 2>/dev/null
i=$(($i+1)) i=$(($i+1))
done done
uci commit wireless uci commit wireless
log "Enabling WiFi and waiting 5 seconds to come up..."
wifi up wifi up
sleep 10 sleep 5
log ""
log WiFi devices:
log "Detected WiFi devices:"
log -------------------------------------------------- log --------------------------------------------------
log $(iwinfo) log "$(iwinfo)"
log -------------------------------------------------- log --------------------------------------------------
} }
...@@ -72,60 +77,79 @@ configure() { ...@@ -72,60 +77,79 @@ configure() {
stop_services stop_services
log Redirecting stderr to $QMP_LOG log Redirecting stderr to $QMP_LOG
exec 2>>$QMP_LOG 1>&2 exec 2>>$QMP_LOG 1>&2
log Starting qmp configuration... log "[Starting qMp autoconfiguration]"
log Waiting 10 seconds to be sure all is configured log "Waiting 15 seconds to make sure everything else is ready..."
sleep 10 sleep 15
log "... done!"
log ""
log "[Preparing wifi]" log "[WiFi devices detection]"
country="$(uci get qmp.wireless.country 2>/dev/null)" country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-US}" country="${country:-US}"
log Using countrycode $country log "Using country code $country."
log "Preparing wifi devices"
prepare_wifi prepare_wifi
log "... done!"
log ""
# Execute birth hooks if it is the first boot of the device # Execute birth hooks if it is the first boot of the device
log "[Birth hooks]"
[ ! -e "$BIRTH_FILE" ] && exechooks birth && touch "$BIRTH_FILE" [ ! -e "$BIRTH_FILE" ] && exechooks birth && touch "$BIRTH_FILE"
log "... done!"
log ""
# Configure system and reboot # Configure system and reboot
log "[Loading qMp functions]"
. $QMP_DIR/qmp_functions.sh . $QMP_DIR/qmp_functions.sh
log "[Configuring initial system]" log "... done!"
log ""
log "[Initial qMp system configuration]"
qmp_configure_initial qmp_configure_initial
log "[Configuring full system]" log "... done!"
log ""
log "[Full qMp system configuration]"
qmp_configure qmp_configure
log "... done!"
log ""
log Rebooting log "[Finishing qMp autoconfiguration]"
touch "$CONTROL_FILE" touch "$CONTROL_FILE"
[ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE [ -f "$CONTROL_FILE" ] && log "Rebooting..." && reboot || log "CRITICAL ERROR, cannot write file $CONTROL_FILE"
} }
# This function is executed in each boot # This function is executed on each boot
startup() { startup() {
# Set HostName # Set HostName
. $QMP_DIR/qmp_system.sh . $QMP_DIR/qmp_system.sh
qmp_set_hosts qmp_set_hosts
[ $(qmp_uci_get services.bwtest) -eq 1 ] && qmp_enable_netserver [ $(qmp_uci_get services.bwtest) -eq 1 ] && qmp_enable_netserver
# Run hooks # Run hooks
exechooks anyboot exechooks anyboot
# Generate current qmp key # Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY logread | md5sum | awk '{print $1}' > $QMP_KEY
# Start firewall # Start firewall
sh /etc/firewall.user sh /etc/firewall.user
} }
start() { start() {
if [ ! -e "$CONTROL_FILE" ]; then if [ ! -e "$CONTROL_FILE" ]; then
echo "qMp is not configured. Starting autoconfiguration..."
echo ""
configure configure
else else
echo "qMp already configured. Remove $CONTROL_FILE to force reconfiguration" echo "qMp is already configured. Delete file $CONTROL_FILE to force reconfiguration."
fi fi
startup startup
} }
stop() { stop() {
log Nothing to do log "Nothing to do"
} }
restart() { restart() {
......
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