Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mrEckendonk/7792f6441d9e9d60128ffb72ee74cf8b to your computer and use it in GitHub Desktop.
Save mrEckendonk/7792f6441d9e9d60128ffb72ee74cf8b to your computer and use it in GitHub Desktop.
Bitninja Add Ssl Termination OLS
#!/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