Skip to content

Commit d9de3d8

Browse files
Skamaslejaapmarcus
andauthored
Avoid cancel backup restore if one domain can set PHP version as in o… (hestiacp#4241)
* Avoid cancel backup restore if one domain can set PHP version as in origin Fix public_html group Notify the user that the PHP version could not be assigned to the domain * Update v-import-cpanel * Few minor changes * Fix format --------- Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent d5744eb commit d9de3d8

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

bin/v-import-cpanel

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ function get_domain_path() {
221221
echo -en "-- $sync_count restored files\r"
222222
done
223223
chown $new_user:$new_user -R /home/$new_user/web/$cp_domain/public_html
224+
chown $new_user:www-data /home/$new_user/web/$cp_domain/public_html
224225
chmod 751 /home/$new_user/web/$cp_domain/public_html
225226
fi
226227
done
@@ -249,27 +250,39 @@ rsync -av --exclude-from='exclude_path' homedir/public_html/ /home/$new_user/web
249250
done
250251

251252
chown $new_user:$new_user -R /home/$new_user/web/$main_domain1/public_html
253+
chown $new_user:www-data /home/$new_user/web/$main_domain1/public_html
252254
chmod 751 /home/$new_user/web/$main_domain1/public_html
253255

254256
####### Set Domain PHP version
255257
PHP_VERSION_LINE=$(grep -r "phpversion:" userdata/$main_domain1)
256258
CPANEL_PHP_VERSION=${PHP_VERSION_LINE#*: }
257-
CPANEL_PHP_VERSION=$(echo $CPANEL_PHP_VERSION | grep -oP '(?<=php)\d+')
258-
HESTIA_PHP_VERSION="PHP-${CPANEL_PHP_VERSION:0:1}_${CPANEL_PHP_VERSION:1}"
259-
260-
if $BIN/v-list-web-templates-backend | grep -qw "$HESTIA_PHP_VERSION"; then
261-
echo "Setting PHP version to $HESTIA_PHP_VERSION for $main_domain1 under user $new_user"
262-
$BIN/v-change-web-domain-backend-tpl $new_user $main_domain1 $HESTIA_PHP_VERSION
263-
if [ $? -ne 0 ]; then
264-
echo "Failed to set PHP version for $main_domain1"
265-
exit 1
259+
if [ -n "$CPANEL_PHP_VERSION" ]; then
260+
CPANEL_PHP_VERSION=$(echo $CPANEL_PHP_VERSION | grep -oP '(?<=php)\d+')
261+
HESTIA_PHP_VERSION="PHP-${CPANEL_PHP_VERSION:0:1}_${CPANEL_PHP_VERSION:1}"
262+
263+
if $BIN/v-list-web-templates-backend | grep -qw "$HESTIA_PHP_VERSION"; then
264+
echo "Setting PHP version to $HESTIA_PHP_VERSION for $main_domain1 under user $new_user"
265+
$BIN/v-change-web-domain-backend-tpl $new_user $main_domain1 $HESTIA_PHP_VERSION
266+
if [ $? -ne 0 ]; then
267+
tput setaf 1
268+
echo "ERROR!! Failed to set same PHP version for $main_domain1 setting default, please check this to avoid errors."
269+
tput sgr0
270+
else
271+
echo "PHP version for $main_domain1 set to $HESTIA_PHP_VERSION"
272+
fi
266273
else
267-
echo "PHP version for $main_domain1 set to $HESTIA_PHP_VERSION"
274+
tput setaf 1
275+
echo "PHP version $HESTIA_PHP_VERSION is not installed on HestiaCP."
276+
echo "Please install and set it to avoid errors in website."
277+
echo "The restoration will continue but the website may not work as expected"
278+
tput sgr0
268279
fi
269280
else
270-
echo "PHP version $HESTIA_PHP_VERSION is not installed on HestiaCP."
271-
echo "Please install it before trying to set it for a domain."
272-
exit 1
281+
tput setaf 1
282+
echo "Unable to detect PHP version used on old server"
283+
echo "Please check you old PHP version and set the PHP version in domain settings"
284+
echo "The restoration will continue but the website may not work as expected"
285+
tput sgr0
273286
fi
274287

275288
##################

0 commit comments

Comments
 (0)