generated from onedr0p/cluster-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98ad923
commit 1b8cd08
Showing
2 changed files
with
19 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
#!/bin/zsh | ||
export TLS_CERT="jory.dev-tls" | ||
export TLS_NAMESPACE="cert-manager" | ||
export TLS_NAMESPACE="network" | ||
CERT_DIR=/tmp/cert | ||
CERT_TMP=$CERT_DIR/tmp | ||
CERT_JSON=$CERT_DIR/certificate/certificate-tls.json | ||
CLUSTER=${1:-main} | ||
CLUSTER=${1:-utility} | ||
DESTINATION=${2:-caddy} | ||
|
||
# Set default values based on DESTINATION | ||
if [[ "$DESTINATION" == "caddy" ]]; then | ||
SERVER="root@voyager" | ||
PATH="/mnt/cache/docker/CaddyV2/data" | ||
elif [[ "$DESTINATION" == "unifi" ]]; then | ||
SERVER="[email protected]" | ||
PATH="/data/unifi-core/config" | ||
else | ||
echo "Unknown DESTINATION: $DESTINATION" | ||
exit 1 | ||
fi | ||
|
||
mkdir -p $CERT_DIR/certificate/ | ||
|
||
|
@@ -24,9 +37,11 @@ if [[ "$DIFF" != "" ]]; then | |
kubectl --context $CLUSTER get secret $TLS_CERT -n $TLS_NAMESPACE -ojsonpath="{.data}" | jq '.["tls.key"]' | sed -e s/\"//g | base64 -d > $CERT_DIR/certificate.key | ||
cp $CERT_TMP $CERT_JSON | ||
cat $CERT_DIR/certificate.crt $CERT_DIR/certificate.key > $CERT_DIR/certificate.pem | ||
scp $CERT_DIR/certificate.crt [email protected]:/data/unifi-core/config/unifi-core.crt | ||
scp $CERT_DIR/certificate.key [email protected]:/data/unifi-core/config/unifi-core.key | ||
scp $CERT_DIR/certificate.crt $SERVER:$PATH | ||
scp $CERT_DIR/certificate.key $SERVER:$PATH | ||
echo "Certificate copied to $DESTINATION" | ||
else | ||
echo "No change in certificates" | ||
fi | ||
|
||
rm $CERT_TMP |