@ -390,12 +390,23 @@ gravity_DownloadBlocklists() {
echo -e " ${ OVER } ${ TICK } ${ str } "
echo -e " ${ OVER } ${ TICK } ${ str } "
fi
fi
if [ [ " ${ status } " -eq 0 && -n " ${ output } " ] ] ; then
echo -e " Encountered non-critical SQL warnings. Please check the suitability of the list you're using!\\nSQL warnings:\\n ${ output } \\n "
fi
rm " ${ target } " > /dev/null 2>& 1 || \
rm " ${ target } " > /dev/null 2>& 1 || \
echo -e " ${ CROSS } Unable to remove ${ target } "
echo -e " ${ CROSS } Unable to remove ${ target } "
gravity_Blackbody = true
gravity_Blackbody = true
}
}
parseList( ) {
local adlistID = " ${ 1 } " src = " ${ 2 } " target = " ${ 3 } "
#Append ,${arg} to every line and then remove blank lines before import
# /.$/a\\ ensures there is a newline on the last line
sed -e " s/ $/, ${ adlistID } /;/^ $/d;/. $/a\\ " " ${ src } " >> " ${ target } "
}
# Download specified URL and perform checks on HTTP status and file content
# Download specified URL and perform checks on HTTP status and file content
gravity_DownloadBlocklistFromUrl( ) {
gravity_DownloadBlocklistFromUrl( ) {
local url = " ${ 1 } " cmd_ext = " ${ 2 } " agent = " ${ 3 } " adlistID = " ${ 4 } " saveLocation = " ${ 5 } " target = " ${ 6 } "
local url = " ${ 1 } " cmd_ext = " ${ 2 } " agent = " ${ 3 } " adlistID = " ${ 4 } " saveLocation = " ${ 5 } " target = " ${ 6 } "
@ -481,14 +492,13 @@ gravity_DownloadBlocklistFromUrl() {
if [ [ " ${ success } " = = true ] ] ; then
if [ [ " ${ success } " = = true ] ] ; then
if [ [ " ${ httpCode } " = = "304" ] ] ; then
if [ [ " ${ httpCode } " = = "304" ] ] ; then
# Add domains to database table file
# Add domains to database table file
#Append ,${arg} to every line and then remove blank lines before import
parseList " ${ adlistID } " " ${ saveLocation } " " ${ target } "
sed -e " s/ $/, ${ adlistID } /;/^ $/d " " ${ saveLocation } " >> " ${ target } "
# Check if $patternbuffer is a non-zero length file
# Check if $patternbuffer is a non-zero length file
elif [ [ -s " ${ patternBuffer } " ] ] ; then
elif [ [ -s " ${ patternBuffer } " ] ] ; then
# Determine if blocklist is non-standard and parse as appropriate
# Determine if blocklist is non-standard and parse as appropriate
gravity_ParseFileIntoDomains " ${ patternBuffer } " " ${ saveLocation } "
gravity_ParseFileIntoDomains " ${ patternBuffer } " " ${ saveLocation } "
# Append ,${arg} to every line and then remove blank lines before import
# Add domains to database table file
sed -e " s/ $/, ${ adlistID } /;/^ $/d " " ${ saveLocation } " >> " ${ target } "
parseList " ${ adlistID } " " ${ saveLocation } " " ${ target } "
else
else
# Fall back to previously cached list if $patternBuffer is empty
# Fall back to previously cached list if $patternBuffer is empty
echo -e " ${ INFO } Received empty file: ${ COL_LIGHT_GREEN } using previously cached list ${ COL_NC } "
echo -e " ${ INFO } Received empty file: ${ COL_LIGHT_GREEN } using previously cached list ${ COL_NC } "
@ -497,8 +507,8 @@ gravity_DownloadBlocklistFromUrl() {
# Determine if cached list has read permission
# Determine if cached list has read permission
if [ [ -r " ${ saveLocation } " ] ] ; then
if [ [ -r " ${ saveLocation } " ] ] ; then
echo -e " ${ CROSS } List download failed: ${ COL_LIGHT_GREEN } using previously cached list ${ COL_NC } "
echo -e " ${ CROSS } List download failed: ${ COL_LIGHT_GREEN } using previously cached list ${ COL_NC } "
# Append ,${arg} to every line and then remove blank lines before import
# Add domains to database table file
sed -e " s/ $/, ${ adlistID } /;/^ $/d " " ${ saveLocation } " >> " ${ target } "
parseList " ${ adlistID } " " ${ saveLocation } " " ${ target } "
else
else
echo -e " ${ CROSS } List download failed: ${ COL_LIGHT_RED } no cached list available ${ COL_NC } "
echo -e " ${ CROSS } List download failed: ${ COL_LIGHT_RED } no cached list available ${ COL_NC } "
fi
fi