stale-issue-message:'This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.'
stale-issue-label:'stale'
stale-issue-label:$stale_label
exempt-issue-labels: 'Internal, Fixed in next release, Bug:Confirmed, Documentation Needed'
exempt-all-issue-assignees:true
operations-per-run:300
close-issue-reason:'not_planned'
remove_stale:# trigger "stale" removal immediately when stale issues are commented on
# Create a temporary file. We don't use '--suffix' here because not all
# implementations of mktemp support it, e.g. on Alpine
tmpFile="$(mktemp -p "${GRAVITY_TMPDIR}")"
mv "${tmpFile}""${tmpFile%.*}.gravity"
local timestamp
timestamp="$(date --utc +'%s')"
@ -236,20 +227,9 @@ database_table_from_file() {
echo -e "${CROSS} Unable to remove ${tmpFile}"
}
# Update timestamp of last update of this list. We store this in the "old" database as all values in the new database will later be overwritten
database_adlist_updated(){
output=$({printf".timeout 30000\\nUPDATE adlist SET date_updated = (cast(strftime('%%s', 'now') as int)) WHERE id = %i;\\n""${1}"| pihole-FTL sqlite3 "${gravityDBfile}";} 2>&1)
status="$?"
if[["${status}" -ne 0]];then
echo -e "\\n ${CROSS} Unable to update timestamp of adlist with ID ${1} in database ${gravityDBfile}\\n ${output}"
gravity_Cleanup "error"
fi
}
# Check if a column with name ${2} exists in gravity table with name ${1}
gravity_column_exists(){
output=$({printf".timeout 30000\\nSELECT EXISTS(SELECT * FROM pragma_table_info('%s') WHERE name='%s');\\n""${1}""${2}"| pihole-FTL sqlite3 "${gravityDBfile}";} 2>&1)
output=$({printf".timeout 30000\\nSELECT EXISTS(SELECT * FROM pragma_table_info('%s') WHERE name='%s');\\n""${1}""${2}"| pihole-FTL sqlite3 "${gravityTEMPfile}";} 2>&1)
if[["${output}"=="1"]];then
return0# Bash 0 is success
fi
@ -264,11 +244,11 @@ database_adlist_number() {
return;
fi
output=$({printf".timeout 30000\\nUPDATE adlist SET number = %i, invalid_domains = %i WHERE id = %i;\\n""${num_domains}""${num_non_domains}""${1}"| pihole-FTL sqlite3 "${gravityDBfile}";} 2>&1)
output=$({printf".timeout 30000\\nUPDATE adlist SET number = %i, invalid_domains = %i WHERE id = %i;\\n""${2}""${3}""${1}"| pihole-FTL sqlite3 "${gravityTEMPfile}";} 2>&1)
status="$?"
if[["${status}" -ne 0]];then
echo -e "\\n ${CROSS} Unable to update number of domains in adlist with ID ${1} in database ${gravityDBfile}\\n ${output}"
echo -e "\\n ${CROSS} Unable to update number of domains in adlist with ID ${1} in database ${gravityTEMPfile}\\n ${output}"
gravity_Cleanup "error"
fi
}
@ -280,11 +260,11 @@ database_adlist_status() {
return;
fi
output=$({printf".timeout 30000\\nUPDATE adlist SET status = %i WHERE id = %i;\\n""${2}""${1}"| pihole-FTL sqlite3 "${gravityDBfile}";} 2>&1)
output=$({printf".timeout 30000\\nUPDATE adlist SET status = %i WHERE id = %i;\\n""${2}""${1}"| pihole-FTL sqlite3 "${gravityTEMPfile}";} 2>&1)
status="$?"
if[["${status}" -ne 0]];then
echo -e "\\n ${CROSS} Unable to update status of adlist with ID ${1} in database ${gravityDBfile}\\n ${output}"
echo -e "\\n ${CROSS} Unable to update status of adlist with ID ${1} in database ${gravityTEMPfile}\\n ${output}"
# Extract valid domains from source file and append ,${adlistID} to each line and save count to variable for display.
num_domains=$(grep -E "^(${valid_domain_pattern}|${abp_domain_pattern})$""${src}"| tee >(sed "s/$/,${adlistID}/" >> "${target}")| wc -l)
# Check if the source file contained AdBlock Plus style domains, if so we set the global variable and inform the user
if grep -E "^${abp_domain_pattern}$" -m 1 -q "${src}";then
echo"${INFO} List contained AdBlock Plus style domains"
abp_domains=1
fi
# For completeness, we will get a count of non_domains (this is the number of entries left after stripping the source of comments/duplicates/false positives/domains)