|
||
---|---|---|
get-wildcard-cert-prosody.sh | ||
LICENSE | ||
README.md |
Prosxy-Cert-Updater
This script automates the process of synchronizing wildcard SSL certificates from a remote proxy server to a local Prosody server and restarting Prosody to apply the new certificates.
Prerequisites
Ensure the following requirements are met before running the script:
- SSH Access: The local machine must have SSH access to the proxy server.
- Root Privileges: The script must be executed with sufficient permissions to access and modify certificate files and restart the Prosody service.
- Bash Shell: The script is written for the Bash shell.
- Systemd: The script assumes Prosody is managed via
systemctl
.
Script Details
Variables
PROXY_SERVER
: The SSH connection string for the proxy server (e.g.,root@10.64.0.5
).REMOTE_CERT_PATH
: Path on the proxy server where the certificates are stored.LOCAL_CERT_PATH
: Local path where the certificates should be stored.DOMAIN
: Domain name for the certificates.
Functions
backup
Creates a backup of the current certificates in the backup
folder under the local certificate directory.
fetch_wildcard_certificate
Transfers the wildcard SSL certificates (fullchain.pem
and privkey.pem
) from the remote proxy server to the local certificate directory.
verify_certificates
Checks if the transferred certificate files exist in the local directory. Exits the script if any files are missing.
reload_prosody
Reloads the Prosody service to apply the new certificates.
Main Workflow
- Create a backup of the existing certificates.
- Fetch new certificates from the proxy server.
- Verify that the certificates were transferred successfully.
- Restart the Prosody service.
- Confirm the process is complete.
Usage
- Save the script to a file (e.g.,
sync_certificates.sh
). - Make the script executable:
chmod +x sync_certificates.sh
- Run the script as root or with
sudo
:sudo ./sync_certificates.sh
Logs
The script outputs progress logs for each step, including error messages if any step fails.
Troubleshooting
- Ensure the
scp
command is installed and properly configured on both the local and remote machines. - Verify the paths to the certificate files on the remote and local machines.
- Check the
journalctl
logs if Prosody fails to restart:journalctl -u prosody
License
This script is provided "as is" without warranty of any kind. Use it at your own risk. The Project is licensed under AGPL 3 or newer.
Note: Update the PROXY_SERVER
, REMOTE_CERT_PATH
, LOCAL_CERT_PATH
, and DOMAIN
variables in the script as needed to match your environment.