Files
ols-ucentral-schema/command/cmd_certupdate.uc
John Crispin 4dd5fa4365 add certupdate command handler
Signed-off-by: John Crispin <john@phrozen.org>
2023-09-28 14:52:40 +02:00

30 lines
627 B
Ucode

let tar = b64dec(args.certificates);
if (!tar || !fs.writefile('/tmp/certs.tar', tar)) {
result_json({
"error": 2,
"text": 'failed to extract certificates'
});
return;
}
if (system('/sbin/certupdate')) {
result_json({
"error": 2,
"text": 'failed to update certificates'
});
return;
}
include('reboot_cause.uc', { reason: 'certupdate' });
ctx.call("ucentral", "result", {
"status": {
"error": 0,
"text": 'Success'
}, "id": +id
});
sleep(5000);
system("(sleep 10; jffs2reset -y -r)&");
system("/etc/init.d/ucentral stop");