From d2b8a4ea1762d0af35e9b7e343be82fa6bf0cb28 Mon Sep 17 00:00:00 2001
From: Michael Seevogel <git@michaelseevogel.de>
Date: Mon, 4 Mar 2024 15:53:22 +0100
Subject: [PATCH] Update of branch: - Use alternatives for jailed shell
 accounts in Debian/Ubuntu systems instead of an alias - Made the file
 /etc/bash.bashrc obsolete - command_format updated so that the domain
 placeholder can be used for wget commands - Introduction of the .bashrc.d
 directory for shell users so that they can extend their Bash environment more
 flexibly and easily via resource files - Minor refactoring and other changes

---
 interface/lib/classes/validate_cron.inc.php   |  13 +-
 interface/web/sites/ajax_get_json.php         |   4 +-
 interface/web/sites/cron_edit.php             |   2 +-
 interface/web/sites/lib/lang/ar_cron.lng      |   2 +-
 interface/web/sites/lib/lang/bg_cron.lng      |   2 +-
 interface/web/sites/lib/lang/br_cron.lng      |   2 +-
 interface/web/sites/lib/lang/ca_cron.lng      |   2 +-
 interface/web/sites/lib/lang/cn_cron.lng      |   2 +-
 interface/web/sites/lib/lang/cz_cron.lng      |   2 +-
 interface/web/sites/lib/lang/dk_cron.lng      |   2 +-
 interface/web/sites/lib/lang/el_cron.lng      |   2 +-
 interface/web/sites/lib/lang/en_cron.lng      |   2 +-
 interface/web/sites/lib/lang/es_cron.lng      |   2 +-
 interface/web/sites/lib/lang/fi_cron.lng      |   2 +-
 interface/web/sites/lib/lang/fr_cron.lng      |   2 +-
 interface/web/sites/lib/lang/hr_cron.lng      |   2 +-
 interface/web/sites/lib/lang/hu_cron.lng      |   2 +-
 interface/web/sites/lib/lang/id_cron.lng      |   2 +-
 interface/web/sites/lib/lang/it_cron.lng      |   2 +-
 interface/web/sites/lib/lang/ja_cron.lng      |   2 +-
 interface/web/sites/lib/lang/nl_cron.lng      |   2 +-
 interface/web/sites/lib/lang/pl_cron.lng      |   2 +-
 interface/web/sites/lib/lang/pt_cron.lng      |   2 +-
 interface/web/sites/lib/lang/ro_cron.lng      |   2 +-
 interface/web/sites/lib/lang/ru_cron.lng      |   2 +-
 interface/web/sites/lib/lang/se_cron.lng      |   2 +-
 interface/web/sites/lib/lang/sk_cron.lng      |   2 +-
 interface/web/sites/lib/lang/tr_cron.lng      |   2 +-
 server/conf/bash.bashrc.master                |   9 --
 server/conf/bashrc_el.master                  | 132 -----------------
 server/conf/bashrc_user_deb.master            | 137 ++++++++++++++++++
 server/conf/bashrc_user_generic.master        |  35 +++++
 server/conf/bashrc_user_redhat.master         |  52 +++++++
 server/lib/classes/system.inc.php             |  21 +++
 .../cron_jailkit_plugin.inc.php               |  40 +++--
 .../shelluser_base_plugin.inc.php             |  54 +++++--
 .../shelluser_jailkit_plugin.inc.php          |  78 ++++++----
 37 files changed, 395 insertions(+), 232 deletions(-)
 delete mode 100644 server/conf/bashrc_el.master
 create mode 100644 server/conf/bashrc_user_deb.master
 create mode 100644 server/conf/bashrc_user_generic.master
 create mode 100644 server/conf/bashrc_user_redhat.master

diff --git a/interface/lib/classes/validate_cron.inc.php b/interface/lib/classes/validate_cron.inc.php
index c99f13ef52..be28a87d4c 100644
--- a/interface/lib/classes/validate_cron.inc.php
+++ b/interface/lib/classes/validate_cron.inc.php
@@ -48,15 +48,17 @@ class validate_cron {
 		global $app, $page;
 
 		if(preg_match("'^(\w+):\/\/'", $field_value, $matches)) {
-			if(preg_match("/\{DOMAIN\}/", $field_value)) {
+			//* Add the {DOMAIN} placeholder to the validation process
+			if(preg_match("/{DOMAIN}/", $field_value)) {
+
 				if(isset($app->remoting_lib->primary_id)) {
-					$domain = $app->remoting_lib->dataRecord;
+					$cronjob = $app->remoting_lib->dataRecord;
 				} else {
-					$domain = $page->dataRecord;
+					$cronjob = $page->dataRecord;
 				}
 
-				if($domain['parent_domain_id'] > 0){
-					$parent_domain = $app->db->queryOneRecord("SELECT `domain` FROM `web_domain` WHERE `domain_id` = ?", $domain['parent_domain_id']);
+				if($cronjob['parent_domain_id'] > 0) {
+					$parent_domain = $app->db->queryOneRecord("SELECT `domain` FROM `web_domain` WHERE `domain_id` = ?", $cronjob['parent_domain_id']);
 				}
 
 				$trans = array(
@@ -64,6 +66,7 @@ class validate_cron {
 				);
 
 				$field_value = strtr($field_value, $trans);
+
 			}
 
 			$parsed = parse_url($field_value);
diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php
index 6fd7d09185..914371ab73 100644
--- a/interface/web/sites/ajax_get_json.php
+++ b/interface/web/sites/ajax_get_json.php
@@ -264,7 +264,7 @@ if($type == 'getcronplaceholders') {
 
 		$domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $web["sys_groupid"]);
 
-		//* True when the site is assigned to a client
+		//* True if the site is assigned to a client
 		if(isset($domain_owner["limit_cron_type"])) {
 			if($domain_owner["limit_cron_type"] == 'full') {
 				$cron_type = 'full';
@@ -272,7 +272,7 @@ if($type == 'getcronplaceholders') {
 				$cron_type = 'chrooted';
 			}
 		} else {
-			//* True when the site is assigned to the admin
+			//* True if the site is assigned to the admin
 			$cron_type = 'full';
 		}
 
diff --git a/interface/web/sites/cron_edit.php b/interface/web/sites/cron_edit.php
index ebe2c97a32..ab3f34d7e0 100644
--- a/interface/web/sites/cron_edit.php
+++ b/interface/web/sites/cron_edit.php
@@ -80,7 +80,7 @@ class page_action extends tform_actions {
 
 		$parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `domain`, `document_root`, `hd_quota`, `php_cli_binary`
 		FROM `web_domain`
-			LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
+		LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
 		WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]);
 
 		$php_cli_binary = $parent_domain['php_cli_binary'];
diff --git a/interface/web/sites/lib/lang/ar_cron.lng b/interface/web/sites/lib/lang/ar_cron.lng
index 74911e8d03..fb114d1a5b 100644
--- a/interface/web/sites/lib/lang/ar_cron.lng
+++ b/interface/web/sites/lib/lang/ar_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 ?>
diff --git a/interface/web/sites/lib/lang/bg_cron.lng b/interface/web/sites/lib/lang/bg_cron.lng
index fedfb73393..c4877f8972 100644
--- a/interface/web/sites/lib/lang/bg_cron.lng
+++ b/interface/web/sites/lib/lang/bg_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 ?>
diff --git a/interface/web/sites/lib/lang/br_cron.lng b/interface/web/sites/lib/lang/br_cron.lng
index 263b3177aa..bf26c58310 100644
--- a/interface/web/sites/lib/lang/br_cron.lng
+++ b/interface/web/sites/lib/lang/br_cron.lng
@@ -24,4 +24,4 @@ $wb['log_output_txt'] = 'Gravar saída do log';
 $wb['limit_cron_url_txt'] = 'Somente URL no Cron. Por favor insira uma URL iniciando com https:// como um comando no Cron.';
 $wb['command_error_empty'] = 'Comando a executar está vazio.';
 $wb['Cron Job'] = 'Tarefas no Cron';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/ca_cron.lng b/interface/web/sites/lib/lang/ca_cron.lng
index 420c3390a2..8d04a71e03 100644
--- a/interface/web/sites/lib/lang/ca_cron.lng
+++ b/interface/web/sites/lib/lang/ca_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'Cron de type URL seulement. Merci d\'introduire une
 $wb['command_error_empty'] = 'Le champ Commande à exécuter est vide.';
 $wb['command_hint_txt'] = 'par exemple /var/www/clients/clientX/webY/monscript.sh ou https://www.mondomaine.com/chemin/script.php, vous pouvez utiliser la constante [web_root] qui sera remplacée par /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Journaliser la sortie du cron';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 ?>
diff --git a/interface/web/sites/lib/lang/cn_cron.lng b/interface/web/sites/lib/lang/cn_cron.lng
index 65385864c3..f689a930cf 100644
--- a/interface/web/sites/lib/lang/cn_cron.lng
+++ b/interface/web/sites/lib/lang/cn_cron.lng
@@ -23,5 +23,5 @@ $wb['command_hint_txt'] = '例如,/var/www/clients/clientX/webY/myscript.sh 
 $wb['log_output_txt'] = '记录输出';
 $wb['limit_cron_url_txt'] = '仅限 URL 计划任务。请将以 https:// 开头的 URL 作为计划任务命令输入。';
 $wb['command_error_empty'] = '命令为空。';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 ?>
diff --git a/interface/web/sites/lib/lang/cz_cron.lng b/interface/web/sites/lib/lang/cz_cron.lng
index b98a4cbe2a..5144015d6f 100644
--- a/interface/web/sites/lib/lang/cz_cron.lng
+++ b/interface/web/sites/lib/lang/cz_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $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.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/dk_cron.lng b/interface/web/sites/lib/lang/dk_cron.lng
index 8b27dae089..798cb4ea49 100644
--- a/interface/web/sites/lib/lang/dk_cron.lng
+++ b/interface/web/sites/lib/lang/dk_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command er tom.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/el_cron.lng b/interface/web/sites/lib/lang/el_cron.lng
index c014de779a..fe49854430 100644
--- a/interface/web/sites/lib/lang/el_cron.lng
+++ b/interface/web/sites/lib/lang/el_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/en_cron.lng b/interface/web/sites/lib/lang/en_cron.lng
index 2634a1c9c4..ecd146deea 100644
--- a/interface/web/sites/lib/lang/en_cron.lng
+++ b/interface/web/sites/lib/lang/en_cron.lng
@@ -24,4 +24,4 @@ $wb['log_output_txt'] = 'Log output';
 $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with https:// as cron command.';
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['variables_txt'] = 'Variables';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/es_cron.lng b/interface/web/sites/lib/lang/es_cron.lng
index 2a53c6f64a..ccf7753b68 100644
--- a/interface/web/sites/lib/lang/es_cron.lng
+++ b/interface/web/sites/lib/lang/es_cron.lng
@@ -23,4 +23,4 @@ $wb['run_wday_txt'] = 'Días de la semana';
 $wb['server_id_error_empty'] = 'La ID del servidor está vacía.';
 $wb['server_id_txt'] = 'Servidor';
 $wb['unknown_fieldtype_error'] = 'Se ha usado un tipo de campo desconocido.';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/fi_cron.lng b/interface/web/sites/lib/lang/fi_cron.lng
index 2b34c6c755..b45f2e8849 100644
--- a/interface/web/sites/lib/lang/fi_cron.lng
+++ b/interface/web/sites/lib/lang/fi_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/fr_cron.lng b/interface/web/sites/lib/lang/fr_cron.lng
index c05a02cc96..407b246a11 100644
--- a/interface/web/sites/lib/lang/fr_cron.lng
+++ b/interface/web/sites/lib/lang/fr_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'Cron de type URL seulement. Merci d\'introduire une
 $wb['command_error_empty'] = 'Le champ Commande à exécuter est vide.';
 $wb['command_hint_txt'] = 'par exemple /var/www/clients/clientX/webY/monscript.sh ou https://www.mondomaine.com/chemin/script.php, vous pouvez utiliser la constante [web_root] qui sera remplacée par /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Journaliser la sortie du cron';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/hr_cron.lng b/interface/web/sites/lib/lang/hr_cron.lng
index a1ae73ae42..a847d94087 100644
--- a/interface/web/sites/lib/lang/hr_cron.lng
+++ b/interface/web/sites/lib/lang/hr_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'Samo za URL cron. Unesite URL koji počinje sa http
 $wb['command_error_empty'] = 'Naredba je prazna.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/hu_cron.lng b/interface/web/sites/lib/lang/hu_cron.lng
index 4f76cc9fe4..fce63b11f0 100644
--- a/interface/web/sites/lib/lang/hu_cron.lng
+++ b/interface/web/sites/lib/lang/hu_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/id_cron.lng b/interface/web/sites/lib/lang/id_cron.lng
index 113ebd1d20..c001dfb28f 100644
--- a/interface/web/sites/lib/lang/id_cron.lng
+++ b/interface/web/sites/lib/lang/id_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/it_cron.lng b/interface/web/sites/lib/lang/it_cron.lng
index 5d46d2acbe..7227cab4e6 100644
--- a/interface/web/sites/lib/lang/it_cron.lng
+++ b/interface/web/sites/lib/lang/it_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'Solo URL cron. Per cortesia inserire una URL che in
 $wb['command_error_empty'] = 'Command  vuoto.';
 $wb['command_hint_txt'] = 'esempio: /var/www/clients/clientX/webY/myscript.sh o https://www.mydomain.com/path/script.php, puoi usare [web_root] come sostitutivo che viene rimpiazzato da /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/ja_cron.lng b/interface/web/sites/lib/lang/ja_cron.lng
index 6dcc300f31..cb02ffe8c6 100644
--- a/interface/web/sites/lib/lang/ja_cron.lng
+++ b/interface/web/sites/lib/lang/ja_cron.lng
@@ -23,5 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
 
diff --git a/interface/web/sites/lib/lang/nl_cron.lng b/interface/web/sites/lib/lang/nl_cron.lng
index 978b12778e..587cb4d5ce 100644
--- a/interface/web/sites/lib/lang/nl_cron.lng
+++ b/interface/web/sites/lib/lang/nl_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'Geen domein geselecteerd';
diff --git a/interface/web/sites/lib/lang/pl_cron.lng b/interface/web/sites/lib/lang/pl_cron.lng
index d82036ac1a..7212a3a213 100644
--- a/interface/web/sites/lib/lang/pl_cron.lng
+++ b/interface/web/sites/lib/lang/pl_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/pt_cron.lng b/interface/web/sites/lib/lang/pt_cron.lng
index 1edf37c509..a6b06a5305 100644
--- a/interface/web/sites/lib/lang/pt_cron.lng
+++ b/interface/web/sites/lib/lang/pt_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/ro_cron.lng b/interface/web/sites/lib/lang/ro_cron.lng
index 6757f7b4fe..8a8d2aa79f 100644
--- a/interface/web/sites/lib/lang/ro_cron.lng
+++ b/interface/web/sites/lib/lang/ro_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/ru_cron.lng b/interface/web/sites/lib/lang/ru_cron.lng
index 3c7c2fc1df..1774ba5c64 100644
--- a/interface/web/sites/lib/lang/ru_cron.lng
+++ b/interface/web/sites/lib/lang/ru_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'Только URL может быть в задан
 $wb['command_error_empty'] = 'Команда отсутствует.';
 $wb['command_hint_txt'] = 'Например, /var/www/clients/clientX/webY/myscript.sh или https://www.mydomain.com/path/script.php, Вы можете использовать заполнитель [web_root], который заменяется на /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Журнал вывода';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/se_cron.lng b/interface/web/sites/lib/lang/se_cron.lng
index fec186582d..7ecf078210 100644
--- a/interface/web/sites/lib/lang/se_cron.lng
+++ b/interface/web/sites/lib/lang/se_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Kommandofältet är tomt.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/sk_cron.lng b/interface/web/sites/lib/lang/sk_cron.lng
index f635611113..7c9341d813 100644
--- a/interface/web/sites/lib/lang/sk_cron.lng
+++ b/interface/web/sites/lib/lang/sk_cron.lng
@@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt
 $wb['command_error_empty'] = 'Command is empty.';
 $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.';
 $wb['log_output_txt'] = 'Log output';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/interface/web/sites/lib/lang/tr_cron.lng b/interface/web/sites/lib/lang/tr_cron.lng
index 3970c3e1eb..c41267b922 100644
--- a/interface/web/sites/lib/lang/tr_cron.lng
+++ b/interface/web/sites/lib/lang/tr_cron.lng
@@ -23,4 +23,4 @@ $wb['command_hint_txt'] = 'Örnek: /var/www/clients/musteriX/webY/betigim.sh ya
 $wb['log_output_txt'] = 'Günlük çıktısı';
 $wb['limit_cron_url_txt'] = 'Yalnız İnternet adresli zamanlanmış görev kullanılabilir. Lütfen zamanlanmış görev komutu olarak https:// ile başlayan bir İnternet adresi yazın.';
 $wb['command_error_empty'] = 'Komut boÅŸ olamaz.';
-$wb['domain_not_selected_placeholder_txt'] = 'No Domain selected';
+$wb['domain_not_selected_placeholder_txt'] = 'No domain selected';
diff --git a/server/conf/bash.bashrc.master b/server/conf/bash.bashrc.master
index 9393bd9b50..b6577569de 100644
--- a/server/conf/bash.bashrc.master
+++ b/server/conf/bash.bashrc.master
@@ -12,7 +12,6 @@ fi
 
 ## Change machine hostname to site domain ##
 export HOSTNAME=<tmpl_var name='domain'>
-
 </tmpl_if>
 
 
@@ -62,11 +61,3 @@ fi
 #alias la='ls -A'
 #alias l='ls -CF'
 
-<tmpl_if name='use_php_path'>
-# Overwrite the PHP cli binaries by using $PATH:
-export PATH=<tmpl_var name='php_bin_dir'>:$PATH
-</tmpl_if>
-<tmpl_if name='use_php_alias'>
-alias php="<tmpl_var name='php_alias'>"
-</tmpl_if>
-
diff --git a/server/conf/bashrc_el.master b/server/conf/bashrc_el.master
deleted file mode 100644
index 7282b03f5d..0000000000
--- a/server/conf/bashrc_el.master
+++ /dev/null
@@ -1,132 +0,0 @@
-# /etc/bashrc
-
-# Taken from EL9
-
-# System wide functions and aliases
-# Environment stuff goes in /etc/profile
-
-# It's NOT a good idea to change this file unless you know what you
-# are doing. It's much better to create a custom.sh shell script in
-# /etc/profile.d/ to make custom changes to your environment, as this
-# will prevent the need for merging in future updates.
-
-
-
-# Set some more environment variables, they are likely not set in Jailkit setups for EL.
-export TERM="xterm"
-export LESSOPEN="||/usr/bin/lesspipe.sh %s"
-
-dircolors -b >/dev/null
-
-
-
-
-# Prevent doublesourcing
-if [ -z "$BASHRCSOURCED" ]; then
-  BASHRCSOURCED="Y"
-
-  # are we an interactive shell?
-  if [ "$PS1" ]; then
-    if [ -z "$PROMPT_COMMAND" ]; then
-      case $TERM in
-      xterm*|vte*)
-        if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
-            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
-        else
-            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
-        fi
-        ;;
-      screen*)
-        if [ -e /etc/sysconfig/bash-prompt-screen ]; then
-            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
-        else
-            PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
-        fi
-        ;;
-      *)
-        [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
-        ;;
-      esac
-    fi
-    # Turn on parallel history
-    shopt -s histappend
-    history -a
-    # Turn on checkwinsize
-    shopt -s checkwinsize
-    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
-    # You might want to have e.g. tty in prompt (e.g. more virtual machines)
-    # and console windows
-    # If you want to do so, just add e.g.
-    # if [ "$PS1" ]; then
-    #   PS1="[\u@\h:\l \W]\\$ "
-    # fi
-    # to your custom modification shell script in /etc/profile.d/ directory
-  fi
-
-  if ! shopt -q login_shell ; then # We're not a login shell
-    # Need to redefine pathmunge, it gets undefined at the end of /etc/profile
-    pathmunge () {
-        case ":${PATH}:" in
-            *:"$1":*)
-                ;;
-            *)
-                if [ "$2" = "after" ] ; then
-                    PATH=$PATH:$1
-                else
-                    PATH=$1:$PATH
-                fi
-        esac
-    }
-
-    # Set default umask for non-login shell only if it is set to 0
-    [ `umask` -eq 0 ] && umask 022
-
-    SHELL=/bin/bash
-    # Only display echos from profile.d scripts if we are no login shell
-    # and interactive - otherwise just process them to set envvars
-    for i in /etc/profile.d/*.sh; do
-        if [ -r "$i" ]; then
-            if [ "$PS1" ]; then
-                . "$i"
-            else
-                . "$i" >/dev/null
-            fi
-        fi
-    done
-
-    unset i
-    unset -f pathmunge
-  fi
-
-fi
-
-<tmpl_if name='jailkit_chroot'>
-## Hack for Jailkit User to change back to the logged in user ##
-if [ -n "$LOGNAME" ]; then
- if [ "$LOGNAME" != $USER ]; then
-  export HOME=<tmpl_var name='home_dir'>$LOGNAME
-  export USER=$LOGNAME
-  export USERNAME=$LOGNAME
-  cd $HOME
- fi
-fi
-
-## Change machine hostname to site domain ##
-export HOSTNAME=<tmpl_var name='domain'>
-
-</tmpl_if>
-
-<tmpl_if name='use_php_path'>
-# Overwrite the PHP cli binaries by using $PATH:
-export PATH=<tmpl_var name='php_bin_dir'>:$PATH
-</tmpl_if>
-<tmpl_if name='use_php_alias'>
-alias php="<tmpl_var name='php_alias'>"
-</tmpl_if>
-
-### Hack to source a custom bashrc
-#if [ -f ~/.bashrc_ispcuser ]; then
-#	. ~/.bashrc_ispcuser
-#fi
-
-# vim:ts=4:sw=4
diff --git a/server/conf/bashrc_user_deb.master b/server/conf/bashrc_user_deb.master
new file mode 100644
index 0000000000..10b4b94da2
--- /dev/null
+++ b/server/conf/bashrc_user_deb.master
@@ -0,0 +1,137 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+    *i*) ;;
+      *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+    debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+    xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+        # We have color support; assume it's compliant with Ecma-48
+        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+        # a case would tend to support setf rather than setaf.)
+        color_prompt=yes
+    else
+        color_prompt=
+    fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+    ;;
+*)
+    ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+    alias ls='ls --color=auto'
+    #alias dir='dir --color=auto'
+    #alias vdir='vdir --color=auto'
+
+    #alias grep='grep --color=auto'
+    #alias fgrep='fgrep --color=auto'
+    #alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+#alias ll='ls -l'
+#alias la='ls -A'
+#alias l='ls -CF'
+
+<tmpl_if name='jailkit_chroot' op='==' value='n'>
+<tmpl_if name='use_php_path'>
+# Overwrite the PHP cli binaries by using $PATH:
+export PATH=<tmpl_var name='php_bin_dir'>:$PATH
+</tmpl_if>
+<tmpl_if name='use_php_alias'>
+alias php="<tmpl_var name='php_alias'>"
+</tmpl_if>
+</tmpl_if>
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+    . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+  if [ -f /usr/share/bash-completion/bash_completion ]; then
+    . /usr/share/bash-completion/bash_completion
+  elif [ -f /etc/bash_completion ]; then
+    . /etc/bash_completion
+  fi
+fi
+
+
+# Source custom bashrc files
+if [ -d ~/.bashrc.d ]
+then
+	for brc in ~/.bashrc.d/*
+	do
+		if [ -f "$brc" ]; then
+			. "$brc"
+		fi
+	done
+fi
+
+unset brc
diff --git a/server/conf/bashrc_user_generic.master b/server/conf/bashrc_user_generic.master
new file mode 100644
index 0000000000..563ebefdb2
--- /dev/null
+++ b/server/conf/bashrc_user_generic.master
@@ -0,0 +1,35 @@
+<tmpl_if name='jailkit_chroot' op='==' value='y'>
+## Hack for Jailkit User to change back to the logged in user ##
+if [ -n "$LOGNAME" ]; then
+ if [ "$LOGNAME" != $USER ]; then
+  export HOME=<tmpl_var name='home_dir'>$LOGNAME
+  export USER=$LOGNAME
+  export USERNAME=$LOGNAME
+  cd $HOME
+ fi
+fi
+
+## Change machine hostname to site domain ##
+export HOSTNAME=<tmpl_var name='domain'>
+</tmpl_if>
+
+<tmpl_if name='use_php_path'>
+# Overwrite the PHP cli binaries by using $PATH:
+export PATH=<tmpl_var name='php_bin_dir'>:$PATH
+</tmpl_if>
+<tmpl_if name='use_php_alias'>
+alias php="<tmpl_var name='php_alias'>"
+</tmpl_if>
+
+# Source custom bashrc files
+if [ -d ~/.bashrc.d ]
+then
+	for brc in ~/.bashrc.d/*
+	do
+		if [ -f "$brc" ]; then
+			. "$brc"
+		fi
+	done
+fi
+
+unset brc
diff --git a/server/conf/bashrc_user_redhat.master b/server/conf/bashrc_user_redhat.master
new file mode 100644
index 0000000000..0d5b7ef607
--- /dev/null
+++ b/server/conf/bashrc_user_redhat.master
@@ -0,0 +1,52 @@
+# .bashrc
+
+# Source global definitions
+if [ -f /etc/bashrc ]; then
+        . /etc/bashrc
+fi
+
+<tmpl_if name='jailkit_chroot' op='==' value='y'>
+## Hack for Jailkit User to change back to the logged in user ##
+if [ -n "$LOGNAME" ]; then
+ if [ "$LOGNAME" != $USER ]; then
+  export HOME=<tmpl_var name='home_dir'>$LOGNAME
+  export USER=$LOGNAME
+  export USERNAME=$LOGNAME
+  cd $HOME
+ fi
+fi
+
+## Change machine hostname to site domain ##
+export HOSTNAME=<tmpl_var name='domain'>
+</tmpl_if>
+
+<tmpl_if name='use_php_path'>
+# Overwrite the PHP cli binaries by using $PATH:
+export PATH=<tmpl_var name='php_bin_dir'>:$PATH
+</tmpl_if>
+<tmpl_if name='use_php_alias'>
+alias php="<tmpl_var name='php_alias'>"
+</tmpl_if>
+
+# User specific environment
+if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
+then
+    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
+fi
+export PATH
+
+# Uncomment the following line if you don't like systemctl's auto-paging feature:
+# export SYSTEMD_PAGER=
+
+# Source custom bashrc files
+if [ -d ~/.bashrc.d ]
+then
+	for brc in ~/.bashrc.d/*
+	do
+		if [ -f "$brc" ]; then
+			. "$brc"
+		fi
+	done
+fi
+
+unset brc
diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php
index 5ba578a023..0947afced7 100644
--- a/server/lib/classes/system.inc.php
+++ b/server/lib/classes/system.inc.php
@@ -2358,6 +2358,27 @@ class system{
 		}
 	}
 
+	public function get_os_type() {
+		global $app;
+
+
+		$dist = "undetected";
+
+		if(file_exists('/etc/redhat-release') && (filesize('/etc/redhat-release') > 0)) {
+			$dist = "redhat";
+		} elseif(file_exists('/etc/debian_version') && (filesize('/etc/debian_version') > 0)) {
+			$dist = "debian";
+		} elseif(strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu') || (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu'))) {
+			$dist = "ubuntu";
+		} elseif(file_exists('/etc/SuSE-release') && (filesize('/etc/SuSE-release') > 0)) {
+			$dist = "suse";
+		} elseif(file_exists('/etc/gentoo-release') && (filesize('/etc/gentoo-release') > 0)) {
+			$dist = "gentoo";
+		}
+
+		return $dist;
+	}
+
 	public function is_allowed_path($path) {
 		global $app;
 
diff --git a/server/plugins-available/cron_jailkit_plugin.inc.php b/server/plugins-available/cron_jailkit_plugin.inc.php
index b51964a0b7..4b50b561d5 100644
--- a/server/plugins-available/cron_jailkit_plugin.inc.php
+++ b/server/plugins-available/cron_jailkit_plugin.inc.php
@@ -124,7 +124,7 @@ class cron_jailkit_plugin {
 
 				$this->_add_jailkit_user();
 
-				$this->_add_bashrc_jailkit();
+				$this->_setup_php_jailkit();
 
 				$command .= 'usermod -U ? 2>/dev/null';
 				$app->system->exec_safe($command, $parent_domain["system_user"]);
@@ -198,7 +198,7 @@ class cron_jailkit_plugin {
 
 				$this->_add_jailkit_user();
 
-				$this->_add_bashrc_jailkit();
+				$this->_setup_php_jailkit();
 
 				$this->_update_website_security_level();
 
@@ -369,7 +369,7 @@ class cron_jailkit_plugin {
 		}
 	}
 
-	function _add_bashrc_jailkit() {
+	function _setup_php_jailkit() {
 		global $app;
 
 		// Create .bashrc file
@@ -377,15 +377,16 @@ class cron_jailkit_plugin {
 
 		$tpl = new tpl();
 
-		// /etc/bash.bashrc is not supported by Red Hat OS
-		if($app->system->is_redhat_os() == true) {
-			$tpl->newTemplate("bashrc_el.master");
+		if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") {
+			$tpl->newTemplate("bashrc_user_deb.master");
+		} elseif($app->system->get_os_type() == "redhat") {
+			$tpl->newTemplate("bashrc_user_redhat.master");
 		} else {
-			$tpl->newTemplate("bash.bashrc.master");
+			$tpl->newTemplate("bashrc_user_generic.master");
 		}
 
 		// Predefine some template vars
-		$tpl->setVar('jailkit_chroot', true);
+		$tpl->setVar('jailkit_chroot', 'y');
 		$tpl->setVar('domain', $this->parent_domain['domain']);
 		$tpl->setVar('home_dir', $this->_get_home_dir(""));
 
@@ -394,9 +395,6 @@ class cron_jailkit_plugin {
 
 		$php_bin_dir = dirname($this->parent_domain['php_cli_binary']);
 
-		if(!file_exists($this->_get_home_dir($this->parent_domain['system_user']))) $this->_add_jailkit_user();
-
-
 		if(($this->parent_domain['server_php_id'] > 0) && !empty($this->parent_domain['php_cli_binary'])) {
 			if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) {
 				$tpl->setVar('use_php_path', false);
@@ -412,14 +410,24 @@ class cron_jailkit_plugin {
 				$app->log("The PHP cli binary " . $this->parent_domain['php_cli_binary'] . " is not available in the jail of the web " . $this->parent_domain['domain']  . " / cronjob_id: " . $this->cronjob_id  . ". Check your Jailkit setup!", LOGLEVEL_DEBUG);
 				$tpl->setVar('use_php_path', false);
 				$tpl->setVar('use_php_alias', false);
+				if(is_link($this->parent_domain['document_root'] . '/etc/alternatives/php'))
+				{
+					unlink($this->parent_domain['document_root'] . '/etc/alternatives/php');
+				}
+			} else {
+				if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") {
+					if(is_link($this->parent_domain['document_root'] . '/etc/alternatives/php') || is_file($this->parent_domain['document_root'] . '/etc/alternatives/php'))
+					{
+						unlink($this->parent_domain['document_root'] . '/etc/alternatives/php');
+						symlink($this->parent_domain['php_cli_binary'], $this->parent_domain['document_root'] . '/etc/alternatives/php');
+					} else {
+						symlink($this->parent_domain['php_cli_binary'], $this->parent_domain['document_root'] . '/etc/alternatives/php');
+					}
+				}
 			}
 		}
 
-		if($app->system->is_redhat_os() == true) {
-			$bashrc = $this->parent_domain['document_root'] . '/home/' . $this->parent_domain['system_user'] . '/.bashrc';
-		} else {
-			$bashrc = $this->parent_domain['document_root'] . '/etc/bash.bashrc';
-		}
+		$bashrc = $this->parent_domain['document_root'] . '/home/' .$this->parent_domain['system_user'] . '/.bashrc';
 
 		if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc);
 		file_put_contents($bashrc, $tpl->grab());
diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php
index a9d4357069..5a911d0659 100755
--- a/server/plugins-available/shelluser_base_plugin.inc.php
+++ b/server/plugins-available/shelluser_base_plugin.inc.php
@@ -81,7 +81,9 @@ class shelluser_base_plugin {
 
 		//* Check if the resulting path is inside the docroot
 		$web = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]);
-		//$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
+
+		$this->web = $web;
+
 		if(substr($data['new']['dir'],0,strlen($web['document_root'])) != $web['document_root']) {
 			$app->log('Directory of the shell user is outside of website docroot.',LOGLEVEL_WARN);
 			return false;
@@ -134,9 +136,18 @@ class shelluser_base_plugin {
 					$app->system->chown($homedir,$data['new']['puser'],false);
 					$app->system->chgrp($homedir,$data['new']['pgroup'],false);
 				}
+
 				$command = 'useradd -d ? -g ? -o'; // non unique
 				$command .= ' -s ? -u ? ?';
 				$app->system->exec_safe($command, $homedir, $data['new']['pgroup'], $data['new']['shell'], $uid, $data['new']['username']);
+
+				//* Create .bashrc.d directory
+				if(!is_dir($homedir.'/.bashrc.d')){
+					$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
+					$app->system->chown($homedir.'/.bashrc.d', $data['new']['username']);
+					$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
+				}
+
 				$app->log("Executed command: ".$command, LOGLEVEL_DEBUG);
 				$app->log("Added shelluser: ".$data['new']['username'], LOGLEVEL_DEBUG);
 
@@ -169,10 +180,15 @@ class shelluser_base_plugin {
 				$app->system->chown($homedir.'/.profile', $data['new']['username']);
 				$app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']);
 
-				if($data['new']['chroot'] != "jailkit") {
-					$this->_add_bashrc_base();
+				//* Create .bashrc.d directory
+				if(!is_dir($homedir.'/.bashrc.d')){
+					$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
+					$app->system->chown($homedir.'/.bashrc.d', $data['new']['username']);
+					$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
 				}
 
+				$this->_add_user_bashrc();
+
 				// Create symlinks for conveniance, SFTP user should not land in an empty dir.
 				if(!is_link($homedir.'/web')) symlink('../../web', $homedir.'/web');
 				if(!is_link($homedir.'/log')) symlink('../../log', $homedir.'/log');
@@ -296,7 +312,7 @@ class shelluser_base_plugin {
 					if(!is_file($data['new']['dir']).'/.bash_history') {
 						$app->system->touch($homedir.'/.bash_history');
 						$app->system->chmod($homedir.'/.bash_history', 0750);
-						$app->system->chown($homedir.'/.bash_history', $data['new']['username']);
+						$app->system->chown($homedir.'/.bash_history', $data['new']['puser']);
 						$app->system->chgrp($homedir.'/.bash_history', $data['new']['pgroup']);
 					}
 
@@ -304,14 +320,19 @@ class shelluser_base_plugin {
 					if(!is_file($data['new']['dir']).'/.profile') {
 						$app->system->touch($homedir.'/.profile');
 						$app->system->chmod($homedir.'/.profile', 0644);
-						$app->system->chown($homedir.'/.profile', $data['new']['username']);
+						$app->system->chown($homedir.'/.profile', $data['new']['puser']);
 						$app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']);
 					}
 
-					if($data['new']['chroot'] != "jailkit") {
-						$this->_add_bashrc_base();
+					//* Create .bashrc.d directory
+					if(!is_dir($homedir.'/.bashrc.d')){
+						$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
+						$app->system->chown($homedir.'/.bashrc.d', $data['new']['puser']);
+						$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
 					}
 
+					$this->_add_user_bashrc();
+
 					//* Add webfolder protection again
 					$app->system->web_folder_protection($web['document_root'], true);
 				} else {
@@ -549,25 +570,32 @@ class shelluser_base_plugin {
 	}
 
 
-	function _add_bashrc_base() {
+	function _add_user_bashrc() {
 		global $app;
 
 		// Create .bashrc file
 		$app->load('tpl');
 
+
 		$tpl = new tpl();
-		$tpl->newTemplate("bash.bashrc.master");
 
 		// Predefine some template vars
-		$tpl->setVar('jailkit_chroot', false);
+		$tpl->setVar('jailkit_chroot', 'n');
 		$tpl->setVar('use_php_path', false);
 		$tpl->setVar('use_php_alias', false);
 
+		if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") {
+			$tpl->newTemplate("bashrc_user_deb.master");
+		} elseif($app->system->get_os_type() == "redhat") {
+			$tpl->newTemplate("bashrc_user_redhat.master");
+		} else {
+			$tpl->newTemplate("bashrc_user_generic.master");
+		}
+
 		$php_bin_dir = dirname($this->web['php_cli_binary']);
 
 		if(($this->web['server_php_id'] > 0) && !empty($this->web['php_cli_binary'])) {
-			if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir))
-			{
+			if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) {
 				$tpl->setVar('use_php_path', false);
 				$tpl->setVar('use_php_alias', true);
 				$tpl->setVar('php_alias', $this->web['php_cli_binary']);
@@ -586,6 +614,8 @@ class shelluser_base_plugin {
 		if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc);
 
 		file_put_contents($bashrc, $tpl->grab());
+		$app->system->chown($bashrc, $this->data['new']['username']);
+		$app->system->chgrp($bashrc, $this->data['new']['pgroup']);
 		$app->log("Added bashrc script: " . $bashrc, LOGLEVEL_DEBUG);
 		unset($tpl);
 
diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
index 05e0315f0a..8ffe6b1715 100755
--- a/server/plugins-available/shelluser_jailkit_plugin.inc.php
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -141,7 +141,7 @@ class shelluser_jailkit_plugin {
 						//* call the ssh-rsa update function
 						$this->_setup_ssh_rsa();
 
-						$this->_add_bashrc_jailkit();
+						$this->_setup_php_jailkit();
 
 						$app->system->usermod($data['new']['username'], 0, 0, '', '/usr/sbin/jk_chrootsh', '', '');
 
@@ -236,7 +236,7 @@ class shelluser_jailkit_plugin {
 
 						$this->_add_jailkit_user();
 
-						$this->_add_bashrc_jailkit();
+						$this->_setup_php_jailkit();
 
 						//* call the ssh-rsa update function
 						$this->_setup_ssh_rsa();
@@ -345,7 +345,6 @@ class shelluser_jailkit_plugin {
 		}
 
 		$web = $app->db->queryOneRecord("SELECT domain, last_jailkit_hash FROM web_domain WHERE domain_id = ?", $this->data['new']["parent_domain_id"]);
-		//$web = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]);
 
 		$last_updated = preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections']
 						  .' '.$this->jailkit_config['jailkit_chroot_app_programs']
@@ -680,65 +679,84 @@ class shelluser_jailkit_plugin {
 
 
 
-	function _add_bashrc_jailkit() {
+	function _setup_php_jailkit() {
 		global $app;
 
+		$app->uses('system');
+
 		// Create .bashrc file
 		$app->load('tpl');
 
 		$tpl = new tpl();
-
-		// /etc/bash.bashrc is not supported by Red Hat OS
-		if($app->system->is_redhat_os() == true) {
-			$tpl->newTemplate("bashrc_el.master");
-		} else {
-			$tpl->newTemplate("bash.bashrc.master");
-		}
+		$tpl_deb_user_bashrc = new tpl();
 
 		// Predefine some template vars
-		$tpl->setVar('jailkit_chroot', true);
+		$tpl->setVar('jailkit_chroot', 'y');
 		$tpl->setVar('domain', $this->web['domain']);
 		$tpl->setVar('home_dir', $this->_get_home_dir(""));
-
 		$tpl->setVar('use_php_path', false);
 		$tpl->setVar('use_php_alias', false);
 
-		$php_bin_dir = dirname($this->web['php_cli_binary']);
+		if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") {
+			$tpl->newTemplate("bashrc_user_deb.master");
+		} elseif($app->system->get_os_type() == "redhat") {
+			$tpl->newTemplate("bashrc_user_redhat.master");
+		} else {
+			$tpl->newTemplate("bashrc_user_generic.master");
+		}
+
 
-		if(!file_exists($this->_get_home_dir($this->web['system_user']))) $this->_add_jailkit_user();
+		$php_bin_dir = dirname($this->web['php_cli_binary']);
 
 		if(($this->web['server_php_id'] > 0) && !empty($this->web['php_cli_binary'])) {
-			if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) {
-				$tpl->setVar('use_php_path', false);
-				$tpl->setVar('use_php_alias', true);
-				$tpl->setVar('php_alias', $this->web['php_cli_binary']);
-			} else {
-				$tpl->setVar('use_php_path', true);
-				$tpl->setVar('use_php_alias', false);
-				$tpl->setVar('php_bin_dir', $php_bin_dir);
+			if($app->system->get_os_type() != "debian" || $app->system->get_os_type() != "ubuntu") {
+				if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) {
+					$tpl->setVar('use_php_path', false);
+					$tpl->setVar('use_php_alias', true);
+					$tpl->setVar('php_alias', $this->web['php_cli_binary']);
+				} else {
+					$tpl->setVar('use_php_path', true);
+					$tpl->setVar('use_php_alias', false);
+					$tpl->setVar('php_bin_dir', $php_bin_dir);
+				}
 			}
 
 			if(!file_exists($this->web['document_root'] . '/' . $this->web['php_cli_binary'])) {
-				$app->log("The PHP cli binary " . $this->web['php_cli_binary'] . " is not available in the jail of the web " . $this->web['domain']  . " / username: " . $this->username  . ". Check your Jailkit setup!", LOGLEVEL_DEBUG);
+				$app->log("The PHP cli binary " . $this->web['php_cli_binary'] . " is not available in the jail of the web " . $this->web['domain']  . " / SSH/SFTP user: " . $this->username  . ". Check your Jailkit setup!", LOGLEVEL_DEBUG);
 				$tpl->setVar('use_php_path', false);
 				$tpl->setVar('use_php_alias', false);
+				if(is_link($this->web['document_root'] . '/etc/alternatives/php'))
+				{
+					unlink($this->web['document_root'] . '/etc/alternatives/php');
+				}
+			} else {
+				if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") {
+					if(is_link($this->web['document_root'] . '/etc/alternatives/php') || is_file($this->web['document_root'] . '/etc/alternatives/php'))
+					{
+						unlink($this->web['document_root'] . '/etc/alternatives/php');
+						symlink($this->web['php_cli_binary'], $this->web['document_root'] . '/etc/alternatives/php');
+					} else {
+						symlink($this->web['php_cli_binary'], $this->web['document_root'] . '/etc/alternatives/php');
+					}
+				}
+
 			}
 		}
 
-		if($app->system->is_redhat_os() == true) {
-			//$bashrc = $this->web['document_root'] . '/home/' . $this->web['system_user'] . '/.bashrc';
-			$bashrc = $this->web['document_root'] . '/etc/bashrc';
-		} else {
-			$bashrc = $this->web['document_root'] . '/etc/bash.bashrc';
-		}
+		$bashrc = $this->web['document_root'] . '/home/' . $this->data['new']['username'] . '/.bashrc';
 
 		if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc);
 		file_put_contents($bashrc, $tpl->grab());
+		$app->system->chown($bashrc, $this->data['new']['username']);
+		$app->system->chgrp($bashrc, $this->data['new']['pgroup']);
+
 		$app->log("Added bashrc script: " . $bashrc, LOGLEVEL_DEBUG);
 
 		unset($tpl);
 
 
+
+
 	}
 
 } // end class
-- 
GitLab