Skip to content

Commit 0a02ee3

Browse files
author
Marius Cramer
committed
Implemented: FS#3346 - Add a [web_root] placeholder to cronjob command
1 parent 41add69 commit 0a02ee3

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

interface/web/sites/lib/lang/de_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ $wb['run_wday_error_format'] = 'Das Format für Wochentage ist nicht korrekt.';
1919
$wb['command_error_format'] = 'Das Format für den Befehl ist nicht korrekt. Beachten Sie, dass bei einem URL Aufruf nur http und https erlaubt ist.';
2020
$wb['unknown_fieldtype_error'] = 'Es wurde ein unbekanntes Feld verwendet.';
2121
$wb['server_id_error_empty'] = 'Die Server-ID ist leer.';
22+
$wb['command_hint_txt'] = 'z. B. /var/www/clients/clientX/webY/myscript.sh oder http://www.mydomain.com/path/script.php. Der Platzhalter [web_root] wird durch /var/www/clients/clientX/webY/web ersetzt.';
2223
?>

interface/web/sites/lib/lang/en_cron.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ $wb['run_wday_error_format'] = 'Invalid format for days of the week.';
1919
$wb['command_error_format'] = 'Invalid command format. Please note that in case of an url call only http/https is allowed.';
2020
$wb['unknown_fieldtype_error'] = 'An unknown field type has been used.';
2121
$wb['server_id_error_empty'] = 'The server ID is empty.';
22+
$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or http://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
2223
?>

interface/web/sites/templates/cron_edit.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
4747
<div class="ctrlHolder">
4848
<label for="command">{tmpl_var name='command_txt'}</label>
4949
<input name="command" id="command" value="{tmpl_var name='command'}" size="30" maxlength="255" type="text" class="textInput" />
50-
<p class="formHint">e.g. /var/www/clients/client1/myscript.sh or http://www.mydomain.com/path/script.php</p>
50+
<p class="formHint">{tmpl_var name='command_hint_txt'}</p>
5151
</div>
5252
<div class="ctrlHolder">
5353
<p class="label">{tmpl_var name='active_txt'}</p>

server/plugins-available/cron_plugin.inc.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,20 @@ function _write_crontab() {
205205
if($job['type'] == 'url') {
206206
$command .= "\t{$cron_config['wget']} -q -t 1 -T 7200 -O /dev/null " . escapeshellarg($job['command']) . " >/dev/null 2>&1";
207207
} else {
208+
$web_root = '';
208209
if($job['type'] == 'chrooted') {
209210
if(substr($job['command'], 0, strlen($this->parent_domain['document_root'])) == $this->parent_domain['document_root']) {
210211
//* delete the unneeded path part
211212
$job['command'] = substr($job['command'], strlen($this->parent_domain['document_root']));
212213
}
214+
} else {
215+
$web_root = $this->parent_domain['document_root'];
213216
}
217+
$web_root .= '/web';
218+
$job['command'] = str_replace('[web_root]', $web_root, $job['command']);
214219

215220
$command .= "\t";
216-
if($job['type'] == 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
221+
if($job['type'] != 'chrooted' && substr($job['command'], 0, 1) != "/") $command .= $this->parent_domain['document_root'].'/';
217222
$command .= $job['command'];
218223
}
219224

0 commit comments

Comments
 (0)