Current File : //root/26072024.sh
#!/bin/bash

# Get today's date in YYYYMMDD format
today_date="26072024"

# Define the directory and log file with today's date
mkdir -p /patch/
filechk="/patch/patch${today_date}.log"

# Check if the patch has already been applied
if [ -f "$filechk" ]; then
    echo "Patch ${today_date} Already Updated" >> "$filechk"
    exit
fi

# Create the log file and start the report
touch "$filechk"
echo "report start" >> "$filechk"

# Download and extract the patch report
cd /patch/
wget -O "${today_date}report.zip" "https://d.ovipanel.in/Patch/${today_date}report.zip"
unzip -o "${today_date}report.zip"

# Define PHP path
PHP_PATH="/usr/local/php56/bin/php"

# Check if PHP is in the specified path
if [ -f "$PHP_PATH" ]; then
    echo "PHP multiple version is there" >> "$filechk"
else
    PHP_PATH=$(whereis php | awk '{print $2}')
fi

# Run the PHP script
"$PHP_PATH" /patch/${today_date}report.php >> "$filechk"

# Clean up
rm -f /patch/${today_date}report.php
rm -f /patch/${today_date}report.zip

echo "Patch End" >> "$filechk"