Created
April 4, 2025 12:33
-
-
Save mrEckendonk/7792f6441d9e9d60128ffb72ee74cf8b to your computer and use it in GitHub Desktop.
Bitninja Add Ssl Termination OLS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Configuration | |
SSL_DIR="/var/local/enhance/website_ssl" | |
BITNINJA_CMD="bitninjacli --module=SslTerminating --add-cert" | |
# Find and process domains | |
find "${SSL_DIR}" -maxdepth 1 -type f -name "*.cert" | while read -r cert_file; do | |
# Extract domain name from certificate filename | |
domain=$(basename "${cert_file}" .cert) | |
# Set key file path | |
key_file="${SSL_DIR}/${domain}.key" | |
# Verify both files exist | |
if [[ -f "${key_file}" ]]; then | |
echo "Processing domain: ${domain}" | |
# Execute the BitNinja command | |
output=$(${BITNINJA_CMD} --domain="mail.${domain}" \ | |
--certFile="${cert_file}" \ | |
--keyFile="${key_file}" 2>&1) | |
# Print results | |
echo "----------------------------------------" | |
echo "Domain: mail.${domain}" | |
echo "Command output:" | |
echo "${output}" | |
echo "----------------------------------------" | |
else | |
echo "Skipping ${domain} - Key file not found: ${key_file}" | |
fi | |
done | |
echo "Processing complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment