check-swu-version.are
/* DESC: This downloads a Textfile that contains a version number and compares is with the installed software version. 
 * DESC: If the Version if diffrent a software update will be started.
 * Copyright (C) 2017 JJ NetModule AG, Switzerland
 */
 
 
 
updateversionurl="http://share.netmodule.com/public/system-software/latest/NB2710.version";
updateimageurl="http://share.netmodule.com/public/system-software/latest/NB2700_Software_Release.img";
 
 
 
versionfile="swversion.text";
currentversion=nb_status("system").SYSTEM_SOFTWARE;
 
if (nb_transfer_get("","",updateversionurl,versionfile) != -1) {
	nb_syslog("http request worked");
	} else {
	nb_syslog("http request failed");
	exit(1);
	}
 
 
if (file_exists(versionfile)) {	
		fh=fopen(versionfile,"r");
		if (!is_void(fh)) {
		fseek(fh,0);
		line=trim(fgets(fh));
		if (strlen(line) > 2) {
			if (line != currentversion) {
				nb_syslog("Version %s on %s is diffrent to %s, lets start the update",line,updateurl,currentversion);
                          nb_update_software(updateimageurl);
 
			} else {
				nb_syslog("No newer image available, update skipped");
			}
		}
		}
		fclose(fh);
		exit(0);
 
} else {
	nb_syslog("No local file with versionnumber found");
	exit(1);
 
}