From e7617c3002a6798e3664624804823bf8fb7480b3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 25 Dec 2023 07:13:36 +0100 Subject: [PATCH] Update ha_entrypoint_modif.sh --- .templates/ha_entrypoint_modif.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.templates/ha_entrypoint_modif.sh b/.templates/ha_entrypoint_modif.sh index 37ee128d1..accc1e6ba 100755 --- a/.templates/ha_entrypoint_modif.sh +++ b/.templates/ha_entrypoint_modif.sh @@ -8,9 +8,18 @@ set -e # Ensure lf ########### -for folders in /default /defaults /etc; do - if [ -d "$folders" ]; then - find "$folders" -type f -print0 | xargs -0 dos2unix +# This script recursively applies dos2unix to all files in /etc +# It skips hidden files, binary files, and files without crlf eol + +# Find all non-hidden files in /etc that contain crlf eol +FILES=$(find /etc -type f -not -path '*/\.*' -exec grep -Il $'\r' {} \;) + +# Loop through each file and apply dos2unix +for f in $FILES; do + # Check if the file is a text file + if file "$f" | grep -q text; then + # Apply dos2unix and keep the original timestamp + dos2unix -k "$f" fi done