NixOS deployment for LinuxLab
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p yq
#shellcheck shell=bash
if [[ ! -f ".sops.yaml" ]]; then echo "Error: .sops.yaml file not found in $(pwd)" echo "Please ensure you are running this script from the repository root directory." exit 1 fi
# Schritt 1: Alle Regex aus der .sops.yaml-Datei extrahieren regex_list=$(yq -r '.creation_rules[].path_regex' .sops.yaml)
# Schritt 2: Alle Dateien finden, die zu den Regex passen matching_files=() for regex in $regex_list; do # Entferne eventuelle ^ und $ Zeichen, damit die Regex auch in find funktionieren simplified_regex=$(echo "$regex" | sed 's/^\^//;s/\$$//') found_files=$(find . -type f | grep -E "$simplified_regex")
# Füge die gefundenen Dateien zur Liste hinzu for file in $found_files; do matching_files+=("$file") done done
# Deduplizieren der Dateiliste mit mapfile mapfile -t unique_files < <(printf "%s\n" "${matching_files[@]}" | sort -u)
# Schritt 3: sops updatekeys für jede Datei ausführen for file in "${unique_files[@]}"; do echo "Updating keys for: $file" sops updatekeys -y "$file" done
echo "Finished updating keys."
|