manman-sync fix storing data
This commit is contained in:
		
							parent
							
								
									503893fdf7
								
							
						
					
					
						commit
						436f3eaff5
					
				@ -12,18 +12,18 @@ return function(form, uci)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	local o
 | 
						local o
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local manman = s:option(Flag, "manman_sync", pkg_i18n.translate("Enable ManMan sync"))
 | 
						local manman = s:option(Flag, 'manman_sync', pkg_i18n.translate('Enable ManMan sync'))
 | 
				
			||||||
	manman.default = uci:get_bool("gluon", "manman_sync", "enabled")
 | 
						manman.default = uci:get_bool('gluon-manman-sync', 'sync', 'enabled')
 | 
				
			||||||
	function manman:write(data)
 | 
						function manman:write(data)
 | 
				
			||||||
		uci:set("gluon", "manman_sync", "enabled", data)
 | 
							uci:set('gluon-manman-sync', 'sync', 'enabled', data)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local id = s:option(Value, "manman_id", pkg_i18n.translate("ManMan location ID"))
 | 
						local id = s:option(Value, 'manman_id', pkg_i18n.translate('ManMan location ID'))
 | 
				
			||||||
	id:depends(manman, true)
 | 
						id:depends(manman, true)
 | 
				
			||||||
	id.default = uci:get("gluon", "manman_sync", "node_id")
 | 
						id.default = uci:get('gluon-manman-sync', 'sync', 'node_id')
 | 
				
			||||||
	id.datatype = "uinteger"
 | 
						id.datatype = 'uinteger'
 | 
				
			||||||
	function id:write(data)
 | 
						function id:write(data)
 | 
				
			||||||
		uci:set("gluon", "manman_sync", "node_id", data)
 | 
							uci:set('gluon-manman-sync', 'sync', 'node_id', data)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function s:write()
 | 
						function s:write()
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								package/gluon-manman-sync/files/etc/config/gluon-manman-sync
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								package/gluon-manman-sync/files/etc/config/gluon-manman-sync
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					package gluon-manman-sync
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config sync 'sync'
 | 
				
			||||||
 | 
						option enabled '0'
 | 
				
			||||||
 | 
					  option node_id ''
 | 
				
			||||||
 | 
					  option last_data_hash ''
 | 
				
			||||||
 | 
					  option last_data ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config rollback 'rollback'
 | 
				
			||||||
 | 
					  option success '1'
 | 
				
			||||||
 | 
					  option checked_at ''
 | 
				
			||||||
 | 
					  option previous_hash ''
 | 
				
			||||||
 | 
					  option new_hash ''
 | 
				
			||||||
@ -11,8 +11,8 @@ local mappings = {
 | 
				
			|||||||
  tunnel = 'vpn'
 | 
					  tunnel = 'vpn'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if uci:get_bool('gluon', 'manman_sync', 'enabled') then
 | 
					if uci:get_bool('gluon-manman-sync', 'sync', 'enabled') then
 | 
				
			||||||
  local location_id = uci:get('gluon', 'manman_sync', 'location_id')
 | 
					  local location_id = uci:get('gluon-manman-sync', 'sync', 'location_id')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if not location_id then
 | 
					  if not location_id then
 | 
				
			||||||
    print('E: manman location_id missing')
 | 
					    print('E: manman location_id missing')
 | 
				
			||||||
 | 
				
			|||||||
@ -41,16 +41,16 @@ static struct json_object * get_autoupdater(void) {
 | 
				
			|||||||
	ctx->flags &= ~UCI_FLAG_STRICT;
 | 
						ctx->flags &= ~UCI_FLAG_STRICT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct uci_package *p;
 | 
						struct uci_package *p;
 | 
				
			||||||
	if (uci_load(ctx, "gluon", &p))
 | 
						if (uci_load(ctx, "gluon-manman-sync", &p))
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct uci_section *s = uci_lookup_section(ctx, p, "manman_sync");
 | 
						struct uci_section *s = uci_lookup_section(ctx, p, "sync");
 | 
				
			||||||
	if (!s)
 | 
						if (!s)
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct json_object *ret = json_object_new_object();
 | 
						struct json_object *ret = json_object_new_object();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	json_object_object_add(ret, "nodeid", gluonutil_wrap_string(uci_lookup_option_string(ctx, s, "nodeid")));
 | 
						json_object_object_add(ret, "node_id", gluonutil_wrap_string(uci_lookup_option_string(ctx, s, "node_id")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *enabled = uci_lookup_option_string(ctx, s, "enabled");
 | 
						const char *enabled = uci_lookup_option_string(ctx, s, "enabled");
 | 
				
			||||||
	json_object_object_add(ret, "enabled", json_object_new_boolean(enabled && !strcmp(enabled, "1")));
 | 
						json_object_object_add(ret, "enabled", json_object_new_boolean(enabled && !strcmp(enabled, "1")));
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user