Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Last active September 9, 2016 22:45
Show Gist options
  • Save rushipkar90/d0f9cccca2985725397f0a9d48979cc9 to your computer and use it in GitHub Desktop.
Save rushipkar90/d0f9cccca2985725397f0a9d48979cc9 to your computer and use it in GitHub Desktop.
Upgradephp along with extensions
#/bin/bash
set -x
echo > /usr/local/src/customphpini.txt;
echo > /usr/local/src/commentphp.txt;
echo > /usr/local/src/oldextensions.txt;
echo > /usr/local/src/newextension.txt;
oldextension=`php -i | grep -w "extension_dir =" | grep -v "sqlite" | awk '{print $3}'`;
ls -la $oldextension | awk '{print $9}' | grep -v "./" | grep -v "../" | grep -v '^$' > /usr/local/src/oldextensions.txt;
thetime=`date +"%Y-%m-%d-%S"`;
php -m > /usr/local/src/modules.txt
echo "================================" >> /usr/local/src/modules.txt
/usr/local/apache/bin/apachectl -M >> /usr/local/src/modules.txt
cp -ar /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_$thetime;
cp -ar /usr/local/lib/php.ini /usr/local/lib/php.ini_$thetime;
cp -ar /var/cpanel/easy/apache/profile/_main.yaml /var/cpanel/easy/apache/profile/_main.yaml_$thetime;
cat /var/cpanel/easy/apache/profile/_main.yaml | sed 's/"Cpanel::Easy::PHP5::5_38": 1/"Cpanel::Easy::PHP5::6_25": 1/g' > /var/cpanel/easy/apache/profile/custom/custom_hp_mod.yaml;
/scripts/easyapache --build --profile=custom_hp_mod.yaml;
newextension=`php -i | grep -w "extension_dir =" | grep -v "sqlite" | awk '{print $3}'`;
ls -la $newextension | awk '{print $9}' | grep -v "./" | grep -v "../" | grep -v '^$' > /usr/local/src/newextension.txt;
diff /usr/local/src/oldextensions.txt /usr/local/src/newextension.txt | grep "<" | cut -d "<" -f2 | awk '{print $1}' > /usr/local/src/missingextensions.txt
for l in `cat /usr/local/src/missingextensions.txt`; do
insextension=`echo $l | cut -d "." -f1`;
echo $insextension;
cd /home/cpeasyapache/src/php-5.6.25/ext/$insextension;
phpize;
./configure;
make;
make install;
done
CP_ACCOUNTS=`ls -1A /var/cpanel/users/ | grep -v "root"`
for user in `echo -n $CP_ACCOUNTS`
do
echo $user;
maindomain=`cat /etc/trueuserdomains | grep "$user" | cut -d : -f1`;
homedir=`cat /var/cpanel/userdata/$user/$maindomain | grep homedir | cut -d / -f2`;
echo "$homedir";
if [ "$homedir" = home ]; then
find /home/$user -type d -name mail -prune -o -name "php.ini" -print >> /usr/local/src/customphpini.txt;
#find /home/$user -type f -name 'php.ini' | grep -v mail >> /usr/local/src/customphpini.txt;
else
#find /home2/$user -type f -name 'php.ini' | grep -v mail >> /usr/local/src/customphpini.txt;
find /home2/$user -type d -name mail -prune -o -name "php.ini" -print >> /usr/local/src/customphpini.txt;
fi
done
for j in `cat /usr/local/src/customphpini.txt`; do
echo "$j";
cp -ar "$j" "$j"_$thetime;
phppath=`echo "$j" `;
for k in "$phppath "; do
if [ -f $k ]
then
extensionpath=`cat $k | grep -w "extension_dir =" | cut -d "=" -f2 | replace '"' '' | replace " " ""`
replace "$extensionpath" "$newextension" -- $k;
replace "/usr/local/Zend/lib/Guard-7.0.0/php-5.5.x/ZendGuardLoader.so" "/usr/local/Zend/lib/Guard-7.0.0/php-5.6.x/ZendGuardLoader.so" -- $k;
replace "ioncube_loader_lin_5.5.so" "ioncube_loader_lin_5.6.so" -- $k;
replace "/usr/local/Zend/lib/Guard-6.0.0/php-5.4.x/ZendGuardLoader.so" "/usr/local/Zend/lib/Guard-7.0.0/php-5.6.x/ZendGuardLoader.so" -- $k;
replace "ioncube_loader_lin_5.4.so" "ioncube_loader_lin_5.6.so" -- $k;
# echo $extensionpath;
fi
done;
done;
php -m > /usr/local/src/upgrade_modules.txt
echo "================================" >> /usr/local/src/upgrade_modules.txt
/usr/local/apache/bin/apachectl -M >> /usr/local/src/upgrade_modules.txt
set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment