Able to run user script in gravity.sh for Pi-hole Milestone 5


#1

Some of the users as me are using scripts to change the content of preEventHorizon before written to the gravity.list file.

When in the future the lists are moved to a Database to have more information and possibilities, the current way of running of user scripts after Pihole -g become futile. This because preEventHorizon (pre-gravity.list) is already imported into the database. Gravity.list has made obsolete in Milestone 5.

Changed code part of gravity.sh to execute/etc/pihole/userscript if present.

  str="Removing duplicate domains"
  if [[ "${haveSourceUrls}" == true ]]; then
    echo -ne "  ${INFO} ${str}..."
  fi

  sort -u "${piholeDir}/${parsedMatter}" > "${piholeDir}/${preEventHorizon}"

  # Running user script if present
  if  [[ -x "/etc/pihole/userscript"  ]]; then 
     /etc/pihole/userscript
  fi

  if [[ "${haveSourceUrls}" == true ]]; then
    echo -e "${OVER}  ${TICK} ${str}"
    # Format $preEventHorizon line total as currency
    num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${preEventHorizon}")")
    echo -e "  ${INFO} Number of unique domains trapped in the Event Horizon: ${COL_BLUE}${num}${COL_NC}"
  fi
}

# Whitelist user-defined domains

The inserted code is:

  # Running user script if present
  if  [[ -x "/etc/pihole/userscript"  ]]; then 
     /etc/pihole/userscript
  fi

More information on the Database based blocking can be found in the following posting:

https://discourse.pi-hole.net/t/white-blacklist-add-reason-field/1439/11


#3

This is an unsupported use case, and not a feature we have ever supported. Adding this feature would lead to very difficult to troubleshoot issues if the user’s script does not work. We can not support arbitrary modifications of core Pi-hole functionality.


#4

It does not have make support more difficult because you know the name and location of the the user script.
When generation a debug token you can check for that user script and state that, unless the script is removed and Pi-hole restarted, to retest functionallity, no debug token is being generated.

The script is changing the lists, like we are allowed to decide what list we want to use for blocking.


#6

It makes support immensely more complicated if an arbitrary user script is running. That script could be doing literally anything, and we can not support that. Even if it’s not running, when it ran before it could have caused unforeseen changes which permanently changed the state of the system.