diff --git a/root_file_system/default/etc/config/nodewatcher b/root_file_system/default/etc/config/nodewatcher index 6f6389e..4078bee 100644 --- a/root_file_system/default/etc/config/nodewatcher +++ b/root_file_system/default/etc/config/nodewatcher @@ -2,6 +2,7 @@ config 'script' option 'version' '23' option 'error_level' '0' option 'logfile' '/var/log/nodewatcher.log' + option 'sync_hostname' '1' config 'api' option 'ipv4_address' '1' diff --git a/root_file_system/default/etc/nodewatcher.sh b/root_file_system/default/etc/nodewatcher.sh index 0f72e03..f5264e3 100755 --- a/root_file_system/default/etc/nodewatcher.sh +++ b/root_file_system/default/etc/nodewatcher.sh @@ -13,6 +13,7 @@ if [ -f /etc/config/nodewatcher ];then SCRIPT_VERSION=`uci get nodewatcher.@script[0].version` SCRIPT_ERROR_LEVEL=`uci get nodewatcher.@script[0].error_level` SCRIPT_LOGFILE=`uci get nodewatcher.@script[0].logfile` + SCRIPT_SYNC_HOSTNAME=`uci get nodewatcher.@script[0].sync_hostname` CRAWL_METHOD=`uci get nodewatcher.@crawl[0].method` CRAWL_ROUTER_ID=`uci get nodewatcher.@crawl[0].router_id` CRAWL_UPDATE_HASH=`uci get nodewatcher.@crawl[0].update_hash` @@ -38,6 +39,9 @@ fi if [ -n $CLIENT_INTERFACES ]; then CLIENT_INTERFACES="ath0" fi +if [ -n $SCRIPT_SYNC_HOSTNAME ]; then + SCRIPT_SYNC_HOSTNAME="1" +fi API_RETRY=$(($API_RETRY - 1)) @@ -212,19 +216,24 @@ configure() { if [ `echo $ergebnis| cut '-d;' -f1` = "success" ]; then #uci set freifunk.contact.location=`echo $ergebnis| cut '-d;' -f3` - - uci set system.@system[0].hostname=`echo $ergebnis| cut '-d;' -f4` - echo `echo $ergebnis| cut '-d;' -f4` > /proc/sys/kernel/hostname -# uci get system.@system[0].latitude= -# uci get system.@system[0].longitude= -# uci get freifunk.community.ssid= -# uci get freifunk.contact.nickname= -# uci get freifunk.contact.mail= -# uci get freifunk.community.prefix= -# uci get freifunk.contact.note= + if [[ $SCRIPT_SYNC_HOSTNAME = "1" ]]; then + if [ $error_level -gt "1" ]; then + echo "`date`: Setze Hostname" >> $logfile + fi + uci set system.@system[0].hostname=`echo $ergebnis| cut '-d;' -f4` + echo `echo $ergebnis| cut '-d;' -f4` > /proc/sys/kernel/hostname - uci commit +# uci get system.@system[0].latitude= +# uci get system.@system[0].longitude= +# uci get freifunk.community.ssid= +# uci get freifunk.contact.nickname= +# uci get freifunk.contact.mail= +# uci get freifunk.community.prefix= +# uci get freifunk.contact.note= + + uci commit + fi if [ $error_level -gt "1" ]; then echo "`date`: Der Router wurde konfiguriert" >> $logfile fi @@ -442,14 +451,16 @@ crawl() { echo "`date`: Das Senden der Statusdaten war nach dem `expr $i + 1`. Mal erfolgreich" >> $logfile fi - netmon_hostname="`echo $api_return | cut '-d;' -f2`" - if [ "$netmon_hostname" != "`cat /proc/sys/kernel/hostname`" ]; then - if [ $error_level -gt "1" ]; then - echo "`date`: Setze neuen Hostname (Hostname synchronisation)" >> $logfile + if [[ $SCRIPT_SYNC_HOSTNAME = "1" ]]; then + netmon_hostname="`echo $api_return | cut '-d;' -f2`" + if [ "$netmon_hostname" != "`cat /proc/sys/kernel/hostname`" ]; then + if [ $error_level -gt "1" ]; then + echo "`date`: Setze neuen Hostname (Hostname synchronisation)" >> $logfile + fi + uci set system.@system[0].hostname=$netmon_hostname + uci commit + echo $netmon_hostname > /proc/sys/kernel/hostname fi - uci set system.@system[0].hostname=$netmon_hostname - uci commit - echo $netmon_hostname > /proc/sys/kernel/hostname fi break; diff --git a/root_file_system/dir300/etc/config/nodewatcher b/root_file_system/dir300/etc/config/nodewatcher index e7d9385..13a3384 100644 --- a/root_file_system/dir300/etc/config/nodewatcher +++ b/root_file_system/dir300/etc/config/nodewatcher @@ -2,6 +2,7 @@ config 'script' option 'version' '23' option 'error_level' '0' option 'logfile' '/var/log/nodewatcher.log' + option 'sync_hostname' '1' config 'api' option 'ipv4_address' '1' diff --git a/root_file_system/wr1043nd/etc/config/nodewatcher b/root_file_system/wr1043nd/etc/config/nodewatcher index ba61865..55b8e38 100644 --- a/root_file_system/wr1043nd/etc/config/nodewatcher +++ b/root_file_system/wr1043nd/etc/config/nodewatcher @@ -2,6 +2,7 @@ config 'script' option 'version' '23' option 'error_level' '0' option 'logfile' '/var/log/nodewatcher.log' + option 'sync_hostname' '1' config 'api' option 'ipv4_address' '1'