#!/bin/bash
# allfpm means reload all three fpm service (5.6/7.0/7.2) and nginx
# All below three dir path will have one file (for e.g example.com.conf ) at one time. Either php56 include dir will have this file or 7.0 or 7.2.
#7.0
php_v70=/etc/opt/rh/rh-php70/php-fpm.d/
#5.6
php_v56=/opt/remi/php56/root/etc/php-fpm.d/
#7.2
php_v72=/etc/php-fpm.d/
read -p 'Enter Website Name: (without www) :- ' site_name
#echo "============================================="
#echo "========== Enter Website's Name ============="
#echo "============================================="
#read -p 'Enter Website Name: (without www) :- ' site_name
#echo "============================================="
#echo "= Choose PHP Version, e.g 5.6 or 7.0 or 7.2 ="
#echo "============================================="
#read -p 'Choose PHP Version (e.g 56 or 70 or 72) :- ' php_ver
site_username=`virtualmin list-domains | grep $site_name | awk '{print $2}'`
rm -vf /home/"$site_username"/public_html/php_ver.php
sleep 2
cp /root/scripts/php_ver.php /home/$site_username/public_html/
chown $site_username: /home/$site_username/public_html/php_ver.php
current_php_ver=`curl -s $site_name/php_ver.php | cut -c1-3 | sed -r 's/\./\ /g' | sed 's/ //g'`
echo "Currently $site_name is running on PHP-FPM $current_php_ver"
read -p 'Choose PHP Version (e.g 56 or 70 or 72) :- ' php_ver
# Condition # 1
#p70=7.0
#p56=5.6
#p72=7.2
if [ $current_php_ver -eq 56 ] || [ $php_ver -eq 70 ]
then
mv $php_v56$site_name.conf $php_v70
# Reload PHP 5.6, PHP 7.0 and Nginx here
allfpm
exit
else
# Condition # 2
if [ $current_php_ver -eq 56 ] || [ $php_ver -eq 72 ]
then
mv $php_v56$site_name.conf $php_v72
# Reload PHP 5.6, PHP 7.2 and Nginx here
allfpm
exit
else
# Condition # 3
if [ $current_php_ver -eq 70 ] || [ $php_ver -eq 72 ]
then
mv $php_v70$site_name.conf $php_v72
# Reload PHP 7.0, PHP 7.2 and Nginx here
allfpm
exit
else
# Condition # 4
if [ $current_php_ver -eq 70 ] || [ $php_ver -eq 56 ]
then
mv $php_v70$site_name.conf $php_v56
# Reload PHP 7.0, PHP 5.6 and Nginx here
allfpm
exit
else
# Condition # 5
if [ $current_php_ver -eq 72 ] || [ $php_ver -eq 56 ]
then
mv $php_v72$site_name.conf $php_v56
# Reload PHP 7.2, PHP 5.6 and Nginx here
allfpm
exit
else
# Condition # 6
if [ $current_php_ver -eq 72 ] || [ $php_ver -eq 70 ]
then
mv $php_v72$site_name.conf $php_v70
# Reload PHP 7.2, PHP 7.0 and Nginx here
allfpm
exit
fi
fi
fi
fi
fi
fi
Overview:- This script will change find out the current running version of php-fpm, then it will ask for choice e.g 5.6, 7.0, 7.2 and then a .conf will be moved to that respective php-fpm include directory, after that fpm services + nginx will be reloaded.
Issue :- When current version is 7.2 and choice is 7.0, its still calling the #1 Condition, i have tested it with echo message to ensure and like this its not working as i want.
Please help.
Aucun commentaire:
Enregistrer un commentaire