Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENABLE_BROWSERS_LIST & CUSTOM_BROWSERS env variables #163

Merged

Conversation

RobertD502
Copy link
Contributor

Changes

  • Added optional ENABLE_BROWSERS_LIST and CUSTOM_BROWSERS variables.

start.sh script changes

  • When the container is started, the original goaccess browsers.list (located in /goaccess/config/) is copied to the /goaccess-config directory. If the user defined the CUSTOM_BROWSERS variable with a comma delimited list consisting of Browser:Browser_category items, these are appended to the /goaccess-config/browsers.list file.
  • By checking if browsers.list is already present in the /goaccess-config directory at container runtime and subsequently removing it prior to copying over a fresh copy from the /goaccess/config directory, we can ensure that the browsers.list always aligns with the user's CUSTOM_BROWSERS variable. Since the /goaccess/config/browsers.list file is persistent, appending to it would result in custom browsers being left behind within the file when a user removes browser(s) from the CUSTOM_BROWSERS variable during a container restart - copying over a fresh file prior to appending custom browsers gets around this potential issue.
  • For user defined CUSTOM_BROWSERS, if a Browser has already been defined in browsers.list, it will be ignored and not appended to the list. Only the browser category (e.g., Crawlers) can be the same for multiple custom browser definitions.

custom.sh, ncsa_combined.sh, npm.sh, npm_error.sh, npm_redirection.sh, traefik.sh script changes

  • If the ENABLE_BROWSERS_LIST variable is set to True, for each log type the corresponding goaccess.conf file has the line browsers-file /goaccess-config/browsers.list appended to it enabling the use of the browsers.list file.
  • If a user didn't define the CUSTOM_BROWSERS variable, this will still allow them to use the default goaccess browsers list.
    Note regarding Custom Log Types: Since a user may already have a browser.list file defined in their goaccess.conf file, if that is the case, their choice is respected instead of forcing them to use the file located at /goaccess-config/browsers.list. However, if they don't, but did enable the browsers list via the variable, then /goaccess-config/browsers.list is used and their custom browsers (if any defined) are appended to said file.

Documentation

  • I went ahead and added documentation related to these two new variables to the README

#Browsers List
- During startup, if a `browsers.list` file already exists in the `/goaccess-config` directory, it is removed and replaced with the original goaccess `browsers.list` file.
- If the file doesn't exist, it is copied from the `/goaccess/config` directory to the `/goaccess-config` directory.

#Modifying the browsers list
- Given the user's definition of the `CUSTOM_BROWSERS` env variable, each browser:browser category combo is appended to the `browsers.list` file (only if the browser isn't already defined in the `browsers.list`).
- If the user sets the env variable `ENABLE_BROWSERS_LIST` to true, their `goaccess.conf` file is modified to include the `browsers-file` which points to the `/goaccess-config/browsers.list` file.
- In the event that the user's `goaccess.conf` file already references a `browsers.list` file, the `/goaccess-config/browsers.list` file is ignored in favor of the user's file.
@xavier-hernandez
Copy link
Owner

I'll look at this today or tomorrow. I briefly looked over, and it looks good. Thanks.

@xavier-hernandez xavier-hernandez merged commit b06bef0 into xavier-hernandez:main Oct 9, 2023
@RobertD502 RobertD502 deleted the add_browsers_list branch October 9, 2023 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants