summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2024-12-15 18:46:51 +0000
committerFelix Fietkau2024-12-15 18:48:43 +0000
commit8b1f1d099352954063a2bf53a612af4b81645be7 (patch)
tree53e391d9ef0dd07da996b017b1c8c625ec4f401e
parentf335f5b40b4ec0b741616d6758aa117183335626 (diff)
unet-cli: add support for importing networks from signed data
This can be used to edit existing networks on the device when the key is generated from a seed password. Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rwxr-xr-xscripts/unet-cli19
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/unet-cli b/scripts/unet-cli
index 600c332..970caaa 100755
--- a/scripts/unet-cli
+++ b/scripts/unet-cli
@@ -314,7 +314,12 @@ while (substr(ARGV[0], 0, 1) == "-") {
exit(usage());
}
-let hostname, ssh_host, servicename;
+let import_file, hostname, ssh_host, servicename;
+
+if (command == "import") {
+ import_file = shift(ARGV);
+ assert(import_file, "Missing import file argument");
+}
if (command in [ "add-host", "set-host", "add-ssh-host", "set-ssh-host" ]) {
hostname = shift(ARGV);
@@ -340,6 +345,16 @@ if (command in [ "add-ssh-host", "set-ssh-host" ]) {
let net_data;
+if (command == "import") {
+ if (!access(import_file) &&
+ index(import_file, "/") < 0)
+ import_file = "/etc/unetd/" + import_file + ".bin";
+
+ assert(access(import_file), "Invalid import file name");
+ if (system(`${unet_tool} -b ${import_file} -T -o ${file}`))
+ exit(1);
+}
+
if (command == "create") {
net_data = {
config: {},
@@ -380,6 +395,8 @@ if (command == "sign") {
}
switch (command) {
+case 'import':
+ break;
case 'create':
case 'set-config':
set_fields(net_data.config, {