mirror of
				https://github.com/Telecominfraproject/ols-ucentral-schema.git
				synced 2025-10-31 18:17:45 +00:00 
			
		
		
		
	schema: fix log generation
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
		| @@ -17,33 +17,38 @@ inputfile.close(); | |||||||
| let logs = []; | let logs = []; | ||||||
|  |  | ||||||
| try { | try { | ||||||
| 	let batch = renderer.render(schemareader.validate(inputjson), logs); | 	let state = schemareader.validate(inputjson, logs); | ||||||
|  |  | ||||||
|  | 	let batch = state ? renderer.render(state, logs) : ""; | ||||||
|  |  | ||||||
| 	fs.stdout.write("Log messages:\n" + join("\n", logs) + "\n\n"); | 	fs.stdout.write("Log messages:\n" + join("\n", logs) + "\n\n"); | ||||||
|  |  | ||||||
| 	fs.stdout.write("UCI batch output:\n" + batch + "\n"); | 	fs.stdout.write("UCI batch output:\n" + batch + "\n"); | ||||||
|  |  | ||||||
| 	let outputjson = fs.open("/tmp/ucentral.uci", "w"); | 	if (state) { | ||||||
| 	outputjson.write(batch); | 		let outputjson = fs.open("/tmp/ucentral.uci", "w"); | ||||||
| 	outputjson.close(); | 		outputjson.write(batch); | ||||||
|  | 		outputjson.close(); | ||||||
|  |  | ||||||
| 	for (let cmd in [ 'rm -rf /tmp/config-shadow', | 		for (let cmd in [ 'rm -rf /tmp/config-shadow', | ||||||
| 			  'cp -r /etc/config-shadow /tmp' ]) | 				  'cp -r /etc/config-shadow /tmp' ]) | ||||||
| 		system(cmd); | 			system(cmd); | ||||||
|  |  | ||||||
| 	let apply = fs.popen("/sbin/uci -c /tmp/config-shadow batch", "w"); | 		let apply = fs.popen("/sbin/uci -c /tmp/config-shadow batch", "w"); | ||||||
| 	apply.write(batch); | 		apply.write(batch); | ||||||
| 	apply.close(); | 		apply.close(); | ||||||
|  |  | ||||||
| 	for (let cmd in [ 'uci -c /tmp/config-shadow commit', | 		for (let cmd in [ 'uci -c /tmp/config-shadow commit', | ||||||
| 			  'cp /tmp/config-shadow/* /etc/config/', | 				  'cp /tmp/config-shadow/* /etc/config/', | ||||||
| 			  'rm -rf /tmp/config-shadow', | 				  'rm -rf /tmp/config-shadow', | ||||||
| 			  'reload_config']) | 				  'reload_config']) | ||||||
| 		system(cmd); | 			system(cmd); | ||||||
|  |  | ||||||
| 	fs.unlink('/etc/ucentral/ucentral.active'); |  | ||||||
| 	fs.symlink(ARGV[2], '/etc/ucentral/ucentral.active'); |  | ||||||
|  |  | ||||||
|  | 		fs.unlink('/etc/ucentral/ucentral.active'); | ||||||
|  | 		fs.symlink(ARGV[2], '/etc/ucentral/ucentral.active'); | ||||||
|  | 	} else { | ||||||
|  | 		error = 1; | ||||||
|  | 	} | ||||||
| } | } | ||||||
| catch (e) { | catch (e) { | ||||||
| 	error = 1; | 	error = 1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 John Crispin
					John Crispin