parent
6df141e7a6
commit
7e0075584d
@ -17,7 +17,7 @@ define Package/gluon-config-mode-core
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Luci based config mode for user friendly setup of new mesh nodes
|
||||
DEPENDS:=gluon-setup-mode-virtual +gluon-luci-theme +gluon-lock-password $(GLUON_I18N_PACKAGES)
|
||||
DEPENDS:=gluon-setup-mode-virtual +gluon-luci-theme +gluon-lock-password +pretty-hostname $(GLUON_I18N_PACKAGES)
|
||||
PROVIDES:=gluon-config-mode-core-virtual
|
||||
endef
|
||||
|
||||
|
@ -51,6 +51,7 @@ function action_reboot()
|
||||
local gluon_luci = require "gluon.luci"
|
||||
local fs = require "nixio.fs"
|
||||
local util = require "nixio.util"
|
||||
local pretty_hostname = require "pretty_hostname"
|
||||
|
||||
local parts_dir = "/lib/gluon/config-mode/reboot/"
|
||||
local files = util.consume(fs.dir(parts_dir))
|
||||
@ -68,7 +69,7 @@ function action_reboot()
|
||||
end
|
||||
end
|
||||
|
||||
local hostname = uci:get_first("system", "system", "hostname")
|
||||
local hostname = pretty_hostname.get(uci)
|
||||
|
||||
luci.template.render("gluon/config-mode/reboot",
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
local cbi = require "luci.cbi"
|
||||
local i18n = require "luci.i18n"
|
||||
local pretty_hostname = require "pretty_hostname"
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
local M = {}
|
||||
@ -7,14 +8,12 @@ local M = {}
|
||||
function M.section(form)
|
||||
local s = form:section(cbi.SimpleSection, nil, nil)
|
||||
local o = s:option(cbi.Value, "_hostname", i18n.translate("Node name"))
|
||||
o.value = uci:get_first("system", "system", "hostname")
|
||||
o.value = pretty_hostname.get(uci)
|
||||
o.rmempty = false
|
||||
o.datatype = "hostname"
|
||||
end
|
||||
|
||||
function M.handle(data)
|
||||
uci:set("system", uci:get_first("system", "system"), "hostname", data._hostname)
|
||||
uci:save("system")
|
||||
pretty_hostname.set(uci, data._hostname)
|
||||
uci:commit("system")
|
||||
end
|
||||
|
||||
|
@ -11,8 +11,10 @@ else
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local pretty_hostname = require 'pretty_hostname'
|
||||
|
||||
local pubkey = util.trim(util.exec("/etc/init.d/fastd show_key " .. "mesh_vpn"))
|
||||
local hostname = uci:get_first("system", "system", "hostname")
|
||||
local hostname = pretty_hostname.get(uci)
|
||||
local contact = uci:get_first("gluon-node-info", "owner", "contact")
|
||||
|
||||
local msg = i18n.translate('gluon-config-mode:pubkey')
|
||||
|
@ -13,7 +13,7 @@ define Package/gluon-core
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Base files of Gluon
|
||||
DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall
|
||||
DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname
|
||||
endef
|
||||
|
||||
define Package/gluon-core/description
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local pretty_hostname = require 'pretty_hostname'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
-- Initial
|
||||
@ -10,7 +11,7 @@ if not sysconfig.gluon_version then
|
||||
|
||||
local system = uci:get_first('system', 'system')
|
||||
|
||||
uci:set('system', system, 'hostname', (site.hostname_prefix or '') .. util.node_id())
|
||||
pretty_hostname.set(uci, (site.hostname_prefix or '') .. util.node_id())
|
||||
uci:set('system', system, 'timezone', site.timezone)
|
||||
|
||||
uci:save('system')
|
||||
|
@ -18,7 +18,7 @@ define Package/gluon-luci-admin
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Luci based simple administration interface for mesh nodes
|
||||
DEPENDS:=gluon-config-mode-core-virtual
|
||||
DEPENDS:=gluon-config-mode-core-virtual +pretty-hostname
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
@ -3,6 +3,7 @@
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local util = require 'luci.util'
|
||||
local i18n = require 'luci.i18n'
|
||||
local pretty_hostname = require 'pretty_hostname'
|
||||
|
||||
local gluon_luci = require "gluon.luci"
|
||||
local site = require 'gluon.site_config'
|
||||
@ -21,7 +22,7 @@
|
||||
}
|
||||
|
||||
local values = {
|
||||
hostname = uci:get_first('system', 'system', 'hostname'),
|
||||
hostname = pretty_hostname.get(uci),
|
||||
primary_mac = sysconfig.primary_mac,
|
||||
model = platform.get_model(),
|
||||
version = util.trim(fs.readfile('/lib/gluon/gluon-version')),
|
||||
|
@ -16,7 +16,7 @@ define Package/gluon-luci-theme
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Luci theme for Gluon
|
||||
DEPENDS:=
|
||||
DEPENDS:=+pretty-hostname
|
||||
endef
|
||||
|
||||
define Package/gluon-luci-theme/description
|
||||
|
@ -16,10 +16,12 @@ $Id$
|
||||
local sys = require "luci.sys"
|
||||
local http = require "luci.http"
|
||||
local disp = require "luci.dispatcher"
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local gluon_luci = require "gluon.luci"
|
||||
local pretty_hostname = require "pretty_hostname"
|
||||
|
||||
local hostname = sys.hostname()
|
||||
local hostname = pretty_hostname.get(uci)
|
||||
local release = fs.readfile("/lib/gluon/release")
|
||||
|
||||
local request = disp.context.path
|
||||
|
@ -12,7 +12,7 @@ define Package/gluon-respondd
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Provides node information to the network
|
||||
DEPENDS:=+gluon-core +libplatforminfo +libgluonutil +respondd
|
||||
DEPENDS:=+gluon-core +libplatforminfo +libgluonutil +libuci +respondd
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
@ -3,4 +3,4 @@ all: respondd.so
|
||||
CFLAGS += -Wall
|
||||
|
||||
respondd.so: respondd.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -lplatforminfo
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared -fPIC -D_GNU_SOURCE -o $@ $^ $(LDLIBS) -lgluonutil -lplatforminfo -luci
|
||||
|
@ -29,12 +29,12 @@
|
||||
#include <json-c/json.h>
|
||||
#include <libgluonutil.h>
|
||||
#include <libplatforminfo.h>
|
||||
#include <uci.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
|
||||
@ -67,12 +67,29 @@ static struct json_object * get_site_code(void) {
|
||||
}
|
||||
|
||||
static struct json_object * get_hostname(void) {
|
||||
struct utsname utsname;
|
||||
struct json_object *ret = NULL;
|
||||
|
||||
if (uname(&utsname))
|
||||
return NULL;
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
ctx->flags &= ~UCI_FLAG_STRICT;
|
||||
|
||||
return gluonutil_wrap_string(utsname.nodename);
|
||||
char section[] = "system.@system[0]";
|
||||
struct uci_ptr ptr;
|
||||
if (uci_lookup_ptr(ctx, &ptr, section, true))
|
||||
goto error;
|
||||
|
||||
struct uci_section *s = ptr.s;
|
||||
|
||||
const char *hostname = uci_lookup_option_string(ctx, s, "pretty_hostname");
|
||||
|
||||
if (!hostname)
|
||||
hostname = uci_lookup_option_string(ctx, s, "hostname");
|
||||
|
||||
ret = gluonutil_wrap_string(hostname);
|
||||
|
||||
error:
|
||||
uci_free_context(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct json_object * respondd_provider_nodeinfo(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user