Add system-password to the schema

With this addition, a desired password can be configured through ucentral config

Signed-off-by: Venkat Chimata <venkata@shasta.cloud>
This commit is contained in:
Venkat Chimata
2024-09-22 11:59:26 +05:30
committed by John Crispin
parent 8b3701bf2e
commit 42e59d5524
7 changed files with 38 additions and 1 deletions

View File

@@ -996,6 +996,14 @@ let shell = {
}
system("(echo " + passwd + "; sleep 1; echo " + passwd + ") | passwd root");
conn.call("ucentral", "password", { passwd });
},
/**
* Set system password
*/
system_password: function(passwd) {
system("(echo " + passwd + "; sleep 1; echo " + passwd + ") | passwd root");
conn.call("ucentral", "password", { passwd });
}
};

View File

@@ -14,6 +14,9 @@ set system.@system[-1].timezone={{ s(unit.timezone) }}
{% endif %}
set system.@system[-1].leds_off={{ b(!unit.leds_active) }}
{%
shell.password(unit.random_password);
if (unit.system_password)
shell.system_password(unit.system_password);
else
shell.password(unit.random_password);
services.set_enabled("led", true);
%}

View File

@@ -37,6 +37,10 @@ properties:
The device shall create a random root password and tell the gateway about it.
type: boolean
default: false
system-password:
description:
System-config string that holds the password for main (root / admin) user to apply.
type: string
beacon-advertisement:
description:
The TIP vendor IEs that shall be added to beacons

View File

@@ -164,6 +164,17 @@ function instantiateUnit(location, value, errors) {
obj.random_password = false;
}
function parseSystemPassword(location, value, errors) {
if (type(value) != "string")
push(errors, [ location, "must be of type string" ]);
return value;
}
if (exists(value, "system-password")) {
obj.system_password = parseSystemPassword(location + "/system-password", value["system-password"], errors);
}
function parseBeaconAdvertisement(location, value, errors) {
if (type(value) == "object") {
let obj = {};

View File

@@ -49,6 +49,10 @@
"type": "boolean",
"default": false
},
"system-password": {
"description": "System-config string that holds the password for main (root / admin) user to apply.",
"type": "string"
},
"beacon-advertisement": {
"description": "The TIP vendor IEs that shall be added to beacons",
"type": "object",

View File

@@ -84,6 +84,9 @@
"type": "boolean",
"default": false
},
"system-password": {
"type": "string"
},
"beacon-advertisement": {
"type": "object",
"properties": {

View File

@@ -94,6 +94,10 @@
"type": "boolean",
"default": false
},
"system-password": {
"description": "System-config string that holds the password for main (root / admin) user to apply.",
"type": "string"
},
"beacon-advertisement": {
"description": "The TIP vendor IEs that shall be added to beacons",
"type": "object",