#!/bin/bash

set -eEuo pipefail

target_directory="/etc/ngcp-config/shared-files/ssl/"

echo "Changing permissions for .key and .csr files in ${target_directory}"
find "${target_directory}" -type f \( -name "*.key" -o -name "*.csr" \) -exec chmod 640 {} \; -exec chown root:ssl-cert {} \;

echo "Changing permissions for .pem and .crt files in ${target_directory}"
find "${target_directory}" -type f \( -name "*.pem" -o -name "*.crt" \) -exec chmod 644 {} \; -exec chown root:ssl-cert {} \;

echo "Permissions have been updated for all .key, .pem, .csr, .crt files."
