@@ -112,6 +112,10 @@ if [ -n "$MANAGEMENT_INTERFACE" ]; then
112112 MANAGEMENT_IP=$( /usr/sbin/openwisp-get-address $MANAGEMENT_INTERFACE )
113113fi
114114
115+ get_model (){ cat /tmp/sysinfo/model; }
116+ get_os (){ ubus call system board | grep description | awk -F\" ' { print $4 }' ; }
117+ get_system (){ ubus call system board | grep system | awk -F\" ' { print $4 }' ; }
118+
115119# ensures we are dealing with the right web server
116120check_header (){
117121 local is_controller=$( grep -c " X-Openwisp-Controller: true" $1 )
@@ -143,9 +147,9 @@ register() {
143147 local backend=" netjsonconfig.OpenWrt"
144148 local tags=$( uci get openwisp.http.tags 2& > /dev/null)
145149 # get device model, OS identifier and SOC info
146- local model=$( cat /tmp/sysinfo/model )
147- local os=$( ubus call system board | grep description | awk -F \" ' { print $4 } ' )
148- local system=$( ubus call system board | grep system | awk -F \" ' { print $4 } ' )
150+ local model=$( get_model )
151+ local os=$( get_os )
152+ local system=$( get_system )
149153 # get hardware id if script is given
150154 if [ -x " $HARDWARE_ID_SCRIPT " ]; then
151155 local hardware_id=$( " $HARDWARE_ID_SCRIPT " )
@@ -339,9 +343,9 @@ apply_configuration() {
339343# send up to date device info to the controller
340344update_info () {
341345 # get device model, OS identifier and SOC info
342- local model=$( cat /tmp/sysinfo/model )
343- local os=$( ubus call system board | grep description | awk -F \" ' { print $4 } ' )
344- local system=$( ubus call system board | grep system | awk -F \" ' { print $4 } ' )
346+ local model=$( get_model )
347+ local os=$( get_os )
348+ local system=$( get_system )
345349 # retry several times
346350 for i in $( seq 1 10) ; do
347351 $FETCH_COMMAND -i \
0 commit comments