Skip to content

Commit 39d2fdc

Browse files
committed
Merge branch 'main' into next
2 parents 852e881 + ac9f817 commit 39d2fdc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bootstrap/helpers/shared.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,19 +1179,32 @@ function check_domain_usage(ServiceApplication|Application|null $resource = null
11791179
function parseCommandsByLineForSudo(Collection $commands, Server $server): array
11801180
{
11811181
$commands = $commands->map(function ($line) {
1182-
if (! str($line)->startsWith('cd') && ! str($line)->startsWith('command') && ! str($line)->startsWith('echo') && ! str($line)->startsWith('true')) {
1182+
if (! str(trim($line))->startsWith([
1183+
'cd',
1184+
'command',
1185+
'echo',
1186+
'true',
1187+
'if',
1188+
'fi',
1189+
])) {
11831190
return "sudo $line";
11841191
}
11851192

1193+
if (str(trim($line))->startsWith('if')) {
1194+
return str_replace('if', 'if sudo', $line);
1195+
}
1196+
11861197
return $line;
11871198
});
1199+
11881200
$commands = $commands->map(function ($line) use ($server) {
11891201
if (Str::startsWith($line, 'sudo mkdir -p')) {
11901202
return "$line && sudo chown -R $server->user:$server->user ".Str::after($line, 'sudo mkdir -p').' && sudo chmod -R o-rwx '.Str::after($line, 'sudo mkdir -p');
11911203
}
11921204

11931205
return $line;
11941206
});
1207+
11951208
$commands = $commands->map(function ($line) {
11961209
$line = str($line);
11971210
if (str($line)->contains('$(')) {

0 commit comments

Comments
 (0)