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

Feature/support proxy for freshclam #22

Closed
wants to merge 14 commits into from
Closed
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Build, Push Container image to DockerHub

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 6' # At 12:00 AM, only on Saturday

env:
IMAGE_NAME: "clamav-rest"
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
- [Status Codes](#status-codes)
- [Configuration](#configuration)
- [Environment Variables](#environment-variables)
- [Networking](#networking)
- [Networking](#networking)
- [Maintenance / Monitoring](#maintenance--monitoring)
- [Shell Access](#shell-access)

- [Developing](#developing)
- [Developing](#developing)
- [References](#references)

# Introduction
Expand Down Expand Up @@ -128,6 +128,10 @@ Below is the complete list of available options that can be used to customize yo
| `PCRE_MATCHLIMIT` | Maximum PCRE Match Calls - Default `100000` |
| `PCRE_RECMATCHLIMIT` | Maximum Recursive Match Calls to PCRE - Default `2000` |
| `SIGNATURE_CHECKS` | Check times per day for a new database signature. Must be between 1 and 50. - Default `2` |
| `PROXY_SERVER` | Specify a proxy for freshclam to utilize, if applicable, set in environment variables - Optional |
| `PROXY_PORT` | The port for the proxy server, if applicable, set in environment variables - Optional |
| `PROXY_USERNAME` | The username for the proxy server, if applicable, set in environment variables - Optional |
| `PROXY_PASSWORD` | The password for the proxy server, if applicable, set in environment variables - Optional |

## Networking

Expand All @@ -139,7 +143,7 @@ Below is the complete list of available options that can be used to customize yo

## Shell Access

For debugging and maintenance purposes you may want access the containers shell.
For debugging and maintenance purposes you may want access the containers shell.

```bash
docker exec -it (whatever your container name is e.g. clamav-rest) /bin/sh
Expand Down
18 changes: 17 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ sed -i 's/^#MaxPartitions .*$/MaxPartitions '"$MAX_PARTITIONS"'/g' /etc/clamav/c
sed -i 's/^#MaxIconsPE .*$/MaxIconsPE '"$MAX_ICONSPE"'/g' /etc/clamav/clamd.conf
sed -i 's/^#PCREMatchLimit.*$/PCREMatchLimit '"$PCRE_MATCHLIMIT"'/g' /etc/clamav/clamd.conf
sed -i 's/^#PCRERecMatchLimit .*$/PCRERecMatchLimit '"$PCRE_RECMATCHLIMIT"'/g' /etc/clamav/clamd.conf

if [ -n "$PROXY_SERVER" ]; then
sed -i 's~^#HTTPProxyServer .*~HTTPProxyServer '"$PROXY_SERVER"'~g' /etc/clamav/freshclam.conf

# It's not required, but if they also provided a port, then configure it
if [ -n "$PROXY_PORT" ]; then
sed -i 's/^#HTTPProxyPort .*$/HTTPProxyPort '"$PROXY_PORT"'/g' /etc/clamav/freshclam.conf
fi

# It's not required, but if they also provided a username, then configure both the username and password
if [ -n "$PROXY_USERNAME" ]; then
sed -i 's/^#HTTPProxyUsername .*$/HTTPProxyUsername '"$PROXY_USERNAME"'/g' /etc/clamav/freshclam.conf
sed -i 's~^#HTTPProxyPassword .*~HTTPProxyPassword '"$PROXY_PASSWORD"'~g' /etc/clamav/freshclam.conf
fi
fi

(
freshclam --daemon --checks=$SIGNATURE_CHECKS &
clamd &
Expand All @@ -39,4 +55,4 @@ terminate() {
trap terminate CHLD
wait

exit $exitcode
exit $exitcode