No code changes, just formatting. Replace whitespaces with tabs to indent

This commit is contained in:
Clemens John 2013-08-04 16:58:53 +00:00
parent 18111568fb
commit 8f58079510

View file

@ -27,24 +27,24 @@ fi
API_RETRY=$(($API_RETRY - 1)) API_RETRY=$(($API_RETRY - 1))
if [[ $API_IPV4_ADRESS != "1" ]]; then if [[ $API_IPV4_ADRESS != "1" ]]; then
netmon_api=$API_IPV4_ADRESS netmon_api=$API_IPV4_ADRESS
else else
netmon_api="[$API_IPV6_ADRESS"%"$API_IPV6_INTERFACE]" netmon_api="[$API_IPV6_ADRESS"%"$API_IPV6_INTERFACE]"
fi fi
if [ $SCRIPT_ERROR_LEVEL -gt "1" ]; then if [ $SCRIPT_ERROR_LEVEL -gt "1" ]; then
err() { err() {
echo "$(date) [configurator]: $1" >> $SCRIPT_LOGFILE echo "$(date) [configurator]: $1" >> $SCRIPT_LOGFILE
} }
else else
err() { err() {
: :
} }
fi fi
sync_hostname() { sync_hostname() {
err "Syncing hostname" err "Syncing hostname"
api_return=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=get_hostname&authentificationmethod=$CRAWL_METHOD&nickname=$CRAWL_NICKNAME&password=$CRAWL_PASSWORD&router_auto_update_hash=$CRAWL_UPDATE_HASH&router_id=$CRAWL_ROUTER_ID") api_return=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=get_hostname&authentificationmethod=$CRAWL_METHOD&nickname=$CRAWL_NICKNAME&password=$CRAWL_PASSWORD&router_auto_update_hash=$CRAWL_UPDATE_HASH&router_id=$CRAWL_ROUTER_ID")
netmon_hostname=${api_return%,*} netmon_hostname=${api_return%,*}
netmon_hostname=${netmon_hostname#*,} netmon_hostname=${netmon_hostname#*,}
if [ "$netmon_hostname" != "" ]; then if [ "$netmon_hostname" != "" ]; then
@ -54,7 +54,7 @@ sync_hostname() {
uci commit uci commit
echo $netmon_hostname > /proc/sys/kernel/hostname echo $netmon_hostname > /proc/sys/kernel/hostname
else else
err "Hostname is up to date" err "Hostname is up to date"
fi fi
fi fi
} }
@ -63,30 +63,30 @@ assign_router() {
hostname=`cat /proc/sys/kernel/hostname` hostname=`cat /proc/sys/kernel/hostname`
#Choose right login String #Choose right login String
#Here maybe a ; to much at the end..?? #Here maybe a ; to much at the end..??
login_strings=$(awk '{ mac=toupper($1); gsub(":", "", mac); printf mac ";" }' /sys/class/net/br-mesh/address /sys/class/net/eth0/address /sys/class/net/ath0/address 2> /dev/null) login_strings=$(awk '{ mac=toupper($1); gsub(":", "", mac); printf mac ";" }' /sys/class/net/br-mesh/address /sys/class/net/eth0/address /sys/class/net/ath0/address 2> /dev/null)
ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=test_login_strings&login_strings=$login_strings") ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=test_login_strings&login_strings=$login_strings")
router_auto_assign_login_string=${ergebnis#*;} router_auto_assign_login_string=${ergebnis#*;}
ergebnis=${ergebnis%;*} ergebnis=${ergebnis%;*}
if [ "$ergebnis" = "error" ]; then if [ "$ergebnis" = "error" ]; then
router_auto_assign_login_string=${login_strings%%;*} router_auto_assign_login_string=${login_strings%%;*}
err "A router with this login string does not exist: $login_strings" err "A router with this login string does not exist: $login_strings"
err "Using $router_auto_assign_login_string as login string" err "Using $router_auto_assign_login_string as login string"
fi fi
#Try to assign Router with choosen login string #Try to assign Router with choosen login string
ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=router_auto_assign&router_auto_assign_login_string=$router_auto_assign_login_string&hostname=$hostname") ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=router_auto_assign&router_auto_assign_login_string=$router_auto_assign_login_string&hostname=$hostname")
ret=${ergebnis%%;*} ret=${ergebnis%%;*}
errstr=${ergebnis#*;} errstr=${ergebnis#*;}
errstr=${errstr%%;*} errstr=${errstr%%;*}
if [ "$ret" != "success" ]; then if [ "$ret" != "success" ]; then
err "The router has not been assigned to a router in Netmon" err "The router has not been assigned to a router in Netmon"
err "Failure on router_auto_assign: $errstr. Exiting" err "Failure on router_auto_assign: $errstr. Exiting"
exit 0 exit 0
elif [ "$ret" = "success" ]; then elif [ "$ret" = "success" ]; then
update_hash=${ergebnis%;*;*} update_hash=${ergebnis%;*;*}
update_hash=${update_hash##*;} update_hash=${update_hash##*;}
api_key=${ergebnis##*;} api_key=${ergebnis##*;}
#write new config #write new config
uci set configurator.@crawl[0].router_id=$errstr uci set configurator.@crawl[0].router_id=$errstr
uci set configurator.@crawl[0].update_hash=$update_hash uci set configurator.@crawl[0].update_hash=$update_hash
@ -94,7 +94,7 @@ assign_router() {
#set also new router id for nodewatcher #set also new router id for nodewatcher
#uci set nodewatcher.@crawl[0].router_id=$errstr #uci set nodewatcher.@crawl[0].router_id=$errstr
err "The router $errstr has been assigned with a router in Netmon" err "The router $errstr has been assigned with a router in Netmon"
uci commit uci commit
CRAWL_METHOD=`uci get configurator.@crawl[0].method` CRAWL_METHOD=`uci get configurator.@crawl[0].method`
@ -107,18 +107,18 @@ assign_router() {
autoadd_ipv6_address() { autoadd_ipv6_address() {
err "Doing IPv6 autoadd" err "Doing IPv6 autoadd"
ipv6_link_local_addr=$(ip addr show dev br-mesh scope link | awk '/inet6/{print $2}') ipv6_link_local_addr=$(ip addr show dev br-mesh scope link | awk '/inet6/{print $2}')
ipv6_link_local_netmask=${ipv6_link_local_addr##*/} ipv6_link_local_netmask=${ipv6_link_local_addr##*/}
ipv6_link_local_addr=${ipv6_link_local_addr%%/*} ipv6_link_local_addr=${ipv6_link_local_addr%%/*}
ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=autoadd_ipv6_address&authentificationmethod=$CRAWL_METHOD&nickname=$CRAWL_NICKNAME&password=$CRAWL_PASSWORD&router_auto_update_hash=$CRAWL_UPDATE_HASH&router_id=$CRAWL_ROUTER_ID&ip=$ipv6_link_local_addr&netmask=$ipv6_link_local_netmask") ergebnis=$(wget -T $API_TIMEOUT -q -O - "http://$netmon_api/api_csv_configurator.php?section=autoadd_ipv6_address&authentificationmethod=$CRAWL_METHOD&nickname=$CRAWL_NICKNAME&password=$CRAWL_PASSWORD&router_auto_update_hash=$CRAWL_UPDATE_HASH&router_id=$CRAWL_ROUTER_ID&ip=$ipv6_link_local_addr&netmask=$ipv6_link_local_netmask")
ret=${ergebnis%%,*} ret=${ergebnis%%,*}
if [ "$ret" = "success" ]; then if [ "$ret" = "success" ]; then
uci set configurator.@netmon[0].autoadd_ipv6_address='0' uci set configurator.@netmon[0].autoadd_ipv6_address='0'
uci commit uci commit
err "The IPv6 address of the router $CRAWL_ROUTER_ID has been added to the router in Netmon" err "The IPv6 address of the router $CRAWL_ROUTER_ID has been added to the router in Netmon"
err "IPv6 Autoadd has been disabled cause it is no longer necesarry" err "IPv6 Autoadd has been disabled cause it is no longer necesarry"
else else
routerid=${ergebnis##*,} routerid=${ergebnis##*,}
if [ "$routerid" == "$CRAWL_ROUTER_ID" ]; then if [ "$routerid" == "$CRAWL_ROUTER_ID" ]; then
err "The IPv6 address already exists in Netmon on this router. Maybe because of a previos assignment" err "The IPv6 address already exists in Netmon on this router. Maybe because of a previos assignment"
uci set configurator.@netmon[0].autoadd_ipv6_address='0' uci set configurator.@netmon[0].autoadd_ipv6_address='0'
@ -131,16 +131,16 @@ autoadd_ipv6_address() {
} }
if [ $CRAWL_METHOD == "login" ]; then if [ $CRAWL_METHOD == "login" ]; then
err "Authentification method is: username and passwort" err "Authentification method is: username and passwort"
elif [ $CRAWL_METHOD == "hash" ]; then elif [ $CRAWL_METHOD == "hash" ]; then
err "Authentification method: autoassign and hash" err "Authentification method: autoassign and hash"
err "Checking if the router is already assigned to a router in Netmon" err "Checking if the router is already assigned to a router in Netmon"
if [ $CRAWL_UPDATE_HASH == "1" ]; then if [ $CRAWL_UPDATE_HASH == "1" ]; then
err "The router is not assigned to a router in Netmon" err "The router is not assigned to a router in Netmon"
err "Trying to assign the router" err "Trying to assign the router"
assign_router assign_router
else else
err "The router is already assigned to a router in Netmon" err "The router is already assigned to a router in Netmon"
fi fi
fi fi
@ -149,5 +149,5 @@ if [[ $AUTOADD_IPV6_ADDRESS = "1" ]]; then
fi fi
if [[ $SCRIPT_SYNC_HOSTNAME = "1" ]]; then if [[ $SCRIPT_SYNC_HOSTNAME = "1" ]]; then
sync_hostname sync_hostname
fi fi