From 90970f97e8695b62f7aa337bfd99d16a63059a4a Mon Sep 17 00:00:00 2001 From: William Wernert Date: Fri, 9 Jul 2021 15:44:27 -0400 Subject: [PATCH] Add function to check if files copied to local have been changed in default --- salt/common/tools/sbin/soup | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index bc95c5428..a59c63ffe 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -182,6 +182,33 @@ check_airgap() { fi } +check_local_mods() { + local salt_local=/opt/so/saltstack/local + + local_mod_arr=() + + while IFS= read -r -d '' local_file; do + stripped_path=${local_file#"$salt_local"} + default_file="${DEFAULT_SALT_DIR}${stripped_path}" + if [[ -f $default_file ]]; then + file_diff=$(diff "$default_file" "$local_file" ) + if [[ $(echo "$file_diff" | grep -c "^<") -gt 0 ]]; then + local_mod_arr+=( "$local_file" ) + fi + fi + done< <(find $salt_local -type f -print0) + + if [[ ${#local_mod_arr} -gt 0 ]]; then + echo "Potentially breaking changes found in the following files (check ${DEFAULT_SALT_DIR} for original copy):" + for file_str in "${local_mod_arr[@]}"; do + echo " $file_str" + done + echo "" + echo "To reference this list later, check $SOUP_LOG" + sleep 10 + fi +} + check_sudoers() { if grep -q "so-setup" /etc/sudoers; then echo "There is an entry for so-setup in the sudoers file, this can be safely deleted using \"visudo\"." @@ -956,6 +983,8 @@ main() { fi fi + check_local_mods + check_sudoers if [[ -n $lsl_msg ]]; then