Skip to content

Commit

Permalink
fix: use sudo_if_available for normalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhodgkiss authored Sep 5, 2024
1 parent f53c589 commit a699268
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/config-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ function main {
local file="$1"
local text="$2"

sed -i "s#/tmp/$text/\(.*\)#/tmp/\1#g" "$file"
sudo_if_available sed -i "s#/tmp/$text/\(.*\)#/tmp/\1#g" "$file"
}

function normalise_files_in_folder() {
local folder="$1"
local text="$2"

# Find all files in the folder and its subfolders and loop through them
find "$folder" -type f -print0 | while IFS= read -r -d '' file; do
sudo_if_available find "$folder" -type f -print0 | while IFS= read -r -d '' file; do
normalise_file_text "$file" "$text"
done
}
Expand All @@ -278,7 +278,7 @@ function main {
redact_config_dir "$target_environment_path"
encrypt_config_dir "$target_environment_path"
generate_config "$target_environment_path" "$target_dir"
sudo_if_available normalise_files_in_folder "$target_dir" "target-kayobe-env"
normalise_files_in_folder "$target_dir" "target-kayobe-env"
}

function generate_source_config {
Expand All @@ -293,7 +293,7 @@ function main {
redact_config_dir "$source_environment_path" "$target_kayobe_config_dir"
encrypt_config_dir "$source_environment_path"
generate_config "$source_environment_path" "$source_dir"
sudo_if_available normalise_files_in_folder "$source_dir" "source-kayobe-env"
normalise_files_in_folder "$source_dir" "source-kayobe-env"
}

generate_target_config $1 >/dev/null 2>&1 &
Expand Down

0 comments on commit a699268

Please sign in to comment.