Sync Hostnames with Nodewatcher
This commit is contained in:
parent
cff6d5a1e2
commit
58dcca39ad
4 changed files with 32 additions and 18 deletions
|
@ -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'
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
@ -213,6 +217,10 @@ configure() {
|
|||
if [ `echo $ergebnis| cut '-d;' -f1` = "success" ]; then
|
||||
#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`
|
||||
echo `echo $ergebnis| cut '-d;' -f4` > /proc/sys/kernel/hostname
|
||||
|
||||
|
@ -225,6 +233,7 @@ configure() {
|
|||
# uci get freifunk.contact.note=
|
||||
|
||||
uci commit
|
||||
fi
|
||||
if [ $error_level -gt "1" ]; then
|
||||
echo "`date`: Der Router wurde konfiguriert" >> $logfile
|
||||
fi
|
||||
|
@ -442,6 +451,7 @@ crawl() {
|
|||
echo "`date`: Das Senden der Statusdaten war nach dem `expr $i + 1`. Mal erfolgreich" >> $logfile
|
||||
fi
|
||||
|
||||
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
|
||||
|
@ -451,6 +461,7 @@ crawl() {
|
|||
uci commit
|
||||
echo $netmon_hostname > /proc/sys/kernel/hostname
|
||||
fi
|
||||
fi
|
||||
|
||||
break;
|
||||
else
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Add table
Reference in a new issue