fix(mikrotikConfigRoutes): enhance script execution logic to find script ID before running
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m9s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m9s
This commit is contained in:
@@ -295,8 +295,12 @@ async function runScript(req, res) {
|
||||
}
|
||||
|
||||
const client = createRosClient(creds);
|
||||
// /rest/system/script/run — запуск скрипта по имени (.id принимает имя скрипта)
|
||||
await client.command('system/script/run', { '.id': script });
|
||||
// Сначала находим скрипт по имени, затем запускаем по .id
|
||||
const scripts = await client.print('system/script');
|
||||
const list = Array.isArray(scripts?.data) ? scripts.data : (scripts?.data ? [scripts.data] : []);
|
||||
const found = list.find(s => (s.name || s['.id']) === script);
|
||||
const scriptId = found ? (found['.id'] || found.name) : script;
|
||||
await client.command('system/script/run', { '.id': scriptId });
|
||||
|
||||
return sendOk(res, { ok: true, message: `Скрипт ${script} запущен` });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user