From 7c60112537c50a48f8dff1421ec7e7eae15c506e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Aug 2016 09:20:50 +0100 Subject: [PATCH] Completion file may not exist on the mesh --- src/freedombone-mesh-batman | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index 49c8ce6e..b8046f18 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -42,23 +42,22 @@ if [[ $1 == "start" ]]; then fi # Mesh definition -WIFI_SSID= -if ! grep -q "WIFI_SSID:" $COMPLETION_FILE; then - WIFI_SSID='mesh' -else - WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}') +WIFI_SSID='mesh' +if [ -f $COMPLETION_FILE ]; then + if grep -q "WIFI_SSID:" $COMPLETION_FILE; then + WIFI_SSID=$(cat $COMPLETION_FILE | grep "WIFI_SSID:" | awk -F ':' '{print $2}') + fi + sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE fi -sed -i "s|WIFI_SSID:.*|WIFI_SSID:${WIFI_SSID}|g" $COMPLETION_FILE - CELLID='any' -CHANNEL= -if ! grep -q "Wifi channel:" $COMPLETION_FILE; then - CHANNEL=2 -else - CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}') +CHANNEL=2 +if [ -f $COMPLETION_FILE ]; then + if grep -q "Wifi channel:" $COMPLETION_FILE; then + CHANNEL=$(cat $COMPLETION_FILE | grep "Wifi channel:" | awk -F ':' '{print $2}') + fi + sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE fi -sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE ZERONET_PORT=15441 IPFS_PORT=4001