@@ -7,34 +7,37 @@ source $HESTIA/conf/hestia.conf
77
88# Check if apache2 is in use
99if [ " $WEB_SYSTEM " != " apache2" ]; then
10- echo " Apache2 isnt installed on your system, canceling migration..."
11- exit
10+ echo " Apache2 isn't installed on your system, canceling migration..." && exit 1
1211fi
1312
1413# Check if mod_event is already enabled
15- if apache2ctl -M | grep -q mpm_event_module; then
16- echo " mod_event is already enabled, canceling migration..."
17- exit
14+ if [ $( a2query -M) = ' event' ]; then
15+ echo " mod_event is already enabled, canceling migration..." && exit 1
1816fi
1917
20- # Disable prefork and php, enable event
21- a2dismod php5.6 > /dev/null 2>& 1
22- a2dismod php7.0 > /dev/null 2>&1
23- a2dismod php7.1 > /dev/null 2>&1
24- a2dismod php7.2 > /dev/null 2>&1
25- a2dismod php7.3 > /dev/null 2>&1
26- a2dismod php7.4 > /dev/null 2>&1
27- a2dismod mpm_prefork > /dev/null 2>&1
28- a2dismod mpm_itk > /dev/null 2>&1
29- a2dismod ruid2 > /dev/null 2>&1
30- a2enmod mpm_event > /dev/null 2>&1
31-
32- # Restart apache2 service
33- systemctl restart apache2
18+ if ! apache2ctl configtest > /dev/null 2>&1 ; then
19+ echo " Apache2 configtest failed " && exit 1
20+ fi
21+
22+ a2modules= " php5.6 php7.0 php7.1 php7.2 php7.3 php7.4 mpm_prefork mpm_itk ruid2 "
23+ changed_a2modules= " "
24+
25+ for module in $a2modules ; do
26+ a2query -q -m " $module " || continue
27+ a2dismod " $module "
28+ changed_a2modules= " ${changed_a2modules} ${module} "
29+ done
30+
31+ a2enmod --quiet mpm_event
3432
3533# Check if all went well
36- if apache2ctl -M | grep -q mpm_event_module; then
37- echo " mpm_event module was successfully activated."
38- else
39- echo " Something went wrong, please try to migrate manualy to mpm_event."
34+ if ! apache2ctl configtest > /dev/null 2>&1 ; then
35+ echo " Something went wrong, rolling back. Please try to migrate manually to mpm_event."
36+ for module in $changed_a2modules ; do
37+ a2enmod " $module "
38+ done
39+ exit 1
4040fi
41+
42+ echo " mpm_event module was successfully activated."
43+ systemctl restart apache2
0 commit comments