Sync Hostnames with Nodewatcher

This commit is contained in:
floh1111 2011-07-07 13:08:21 +00:00
parent cff6d5a1e2
commit 58dcca39ad
4 changed files with 32 additions and 18 deletions

View file

@ -2,6 +2,7 @@ config 'script'
option 'version' '23' option 'version' '23'
option 'error_level' '0' option 'error_level' '0'
option 'logfile' '/var/log/nodewatcher.log' option 'logfile' '/var/log/nodewatcher.log'
option 'sync_hostname' '1'
config 'api' config 'api'
option 'ipv4_address' '1' option 'ipv4_address' '1'

View file

@ -13,6 +13,7 @@ if [ -f /etc/config/nodewatcher ];then
SCRIPT_VERSION=`uci get nodewatcher.@script[0].version` SCRIPT_VERSION=`uci get nodewatcher.@script[0].version`
SCRIPT_ERROR_LEVEL=`uci get nodewatcher.@script[0].error_level` SCRIPT_ERROR_LEVEL=`uci get nodewatcher.@script[0].error_level`
SCRIPT_LOGFILE=`uci get nodewatcher.@script[0].logfile` 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_METHOD=`uci get nodewatcher.@crawl[0].method`
CRAWL_ROUTER_ID=`uci get nodewatcher.@crawl[0].router_id` CRAWL_ROUTER_ID=`uci get nodewatcher.@crawl[0].router_id`
CRAWL_UPDATE_HASH=`uci get nodewatcher.@crawl[0].update_hash` CRAWL_UPDATE_HASH=`uci get nodewatcher.@crawl[0].update_hash`
@ -38,6 +39,9 @@ fi
if [ -n $CLIENT_INTERFACES ]; then if [ -n $CLIENT_INTERFACES ]; then
CLIENT_INTERFACES="ath0" CLIENT_INTERFACES="ath0"
fi fi
if [ -n $SCRIPT_SYNC_HOSTNAME ]; then
SCRIPT_SYNC_HOSTNAME="1"
fi
API_RETRY=$(($API_RETRY - 1)) API_RETRY=$(($API_RETRY - 1))
@ -213,6 +217,10 @@ configure() {
if [ `echo $ergebnis| cut '-d;' -f1` = "success" ]; then if [ `echo $ergebnis| cut '-d;' -f1` = "success" ]; then
#uci set freifunk.contact.location=`echo $ergebnis| cut '-d;' -f3` #uci set freifunk.contact.location=`echo $ergebnis| cut '-d;' -f3`
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` uci set system.@system[0].hostname=`echo $ergebnis| cut '-d;' -f4`
echo `echo $ergebnis| cut '-d;' -f4` > /proc/sys/kernel/hostname echo `echo $ergebnis| cut '-d;' -f4` > /proc/sys/kernel/hostname
@ -225,6 +233,7 @@ configure() {
# uci get freifunk.contact.note= # uci get freifunk.contact.note=
uci commit uci commit
fi
if [ $error_level -gt "1" ]; then if [ $error_level -gt "1" ]; then
echo "`date`: Der Router wurde konfiguriert" >> $logfile echo "`date`: Der Router wurde konfiguriert" >> $logfile
fi fi
@ -442,6 +451,7 @@ crawl() {
echo "`date`: Das Senden der Statusdaten war nach dem `expr $i + 1`. Mal erfolgreich" >> $logfile echo "`date`: Das Senden der Statusdaten war nach dem `expr $i + 1`. Mal erfolgreich" >> $logfile
fi fi
if [[ $SCRIPT_SYNC_HOSTNAME = "1" ]]; then
netmon_hostname="`echo $api_return | cut '-d;' -f2`" netmon_hostname="`echo $api_return | cut '-d;' -f2`"
if [ "$netmon_hostname" != "`cat /proc/sys/kernel/hostname`" ]; then if [ "$netmon_hostname" != "`cat /proc/sys/kernel/hostname`" ]; then
if [ $error_level -gt "1" ]; then if [ $error_level -gt "1" ]; then
@ -451,6 +461,7 @@ crawl() {
uci commit uci commit
echo $netmon_hostname > /proc/sys/kernel/hostname echo $netmon_hostname > /proc/sys/kernel/hostname
fi fi
fi
break; break;
else else

View file

@ -2,6 +2,7 @@ config 'script'
option 'version' '23' option 'version' '23'
option 'error_level' '0' option 'error_level' '0'
option 'logfile' '/var/log/nodewatcher.log' option 'logfile' '/var/log/nodewatcher.log'
option 'sync_hostname' '1'
config 'api' config 'api'
option 'ipv4_address' '1' option 'ipv4_address' '1'

View file

@ -2,6 +2,7 @@ config 'script'
option 'version' '23' option 'version' '23'
option 'error_level' '0' option 'error_level' '0'
option 'logfile' '/var/log/nodewatcher.log' option 'logfile' '/var/log/nodewatcher.log'
option 'sync_hostname' '1'
config 'api' config 'api'
option 'ipv4_address' '1' option 'ipv4_address' '1'