Move Custom Scripts out of the repo and add an Import Script picker

Custom Scripts (the Scheduler page's inline editor) used to save into the
git-tracked Custom/ folder, so anything saved there would end up on GitHub.
They now live in /boot/config/plugins/user.scripts/Varaverk/Scripts, same
folder family as Unraid's own User Scripts plugin. Import Script lets you
browse the whole server and move an existing script in instead of only
creating new ones inline — always a move, never a copy, so no stray
duplicate is left where it came from.
This commit is contained in:
Gmer4Lfe
2026-07-03 10:57:35 -04:00
parent 93aa134aaa
commit 6fd22ae4ee
7 changed files with 352 additions and 10 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
echo json_encode(['ok' => false, 'error' => 'Invalid id']);
exit;
}
$path = SCRIPTS_DIR . '/' . $id;
$path = CUSTOM_SCRIPTS_DIR . '/' . substr($id, strlen('Custom/'));
echo json_encode(['ok' => true, 'content' => file_exists($path) ? file_get_contents($path) : '']);
exit;
}
@@ -24,7 +24,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
$id = 'Custom/' . $name . '.sh';
$path = SCRIPTS_DIR . '/Custom/' . $name . '.sh';
$path = CUSTOM_SCRIPTS_DIR . '/' . $name . '.sh';
if ($action === 'delete') {
if (!file_exists($path)) {
@@ -40,7 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit;
}
$dir = SCRIPTS_DIR . '/Custom';
$dir = CUSTOM_SCRIPTS_DIR;
if (!is_dir($dir)) mkdir($dir, 0755, true);
if (file_put_contents($path, $content) === false) {
echo json_encode(['ok' => false, 'error' => 'Failed to write script']);