1
2
3
4
5
6
7
8
9
10
11
12
13
| $commands = [
['echo', '"-----script-start-----"'],
['mkdir', '-p', '/usr/local/src/scripts'],
['cd', '/usr/local/src/scripts'],
[sprintf('echo "%s" | base64 -di > %s.env', base64_encode(implode("\n", $envArr)), $scriptName)],
[sprintf('echo "%s" | base64 -di > %s', base64_encode($scriptContent), $scriptName)],
['chmod', '+x', $scriptName],
array_merge(['bash', $scriptName], array_map(CommandEscapeTool::class, 'escape'], $params), ['2>&1']),
['echo', 'script_exit_code=$?'],
['echo', '-----script-end-----'],
];
$commandStr = sprintf('echo "%s" | base64 -di | bash', base64_encode($commandStr));
|