28 lines
824 B
Bash
Executable File
28 lines
824 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "Usage: $0 <domain>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
DOMAIN="$1"
|
|
LIVE_DIR="${PROJECT_DIR}/letsencrypt/live"
|
|
ACTIVE_DIR="${LIVE_DIR}/current"
|
|
|
|
latest_lineage="$(find "${LIVE_DIR}" -maxdepth 1 -mindepth 1 -type d -name "${DOMAIN}*" | sort | tail -n 1)"
|
|
|
|
if [[ -z "${latest_lineage}" ]]; then
|
|
echo "No certificate lineage found for ${DOMAIN}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${ACTIVE_DIR}"
|
|
latest_lineage_name="$(basename "${latest_lineage}")"
|
|
ln -sfn "../${latest_lineage_name}/fullchain.pem" "${ACTIVE_DIR}/fullchain.pem"
|
|
ln -sfn "../${latest_lineage_name}/privkey.pem" "${ACTIVE_DIR}/privkey.pem"
|
|
|
|
printf 'Active certificate path updated to %s\n' "${latest_lineage}"
|