Advertisement
Guest User

cron plesk compile webp php

a guest
Apr 7th, 2020
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. #!/bin/bash
  2. while read vc
  3. do
  4.     rm -f /root/webp.php
  5.     echo '<?php $ar=gd_info(); foreach($ar as $k=>$v){  if(strpos($k,"WebP")!==false)  {    if($v==1)      echo "OK";    else      echo "KO";  }}?>' > /root/webp.php
  6.     minv="6"
  7.     configmin="73"
  8.     complete=$(echo $vc | cut -d"|" -f1;)
  9.     short=$(echo $vc | cut -d"|" -f2;)
  10.     vshort=$(echo $short | cut -d"." -f1;)
  11.     vshort2=$(echo $short | cut -d"." -f2;)
  12.     #Check if it's php7.X
  13.     if [ "$vshort" -gt "$minv" ]
  14.     then
  15.     #Test if webp is yet running with this version
  16.      test=$(/opt/plesk/php/$short/bin/php /root/webp.php);
  17.         if [ "$test" = "KO" ]
  18.         then
  19.             cd /root/
  20.             rm -f /root/mirror
  21.             yum -y install make gcc plesk-php$vshort$vshort2-devel libjpeg-turbo-devel libpng-devel libXpm-devel freetype-devel libwebp-devel
  22.             wget http://be2.php.net/get/php-$complete.tar.gz/from/this/mirror --no-check-certificate
  23.             tar -xzf mirror
  24.             cd /root/php-$complete/ext/gd
  25.             /opt/plesk/php/$short/bin/phpize
  26.             #Check if it's php 7.4 and change configure line in this case
  27.             if [ "$vshort$vshort2" -gt "$configmin" ]
  28.             then
  29.                 ./configure --with-php-config=/opt/plesk/php/$short/bin/php-config --with-webp --with-freetype --with-jpeg --with-xpm
  30.             else
  31.                 ./configure --with-php-config=/opt/plesk/php/$short/bin/php-config --with-webp-dir=/usr/include/webp --with-freetype-dir=/usr/include/freetype2/freetype --with-jpeg-dir=/usr/include --with-xpm-dir=/usr/include
  32.             fi
  33.             make
  34.             mv /opt/plesk/php/$short/lib64/php/modules/gd.so /opt/plesk/php/$short/lib64/php/modules/gd.so_orig
  35.             cp modules/gd.so /opt/plesk/php/$short/lib64/php/modules/
  36.             plesk bin php_handler --reread
  37.             #rpm -e --justdb plesk-php$short-gd
  38.             rm -f /root/mirror
  39.             rm -rf /root/php-$complete
  40.        
  41.         fi
  42.      fi
  43. done < <(plesk bin php_handler --list 2>/dev/null | grep enabled | sed "s/ by OS vendor//g"| sed "s/  */ /g"| cut -f3,5 -d" "| sed "s/ /\\|/g")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement