Skip to content

Commit cb926ec

Browse files
committed
Fixes issues with custom docroot function
1. When installling Drupal for example: In public_html you got /vendor and /web v-change-web-domain-custom-docroot user domain.com domain.com web changes also open_basedir also to /home/demo/web/domain.eu/public_html/web causing system unable to work Added "PHP" flag v-change-web-domain-custom-docroot to force folder to use /home/demo/web/domain.eu/public_html
1 parent 853fcb2 commit cb926ec

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

bin/v-add-web-domain-backend

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
6666
-e "s|%backend%|$backend_type|g"\
6767
-e "s|%backend_version%|$backend_version|g" > $pool/$backend_type.conf
6868

69+
6970
# Set correct document root path
7071
if [ ! -z "$CUSTOM_DOCROOT" ]; then
7172
docroot="$CUSTOM_DOCROOT"
73+
if [ ! -z "$CUSTOM_PHPROOT" ]; then
74+
docroot="$CUSTOM_PHPROOT"
75+
fi
7276
sed -i "s|/home\/$user\/web\/$domain\/public_html|$docroot|g" $pool/$backend_type.conf
7377
else
7478
docroot="$HOMEDIR/$user/web/$domain/public_html/"

bin/v-change-web-domain-docroot

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# info: Changes the document root for an existing web domain
33

4-
# options: USER DOMAIN TARGET_DOMAIN [DIRECTORY]
4+
# options: USER DOMAIN TARGET_DOMAIN [DIRECTORY] [PHP]
55
# example usage:
66
# add custom docroot: v-change-web-domain-docroot admin domain.tld otherdomain.tld
77
# points domain.tld to otherdomain.tld's document root.
@@ -25,6 +25,7 @@ domain=$2
2525
# so they are correctly passed through to domain.sh
2626
export target_domain=$3
2727
export target_directory=$4
28+
export php=$5
2829

2930
# Includes
3031
source $HESTIA/func/main.sh
@@ -66,13 +67,15 @@ check_hestia_demo_mode
6667
# Unset existing custom document root path
6768
if [ ! -z "$CUSTOM_DOCROOT" ]; then
6869
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT' ""
70+
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_PHPROOT' ""
6971
fi
7072

7173
# If target domain value is 'default', remove the custom document root
7274
# value and rebuild web domain to restore default configuration.
7375
# Otherwise, set target document root path accordingly based on passed values.
7476
if [ "$target_domain" = "default" ]; then
7577
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT' ""
78+
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_PHPROOT' ""
7679
else
7780
# Check for existence of specified directory under target domain's public_html folder
7881
if [ ! -z "$target_directory" ]; then
@@ -81,12 +84,24 @@ else
8184
exit 1
8285
else
8386
CUSTOM_DOCROOT="$HOMEDIR/$user/web/$target_domain/public_html/$target_directory/"
87+
if [ ! -z "$php" ]; then
88+
custom_phproot="$HOMEDIR/$user/web/$target_domain/public_html/"
89+
else
90+
custom_phproot="$HOMEDIR/$user/web/$target_domain/public_html/$target_directory/"
91+
fi
8492
fi
8593
else
8694
CUSTOM_DOCROOT="$HOMEDIR/$user/web/$target_domain/public_html/"
95+
custom_phproot="$HOMEDIR/$user/web/$target_domain/public_html/"
8796
fi
97+
8898
add_object_key 'web' 'DOMAIN' "$domain" 'CUSTOM_DOCROOT' 'IP6'
99+
add_object_key 'web' 'DOMAIN' "$domain" 'CUSTOM_PHPROOT' 'IP6'
100+
89101
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_DOCROOT' "$CUSTOM_DOCROOT"
102+
# CUSTOM_PHPROOT got overwriten by default
103+
CUSTOM_PHPROOT=$custom_phproot
104+
update_object_value 'web' 'DOMAIN' "$domain" '$CUSTOM_PHPROOT' "$CUSTOM_PHPROOT"
90105
fi
91106

92107
#----------------------------------------------------------#

web/add/web/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
$v_custom_doc_folder = escapeshellarg($_POST['v-custom-doc-folder']);
242242
$v_domain = escapeshellarg(trim($_POST['v_domain']));
243243

244-
exec(HESTIA_CMD."v-change-web-domain-docroot ".$user." ".$v_domain." ".$v_custom_doc_domain." ".$v_custom_doc_folder, $output, $return_var);
244+
exec(HESTIA_CMD."v-change-web-domain-docroot ".$user." ".$v_domain." ".$v_custom_doc_domain." ".$v_custom_doc_folder." yes", $output, $return_var);
245245
check_return_code($return_var,$output);
246246
unset($output);
247247
$v_custom_doc_root = 1;

web/edit/web/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@
766766
$v_custom_doc_domain = escapeshellarg($_POST['v-custom-doc-domain']);
767767
$v_custom_doc_folder = escapeshellarg($_POST['v-custom-doc-folder']);
768768

769-
exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." ".$v_custom_doc_domain." ".$v_custom_doc_folder, $output, $return_var);
769+
exec(HESTIA_CMD."v-change-web-domain-docroot ".$v_username." ".escapeshellarg($v_domain)." ".$v_custom_doc_domain." ".$v_custom_doc_folder ." yes", $output, $return_var);
770770
check_return_code($return_var,$output);
771771
unset($output);
772772
$v_custom_doc_root = 1;

0 commit comments

Comments
 (0)