Last active
May 8, 2024 06:05
-
-
Save JonasGao/c5c4f32aaed3df637f146474fa9f82f9 to your computer and use it in GitHub Desktop.
Link pki for nginx from /etc/pki/nginx/xxxx/xxx.xx.xx/... to /etc/pki/nginx/xxx.xx.xx.xx
This file contains 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 | |
# Directory structure | |
# ─ /etc/pki/nginx | |
# ├─ 20231204_3m | |
# │ └─ example.com | |
# │ ├─ chain | |
# │ └─ key | |
# ├─ example.com.cer --> 20231204_3m/example.com/chain | |
# └─ private | |
# └─ example.com.key --> ../20231204_3m/example.com/key | |
PKI_HOME="/etc/pki/nginx" | |
PARENT="$1" | |
DOMAIN="$2" | |
[ -z "$PARENT" ] && echo "Missing Parameter 1: Pki base dir, some thing like 20240304_3m under ${PKI_HOME}" && exit 1 | |
[ -z "$DOMAIN" ] && echo "Missing Parameter 2: Domain key, like example.com" && exit 2 | |
PKI_DIR="${PARENT}/${DOMAIN}" | |
function link { | |
cd "$PKI_HOME" || exit 3 | |
echo "Into ${PKI_HOME}" | |
echo "Will link ${PKI_DIR}" | |
ln -vfns "${PKI_DIR}/chain" "${DOMAIN}.cer" | |
ln -vfns "../${PKI_DIR}/key" "private/${DOMAIN}.key" | |
echo "Finish linking cer and key file" | |
} | |
link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment