Skip to content

Commit 51cf2cd

Browse files
Added more configuration options via environment variables
1 parent 93830cd commit 51cf2cd

2 files changed

Lines changed: 61 additions & 3 deletions

File tree

docker/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ This container is configured using environment variables. The following variable
2323

2424
| Variable | Default Value | Description |
2525
| :--- | :--- | :--- |
26+
| `DEBUG` | `False` | Debug mode |
2627
| `ADMIN_NAME` | `Your Name` | Your name |
2728
| `ADMIN_EMAIL` | `you@example.com` | Your e-mail address |
2829
| `TIMEZONE` | `America/New_York` | Your timezone |
30+
| `LANGUAGE_CODE` | `en-us` | Your language |
31+
| `SECRET_KEY` | | Unique string not to be shared with anyone. Leave empty to generate one randomly |
32+
| `MAX_MIRRORS` | `2` | Maximum number of mirrors to add or refresh per repo |
33+
| `MAX_MIRROR_FAILURES` | `14` | Maximum number of failures before disabling a mirror, set to `-1` to never disable mirrors |
34+
| `DAYS_WITHOUT_REPORT` | `14` | Number of days to wait before raising that a host has not reported |
35+
| `ERRATA_OS_UPDATES` | `yum, rocky, alma, arch, ubuntu, debian` | List of errata sources to update, remove unwanted ones to improve performance |
36+
| `ALMA_RELEASES` | `8, 9, 10` | List of Alma Linux releases to update |
37+
| `DEBIAN_CODENAMES` | `bookworm, trixie` | List of Debian Linux releases to update |
38+
| `UBUNTU_CODENAMES` | `jammy, noble` | List of Ubuntu Linux releases to update |
2939
| `DB_ENGINE` | `SQLite` | Database engine to be used. Choose between `MySQL` or `PostgreSQL`, leave empty to use default `SQLite` |
3040
| `DB_HOST` | | Database hostname, IP or container name |
31-
| `DB_PORT` |` | Database port |
41+
| `DB_PORT` | | Database port |
3242
| `DB_DATABASE` | | Database name |
3343
| `DB_USER` | | Database user |
3444
| `DB_PASSWORD` | | Database password |

docker/docker-entrypoint.sh

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
conf="/etc/patchman/local_settings.py"
44

5+
# Configure DEBUG
6+
if "${DEBUG}"; then
7+
sed -i '3 {s/False/True/}' "$conf"
8+
fi
9+
510
# Configure ADMINS
611
if [ -n "${ADMIN_NAME}" ]; then
712
sed -i '6 {s/Your Name/'"${ADMIN_NAME}"'/}' "$conf"
@@ -65,19 +70,62 @@ if [ -n "${DB_ENGINE}" ]; then
6570
fi
6671

6772
# Configure TIME_ZONE
68-
if [ -n "${TIMEZONE}" ]; then
73+
if [ -n "${TIMEZONE}" ]; then
6974
sed -i '22 {s/America\/New_York/'"${TIMEZONE/\//\\/}"'/}' "$conf"
7075
fi
7176

77+
# Configure LANGUAGE_CODE
78+
if [ -n "${LANGUAGE_CODE}" ]; then
79+
sed -i '26 {s/en-us/'"${LANGUAGE_CODE}"'/}' "$conf"
80+
fi
81+
7282
# Configure SECRET_KEY
7383
if [ -z "$(grep "SECRET_KEY" "$conf" | cut -d " " -f 3 | tr -d "'")" ]; then
7484
if [ -n "${SECRET_KEY}" ]; then
75-
sed -i "s/SECRET_KEY = ''/SECRET_KEY = '"${SECRET_KEY}"'/g" "$conf"
85+
sed -i "29 {s/SECRET_KEY = ''/SECRET_KEY = '${SECRET_KEY}'/}" "$conf"
7686
else
7787
patchman-set-secret-key
7888
fi
7989
fi
8090

91+
# Configure MAX_MIRRORS
92+
if [ -n "${MAX_MIRRORS}" ]; then
93+
sed -i '36 {s/2/'"${MAX_MIRRORS}"'/}' "$conf"
94+
fi
95+
96+
# Configure MAX_MIRROR_FAILURES
97+
if [ -n "${MAX_MIRROR_FAILURES}" ]; then
98+
sed -i '39 {s/14/'"${MAX_MIRROR_FAILURES}"'/}' "$conf"
99+
fi
100+
101+
# Configure DAYS_WITHOUT_REPORT
102+
if [ -n "${DAYS_WITHOUT_REPORT}" ]; then
103+
sed -i '42 {s/14/'"${DAYS_WITHOUT_REPORT}"'/}' "$conf"
104+
fi
105+
106+
# Configure ERRATA_OS_UPDATES
107+
if [ -n "${ERRATA_OS_UPDATES}" ]; then
108+
errataOSUpdates="${ERRATA_OS_UPDATES// /}"
109+
sed -i '45 {s/\[.*\]/['"'${errataOSUpdates//,/\', \'}'"']/}' "$conf"
110+
fi
111+
112+
# Configure ALMA_RELEASES
113+
if [ -n "${ALMA_RELEASES}" ]; then
114+
sed -i '48 {s/\[.*\]/['"${ALMA_RELEASES}"']/}' "$conf"
115+
fi
116+
117+
# Configure DEBIAN_CODENAMES
118+
if [ -n "${DEBIAN_CODENAMES}" ]; then
119+
debianCodenames="${DEBIAN_CODENAMES// /}"
120+
sed -i '51 {s/\[.*\]/['"'${debianCodenames//,/\', \'}'"']/}' "$conf"
121+
fi
122+
123+
# Configure UBUNTU_CODENAMES
124+
if [ -n "${UBUNTU_CODENAMES}" ]; then
125+
ubuntuCodenames="${UBUNTU_CODENAMES// /}"
126+
sed -i '54 {s/\[.*\]/['"'${ubuntuCodenames//,/\', \'}'"']/}' "$conf"
127+
fi
128+
81129
# Configure CACHES
82130
if "${USE_CACHE}"; then
83131
if [ -n "${REDIS_HOST}" ]; then

0 commit comments

Comments
 (0)