Skip to content

Commit 98cf9e6

Browse files
authored
Merge pull request #63 from jfroment/dev
v2.2.1
2 parents 5623c64 + d358ee6 commit 98cf9e6

File tree

5 files changed

+74
-11
lines changed

5 files changed

+74
-11
lines changed

.env.custom.sample

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ CALIBRE_CALIBRE_PASSWORD=changeme
3333
# Flood Password for Deluge RPC daemon
3434
FLOOD_FLOOD_PASSWORD=changeme
3535

36-
# Please ensure you encrypt your password first using this command:
37-
# docker run -it --rm --entrypoint htpasswd ubuntu/apache2 -nbB admin your_password | cut -d ":" -f 2 | sed -e s/\\$/\\$\\$/g
38-
PORTAINER_PORTAINER_ADMIN_PASSWORD=changeme
39-
4036
# Nextcloud
4137
NEXTCLOUD_NEXTCLOUD_ADMIN_USER=admin # you can change it
4238
NEXTCLOUD_NEXTCLOUD_ADMIN_PASSWORD=changeme

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
# v2.2.1 (The little Flame 🔥)
2+
3+
> Bugfix release due to errors on some services after v2.2 release.
4+
5+
## Bugfixes and improvements ⚙️
6+
7+
* [**Portainer**] Remove ``admin`` password auto-configuration. Password is now set on first installation via GUI.
8+
* [**Flood** | **MariaDB** | **Calibre**] Fix variables not taken into account (fix #61)
9+
* Services which used a ``command`` with environment variables were broken since v2.2 release because app-specific env files are injected with env_file directive in Docker Compose, but some services cannot read from environment variables in their command.
10+
111
# v2.2 (The Flame 🔥)
212

313
## What's new?
414

515
### New services 💫
616

7-
* ``qBittorrent``: [Torrends downloader](https://github.com/qbittorrent/qBittorrent)
17+
* ``qBittorrent``: [Torrents downloader](https://github.com/qbittorrent/qBittorrent)
818
* Use of ``hotio`` build ([documentation here](https://hotio.dev/containers/qbittorrent/)) with VueTorrent and native VPN support (for those who want to avoid gluetun configuration)
919
* Use of qBittorrent is recommended over Deluge as the project is more active and its alternative UI setup is easier (no separate container).
1020
* ``Filebrowser``: [Lightweight filebrowser](https://github.com/filebrowser/filebrowser)

run-seedbox.sh

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ done
2828

2929
cleanup_on_exit() {
3030
rm -f rules.props *-vpn.props *-envfile.props config.json
31+
[[ -d env ]] && rm -f env/*.tmp
3132
}
3233
trap cleanup_on_exit EXIT
3334

@@ -255,6 +256,8 @@ rm -f services/generated/*-vpn.yaml
255256

256257
ALL_SERVICES="-f docker-compose.yaml"
257258

259+
GLOBAL_ENV_FILE=".env"
260+
258261
# Parse the config.yaml master configuration file
259262
for json in $(yq eval -o json config.yaml | jq -c ".services[]"); do
260263
name=$(echo $json | jq -r .name)
@@ -304,6 +307,63 @@ for json in $(yq eval -o json config.yaml | jq -c ".services[]"); do
304307
fi
305308
fi
306309

310+
###### For services which have "command" field with environment variables ######
311+
var_in_cmd_detected="0"
312+
if [[ $(yq ".services.${name}.command[]" services/${file} | { grep "\\$.*\}" || true; } | wc -l) -gt 0 ]]; then
313+
var_in_cmd_detected="1"
314+
echo-debug "[$0] Service ${name} has a command with environment variables..."
315+
# Extract variable names to test them
316+
yq ".services.${name}.command[]" services/${file} | { grep "\\$.*\}" || true; } | sed -n -e 's/.*${\(\w\+\)}.*/\1/p' > env/${name}-cmd.env.1.tmp
317+
(
318+
# Check if these variables are defined in generated .env files (global or custom)
319+
set -a
320+
source ./env/${name}.env
321+
source .env
322+
set +a
323+
while read p; do
324+
# If the command references a variable which is not known, throw an error
325+
if [[ -z ${!p+x} ]]; then
326+
echo "ERROR. Variable \"$p\" is referenced in \"command\" for service ${name} (file $file) but this variable is not defined in .env (or in .env.custom with prefix \"${name^^}_\"). Please correct it or add a variable which will be used."
327+
exit 1
328+
fi
329+
done < env/${name}-cmd.env.1.tmp
330+
331+
# Does not work for now because of how docker handles merges for arrays. Original values with variables stay.
332+
# Disabled for now
333+
if [[ "0" == "1" ]]; then
334+
# Extract command block from original service yaml file
335+
yq ".services.${name}.command[]" services/${file} > env/${name}-cmd.env.2.tmp
336+
# Envsubst this file
337+
envsubst < env/${name}-cmd.env.2.tmp > env/${name}-cmd.env.3.tmp
338+
# Convert this file to a props file, used to source a new proper YAML file
339+
i=0
340+
while read line; do
341+
echo "services.${name}.command.$i: $line" >> env/${name}-cmd.env.4.tmp
342+
i=$((i+1))
343+
done < env/${name}-cmd.env.3.tmp
344+
# Generate a proper override file with substituted variables
345+
yq -p=props env/${name}-cmd.env.4.tmp -o yaml > services/generated/${name}-command.yaml
346+
fi
347+
)
348+
rm -f env/*.tmp
349+
# echo-debug "[$0] Adding override file for service ${name} / command with subsituted environment variables..."
350+
# ALL_SERVICES="${ALL_SERVICES} -f services/generated/${name}-command.yaml"
351+
fi
352+
353+
# Handle case for command in a single line, not in array
354+
if [[ $(yq ".services.${name}.command" services/${file} | { grep "\\$.*\}" || true; } | wc -l) -gt 0 ]]; then
355+
var_in_cmd_detected="1"
356+
fi
357+
358+
# Workaround for now
359+
if [[ "${var_in_cmd_detected}" == "1" ]]; then
360+
cat ${GLOBAL_ENV_FILE} ./env/${name}.env >> .env.concat.tmp
361+
rm -f .env.concat
362+
mv .env.concat.tmp .env.concat
363+
export GLOBAL_ENV_FILE=".env.concat"
364+
var_in_cmd_detected="0"
365+
fi
366+
307367
###################################### TRAEFIK RULES ######################################
308368

309369
# Skip this part for services which have Traefik rules disabled in config
@@ -397,8 +457,9 @@ if [[ "${SKIP_PULL}" != "1" ]]; then
397457
fi
398458

399459
echo "[$0] ***** Recreating containers if required... *****"
400-
${DOCKER_COMPOSE_BINARY} ${ALL_SERVICES} up -d --remove-orphans
460+
${DOCKER_COMPOSE_BINARY} --env-file ${GLOBAL_ENV_FILE} ${ALL_SERVICES} up -d --remove-orphans
401461
echo "[$0] ***** Done updating containers *****"
462+
rm -f .env.concat
402463

403464
echo "[$0] ***** Clean unused images and volumes... *****"
404465
docker image prune -af

services/mariadb.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ services:
66
user: ${PUID}:${PGID}
77
restart: always
88
environment:
9-
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
10-
- MYSQL_DATABASE=${MYSQL_DATABASE}
11-
- MYSQL_USER=${MYSQL_USER}
12-
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
139
- TZ=${TZ}
1410
volumes:
1511
- nextclouddb:/var/lib/mysql

services/portainer.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ services:
55
restart: always
66
volumes:
77
- /var/run/docker.sock:/var/run/docker.sock
8-
command: --admin-password ${PORTAINER_ADMIN_PASSWORD} --host=unix:///var/run/docker.sock
8+
command: --host=unix:///var/run/docker.sock

0 commit comments

Comments
 (0)