From 338ca433289f2f19fdc202c7570f2605aad4a962 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 17 Apr 2026 16:21:51 +0200 Subject: [PATCH] fix environment file to not fill with duplicate values with restart container --- bash-config/.bashrc | 2 +- entrypoint-script/entrypoint.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bash-config/.bashrc b/bash-config/.bashrc index a96e228..09bfc94 100644 --- a/bash-config/.bashrc +++ b/bash-config/.bashrc @@ -1,4 +1,4 @@ -if [ ! -z $(cat /etc/environment | grep "USE_TMUX_SHELL") ] && [[ -t 0 ]] && [ -z "$TMUX" ]; then +if grep -q "USE_TMUX_SHELL" /etc/environment && [[ -t 0 ]] && [ -z "$TMUX" ]; then tmux attach || tmux new-session exit fi diff --git a/entrypoint-script/entrypoint.sh b/entrypoint-script/entrypoint.sh index 08fce11..db5af04 100644 --- a/entrypoint-script/entrypoint.sh +++ b/entrypoint-script/entrypoint.sh @@ -9,12 +9,12 @@ USER_GROUP="$USER" function set_environment_variables_if_not_empty { # Set Tmux Shell for .bashrc to load tmux and attach session if exists else create new session if [ -n "${USE_TMUX_SHELL:-}" ]; then - echo "USE_TMUX_SHELL=$USE_TMUX_SHELL" >> /etc/environment + grep -q "^USE_TMUX_SHELL=" /etc/environment || echo "USE_TMUX_SHELL=$USE_TMUX_SHELL" >> /etc/environment fi # Set Server Timezone if [ -n "${TZ:-}" ]; then - echo "TZ=$TZ" >> /etc/environment + grep -q "^TZ=" /etc/environment || echo "TZ=$TZ" >> /etc/environment ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime fi }