Current File : //root/patch11042019.sh
filechk="/etc/sentora/panel/patch11042019.log"
if [ -f "$filechk" ]
then
    echo "Patch 11042019 Already Updated" >> /etc/sentora/panel/patch11042019.log
    exit
fi
touch /etc/sentora/panel/patch11042019.log
echo "Patch 11042019 started here" >> /etc/sentora/panel/patch11042019.log
cd /etc/sentora/panel
wget -O 11042019report.zip http://hostingraja.info/patch/11042019report.zip
unzip -o 11042019report.zip
PHP_PATH="/usr/local/php56/bin/php"
if [ -f "$PHP_PATH" ]
then
    echo "Php multiple version is there" >> /etc/sentora/panel/patch11042019.log
else
PHP_PATH=`whereis php | awk '{print $2}'`
fi
`$PHP_PATH /etc/sentora/panel/11042019report.php >> /etc/sentora/panel/patch11042019.log`
rm -f /etc/sentora/panel/11042019report.php
rm -f /etc/sentora/panel/11042019report.zip
if grep -q ssl_renew "/var/spool/cron/root"; then
        echo "ssl_renew Script alreadey added"  
else
	PGREP=`whereis pgrep | awk '{print $2}'`
	JAVA="java"
	$PGREP ${JAVA} -x
	if [ $? -ne 0 ]
	then
			cd /etc/sentora/panel/modules/ssl/code/
			wget -O ssl_renew.zip http://hostingraja.info/patch/ssl_renew.zip
			unzip -o ssl_renew.zip
			rm -f ssl_renew.zip
			PHP_PATH=`whereis php | awk '{print $2}'`
			FILEMANAGER_PATH="/etc/sentora/panel/etc/apps/filemanager/php.ini"
			if [ -f "$FILEMANAGER_PATH" ]
			then
			echo "0 2 * * 4 $PHP_PATH -c /etc/sentora/panel/etc/apps/filemanager/php.ini  /etc/sentora/panel/modules/ssl/code/ssl_renew.php >/dev/null 2>&1" >> /var/spool/cron/root
			`$PHP_PATH -c /etc/sentora/panel/etc/apps/filemanager/php.ini  /etc/sentora/panel/modules/ssl/code/ssl_renew.php >/dev/null 2>&1`
			else
			echo "0 2 * * 4 $PHP_PATH /etc/sentora/panel/modules/ssl/code/ssl_renew.php >/dev/null 2>&1" >> /var/spool/cron/root
			`$PHP_PATH /etc/sentora/panel/modules/ssl/code/ssl_renew.php >/dev/null 2>&1`
			fi
			chown apache. /etc/sentora/panel/modules/ssl/code/ssl_renew.php
			chmod 644 /etc/sentora/panel/modules/ssl/code/ssl_renew.php
			chmod +x  /etc/sentora/panel/spfdkim.php
	else
		echo "Java no need to update"  >> /etc/sentora/panel/patch11042019.log
	fi
fi
echo "Patch 11042019 updated successfully"  >> /etc/sentora/panel/patch11042019.log