cloud_discovery: make use of the new TIP cloud discovery server

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2025-04-10 08:30:15 +02:00
parent 2b0c600fb3
commit c83ac67492
2 changed files with 6 additions and 4 deletions

View File

@@ -157,15 +157,16 @@ function discover_dhcp() {
function redirector_lookup() {
const path = '/tmp/ucentral.redirector';
ulog(LOG_INFO, 'Contact redirector service\n');
let serial = uci.get('ucentral', 'config', 'serial');
let serial = uci.get('system', '@system[-1]', 'mac');
fs.unlink(path);
system(`wget http://ucentral.io/${serial} -O /tmp/ucentral.redirector`);
system(`curl -k --cert /etc/ucentral/cert.pem --key /etc/ucentral/key.pem --cacert /etc/ucentral/cas.pem https://openlan.keys.tip.build/v1/devices/${serial} --output /tmp/ucentral.redirector`);
if (!fs.stat(path))
return;
let redir = readjsonfile(path);
if (redir?.server && redir?.port) {
if (gateway_write({ server: redir.server, port: redir.port, valid: false })) {
if (redir?.controller_endpoint) {
let controller_endpoint = split(redir.controller_endpoint, ':');
if (gateway_write({ server: controller_endpoint[0], port: controller_endpoint[1] || 15002, valid: false })) {
ulog(LOG_INFO, `Discovered cloud via lookup service ${redir.server}:${redir.port}\n`);
client_start();
set_state(VALIDATING);

View File

@@ -2,6 +2,7 @@
hname=$(cat /etc/board.json | jsonfilter -e '@.system.label_macaddr')
[ -z "$hname" ] && hname=$(cat /sys/class/net/eth0/address)
uci set system.@system[-1].mac=$hname
hname=$(echo $hname | tr -d : | awk '{print tolower($0)}')
uci set system.@system[-1].hostname=$hname
uci set ucentral.config.serial=$hname