bash << 'EOF'
server="server_placeholder"
domain="domain_placeholder"
domainpointing()
{
echo "Domain: $domain"
domainIP1=$( dig $domain +short)
domainIP2=$( cat /var/cpanel/users/${username1##*( )} | grep "IP=" | cut -d'=' -f2 )
statuscode=$(curl -LI $domain -o /dev/null -w '%{http_code}\n' -s)

[ $domainIP1 != $domainIP2 ] && { echo -e "\e[3;4;33mIs $domain pointing to assigned IP address\e[0m: ${red}No${reset}" ; exit ; } || { echo -e "\e[3;4;33mIs $domain pointing to assigned IP address\e[0m: ${green}Yes${reset}" ; }
}
sslchecker()
{

curl --insecure -vvI https://$domain 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }' | grep "Let's Encrypt" > /dev/null

[[  $? -eq 0 ]] && { echo -e "\e[3;4;33mIs SSL certificate installed for $domain\e[0m: ${green}Yes${reset}" ; curl --insecure -vvI https://$domain 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }' ; } || { echo -e "\e[3;4;33mIs SSL certificate installed for $domain\e[0m: ${red}No${reset}" ; exit 1; }
}
checkredirection()
{
curl -iLs $domain | egrep 'HTTP|Location' | grep "https://" 2>&1 1>/dev/null
[[  $? -eq 0 ]] && { echo -e "\e[3;4;33mIs $domain redirecting to a secure site $before\e[0m: ${green}Yes${reset}" ; curl -iLs $domain | egrep 'HTTP|Location'; echo "So exiting..." ; exit 1; } || { echo -e "\e[3;4;33mIs $domain redirecting to a secure site $before\e[0m: ${red}No${reset}" ; }
}
finddocroot()
{
        docroot1=$( /root/bin/ui $domain 2> /dev/null | grep "Doc Root" | cut -d":" -f2 )

        [ -z "$docroot1" ] && exit;
}

COLUMNS=$(tput cols)
red=`tput setaf 1`
green=`tput setaf 2`                                    #Adding colours
reset=$(tput sgr0)

#read -p "Enter domain name: " domain
#username1=$( /root/bin/ui $domain 2> /dev/null | grep "User:" | cut -d":" -f2 )
username1=$(  /scripts/whoowns $domain )
title="SSL Certificate Info"
#domainpointing
finddocroot
domainpointing
sslchecker
before="before adding redirection code"
checkredirection
#echo " Document root is $docroot1 "
epooch=$( date +'%s' )
#echo Epoch time is $epooch
[ -f $docroot1/.htaccess ] &&  { cp $docroot1/.htaccess $docroot1/.htaccess_fssl_"$epooch" ; echo -e "\e[3;4;33mBackup of .htaccess file\e[0m: $docroot1/.htaccess_fssl_"$epooch"" ; }

echo -e "\n ##Start Redirection Code## \n\nHeader always set Content-Security-Policy" \""upgrade-insecure-requests;\"""\nRewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n ##End Redirection Code##\n\n$( cat $docroot1/.htaccess 2> /dev/null )" > $docroot1/.htaccess

echo -e "${green}Redirection code added successfully${reset}"
echo -e "\e[3;4;33mNew .htaccess file with Force SSL code\e[0m: $docroot1/.htaccess"
before="after adding redirection code"

statuscode1=$(curl -LI $domain -o /dev/null -w '%{http_code}\n' -s)
[[ $statuscode -ne $statuscode1 ]] && { echo -e "\e[3;4;33mFinal status code for $domain has changed\e[0m from ${green}$statuscode${reset} to${green} $statuscode1"${reset}; }
checkredirection
EOF