Skip to content

Commit 8543fd1

Browse files
committed
clean up of php-ssh-cron branch
1 parent 1f1350c commit 8543fd1

File tree

11 files changed

+394
-149
lines changed

11 files changed

+394
-149
lines changed

install/sql/ispconfig3.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ CREATE TABLE `server_php` (
14601460
`php_fpm_ini_dir` varchar(255) DEFAULT NULL,
14611461
`php_fpm_pool_dir` varchar(255) DEFAULT NULL,
14621462
`php_fpm_socket_dir` varchar(255) DEFAULT NULL,
1463-
`php_cli_binary` varchar(255) DEFAULT NULL,
1463+
`php_cli_binary` varchar(255) DEFAULT NULL,
14641464
`active` enum('n','y') NOT NULL DEFAULT 'y',
14651465
`sortprio` int(20) NOT NULL DEFAULT 100,
14661466
PRIMARY KEY (`server_php_id`)

interface/web/sites/cron_edit.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function onShowEnd() {
7878
$app->tpl->setVar("edit_disabled", 0);
7979
}
8080

81+
8182
parent::onShowEnd();
8283
}
8384

@@ -148,7 +149,7 @@ function onUpdateSave($sql) {
148149
$has_error = true;
149150
}
150151
}
151-
152+
152153
if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') {
153154
$app->error($app->tform->wordbook["limit_cron_url_txt"]);
154155
$has_error = true;
@@ -178,7 +179,7 @@ function onInsertSave($sql) {
178179
$has_error = true;
179180
}
180181
}
181-
182+
182183
if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') {
183184
$app->error($app->tform->wordbook["limit_cron_url_txt"]);
184185
$has_error = true;

interface/web/sites/templates/cron_edit.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
<label for="command" class="col-sm-3 control-label">{tmpl_var name='command_txt'}</label>
5252
<div class="col-sm-9">
5353
<input type="text" name="command" id="command" value="{tmpl_var name='command'}" class="form-control" />
54-
<b>{tmpl_var name='variables_txt'}:</b> <a href="javascript:void(0);" class="addPlaceholder">{SITE_PHP}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOMAIN}</a>
55-
<br><br><p class="formHint">{tmpl_var name='command_hint_txt'}</p>
54+
<b>{tmpl_var name='variables_txt'}:</b> <a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='php_cli_binary'}" class="addPlaceholder">{SITE_PHP}</a>, <a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='docroot_client'}" class="addPlaceholder">{DOCROOT_CLIENT}</a>, <a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='domain'}" class="addPlaceholder">{DOMAIN}</a>
55+
<!--<br><br><p class="formHint">{tmpl_var name='command_hint_txt'}</p>-->
5656
</div>
5757
</div>
5858
<div class="form-group">

interface/web/sites/templates/cron_list.htm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ <h1><tmpl_var name="list_head_txt"></h1>
55

66

77
<p class="fieldset-legend">{tmpl_var name="toolsarea_head_txt"}</p>
8-
8+
99
<button class="btn btn-default formbutton-success" type="button" data-load-content="sites/cron_edit.php">{tmpl_var name="add_new_cron_txt"}</button>
10-
11-
1210

13-
11+
12+
13+
1414
<p class="fieldset-legend"><tmpl_var name="list_head_txt"></p>
1515
<div class="table-wrapper marginTop15">
1616
<table class="table">
@@ -55,7 +55,7 @@ <h1><tmpl_var name="list_head_txt"></h1>
5555
<td><a href="#" data-load-content="sites/cron_edit.php?id={tmpl_var name='id'}">{tmpl_var name="run_wday"}</a></td>
5656
<td><a href="#" data-load-content="sites/cron_edit.php?id={tmpl_var name='id'}" data-toggle="tooltip" data-placement="bottom" title="{tmpl_var name='command'}">{tmpl_var name="command"}</a></td>
5757
<td class="text-right">
58-
<div class="buttons icons16">
58+
<div class="buttons icons16">
5959
<a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('sites/cron_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a>
6060
</div>
6161
</td>

server/conf/bash.bashrc.master

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ fi
6262
#alias la='ls -A'
6363
#alias l='ls -CF'
6464

65-
<tmpl_if name='use_site_php'>
65+
<tmpl_if name='use_php_path'>
6666
# Overwrite the PHP cli binaries by using $PATH:
6767
export PATH=<tmpl_var name='php_bin_dir'>:$PATH
6868
</tmpl_if>
69-
7069
<tmpl_if name='use_php_alias'>
7170
alias php="<tmpl_var name='php_alias'>"
7271
</tmpl_if>

server/conf/bashrc_el.master

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# /etc/bashrc
2+
3+
# Taken from EL9
4+
5+
# System wide functions and aliases
6+
# Environment stuff goes in /etc/profile
7+
8+
# It's NOT a good idea to change this file unless you know what you
9+
# are doing. It's much better to create a custom.sh shell script in
10+
# /etc/profile.d/ to make custom changes to your environment, as this
11+
# will prevent the need for merging in future updates.
12+
13+
14+
15+
# Set some more environment variables, they are likely not set in Jailkit setups for EL.
16+
export TERM="xterm"
17+
export LESSOPEN="||/usr/bin/lesspipe.sh %s"
18+
19+
dircolors -b >/dev/null
20+
21+
22+
23+
24+
# Prevent doublesourcing
25+
if [ -z "$BASHRCSOURCED" ]; then
26+
BASHRCSOURCED="Y"
27+
28+
# are we an interactive shell?
29+
if [ "$PS1" ]; then
30+
if [ -z "$PROMPT_COMMAND" ]; then
31+
case $TERM in
32+
xterm*|vte*)
33+
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
34+
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
35+
else
36+
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
37+
fi
38+
;;
39+
screen*)
40+
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
41+
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
42+
else
43+
PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
44+
fi
45+
;;
46+
*)
47+
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
48+
;;
49+
esac
50+
fi
51+
# Turn on parallel history
52+
shopt -s histappend
53+
history -a
54+
# Turn on checkwinsize
55+
shopt -s checkwinsize
56+
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
57+
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
58+
# and console windows
59+
# If you want to do so, just add e.g.
60+
# if [ "$PS1" ]; then
61+
# PS1="[\u@\h:\l \W]\\$ "
62+
# fi
63+
# to your custom modification shell script in /etc/profile.d/ directory
64+
fi
65+
66+
if ! shopt -q login_shell ; then # We're not a login shell
67+
# Need to redefine pathmunge, it gets undefined at the end of /etc/profile
68+
pathmunge () {
69+
case ":${PATH}:" in
70+
*:"$1":*)
71+
;;
72+
*)
73+
if [ "$2" = "after" ] ; then
74+
PATH=$PATH:$1
75+
else
76+
PATH=$1:$PATH
77+
fi
78+
esac
79+
}
80+
81+
# Set default umask for non-login shell only if it is set to 0
82+
[ `umask` -eq 0 ] && umask 022
83+
84+
SHELL=/bin/bash
85+
# Only display echos from profile.d scripts if we are no login shell
86+
# and interactive - otherwise just process them to set envvars
87+
for i in /etc/profile.d/*.sh; do
88+
if [ -r "$i" ]; then
89+
if [ "$PS1" ]; then
90+
. "$i"
91+
else
92+
. "$i" >/dev/null
93+
fi
94+
fi
95+
done
96+
97+
unset i
98+
unset -f pathmunge
99+
fi
100+
101+
fi
102+
103+
<tmpl_if name='jailkit_chroot'>
104+
## Hack for Jailkit User to change back to the logged in user ##
105+
if [ -n "$LOGNAME" ]; then
106+
if [ "$LOGNAME" != $USER ]; then
107+
export HOME=<tmpl_var name='home_dir'>$LOGNAME
108+
export USER=$LOGNAME
109+
export USERNAME=$LOGNAME
110+
cd $HOME
111+
fi
112+
fi
113+
114+
## Change machine hostname to site domain ##
115+
export HOSTNAME=<tmpl_var name='domain'>
116+
117+
</tmpl_if>
118+
119+
<tmpl_if name='use_php_path'>
120+
# Overwrite the PHP cli binaries by using $PATH:
121+
export PATH=<tmpl_var name='php_bin_dir'>:$PATH
122+
</tmpl_if>
123+
<tmpl_if name='use_php_alias'>
124+
alias php="<tmpl_var name='php_alias'>"
125+
</tmpl_if>
126+
127+
### Hack to source a custom bashrc
128+
#if [ -f ~/.bashrc_ispcuser ]; then
129+
# . ~/.bashrc_ispcuser
130+
#fi
131+
132+
# vim:ts=4:sw=4

server/lib/classes/system.inc.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,15 +2064,15 @@ function umount_backup_dir($backup_dir, $mount_cmd = '/usr/local/ispconfig/serve
20642064

20652065
function _getinitcommand($servicename, $action, $init_script_directory = '', $check_service) {
20662066
global $conf, $app;
2067-
2067+
20682068
// upstart
20692069
/* removed upstart support - deprecated
20702070
if(is_executable('/sbin/initctl')){
20712071
exec('/sbin/initctl version 2>/dev/null | /bin/grep -q upstart', $retval['output'], $retval['retval']);
20722072
if(intval($retval['retval']) == 0) return 'service '.$servicename.' '.$action;
20732073
}
20742074
*/
2075-
2075+
20762076
if(!in_array($action,array('start','stop','restart','reload','force-reload'))) {
20772077
$app->log('Invalid init command action '.$action,LOGLEVEL_WARN);
20782078
return false;
@@ -2081,18 +2081,18 @@ function _getinitcommand($servicename, $action, $init_script_directory = '', $ch
20812081
//* systemd (now default in all supported OS)
20822082
if(is_executable('/bin/systemd') || is_executable('/usr/bin/systemctl')){
20832083
$app->log('Trying to use Systemd to restart service',LOGLEVEL_DEBUG);
2084-
2084+
20852085
//* Test service name via regex
20862086
if(preg_match('/[a-zA-Z0-9\.\-\_]/',$servicename)) {
2087-
2087+
20882088
//* Test if systemd service is enabled
20892089
if ($check_service) {
20902090
$this->exec_safe("systemctl is-enabled ? 2>&1", $servicename);
20912091
$ret_val = $this->last_exec_retcode();
20922092
} else {
20932093
$app->log('Systemd service '.$servicename.' not found or not enabled.',LOGLEVEL_DEBUG);
20942094
}
2095-
2095+
20962096
//* Return service command
20972097
if ($ret_val == 0 || !$check_service) {
20982098
return 'systemctl '.$action.' '.$servicename.'.service';
@@ -2108,69 +2108,69 @@ function _getinitcommand($servicename, $action, $init_script_directory = '', $ch
21082108

21092109
//* sysvinit fallback
21102110
$app->log('Using init script to restart service',LOGLEVEL_DEBUG);
2111-
2111+
21122112
//* Get init script directory
21132113
if($init_script_directory == '') $init_script_directory = $conf['init_scripts'];
21142114
if(substr($init_script_directory, -1) === '/') $init_script_directory = substr($init_script_directory, 0, -1);
21152115
$init_script_directory = realpath($init_script_directory);
2116-
2116+
21172117
//* Check init script dir
21182118
if(!is_dir($init_script_directory)) {
21192119
$app->log('Init script directory '.$init_script_directory.' not found',LOGLEVEL_WARN);
21202120
return false;
21212121
}
2122-
2122+
21232123
//* Forbidden init script paths
21242124
if(substr($init_script_directory,0,4) == '/var' || substr($init_script_directory,0,4) == '/tmp') {
21252125
$app->log('Do not put init scripts in /var or /tmp folder.',LOGLEVEL_WARN);
21262126
return false;
21272127
}
2128-
2128+
21292129
//* Check init script dir owner
21302130
if(fileowner($init_script_directory) !== 0) {
21312131
$app->log('Init script directory '.$init_script_directory.' not owned by root user',LOGLEVEL_WARN);
21322132
return false;
21332133
}
2134-
2134+
21352135
$full_init_script_path = realpath($init_script_directory.'/'.$servicename);
2136-
2136+
21372137
//** Gentoo, keep symlink as init script, but do some checks
2138-
if(file_exists('/etc/gentoo-release')) {
2138+
if(file_exists('/etc/gentoo-release')) {
21392139
//* check if init script is symlink
2140-
if(is_link($init_script_directory.'/'.$servicename)) {
2140+
if(is_link($init_script_directory.'/'.$servicename)) {
21412141
//* Check init script owner (realpath, symlink is checked later)
21422142
if(fileowner($full_init_script_path) !== 0) {
21432143
$app->log('Init script '.$full_init_script_path.' not owned by root user',LOGLEVEL_WARN);
21442144
return false;
21452145
}
2146-
2146+
21472147
//* full path is symlink
21482148
$full_init_script_path_symlink = $init_script_directory.'/'.$servicename;
2149-
2149+
21502150
//* check if realpath matches symlink
21512151
if(strpos($full_init_script_path_symlink,$full_init_script_path) == 0) {
21522152
$full_init_script_path = $full_init_script_path_symlink;
21532153
}
21542154
}
21552155
}
2156-
2156+
21572157
if($full_init_script_path == '') {
21582158
$app->log('No init script, we quit here.',LOGLEVEL_WARN);
21592159
return false;
21602160
}
2161-
2161+
21622162
//* Check init script
21632163
if(!is_file($full_init_script_path)) {
21642164
$app->log('Init script '.$full_init_script_path.' not found',LOGLEVEL_WARN);
21652165
return false;
21662166
}
2167-
2167+
21682168
//* Check init script owner
21692169
if(fileowner($full_init_script_path) !== 0) {
21702170
$app->log('Init script '.$full_init_script_path.' not owned by root user',LOGLEVEL_WARN);
21712171
return false;
21722172
}
2173-
2173+
21742174
if($check_service && is_executable($full_init_script_path)) {
21752175
return $full_init_script_path.' '.$action;
21762176
}

0 commit comments

Comments
 (0)