Forked from DrJume/delete-traefik-acme-certificates.sh
Created
November 26, 2024 13:40
-
-
Save positiveque/080b275d7ec37e220c66c9e4d879d48f to your computer and use it in GitHub Desktop.
Revisions
-
DrJume revised this gist
Jun 22, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
Empty file. -
DrJume revised this gist
Jun 22, 2021 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,18 +8,18 @@ ACME_FILE="acme.json" SELECTED_DOMAINS=$(jq -r '.letsencrypt.Certificates[].domain.main' "$ACME_FILE" | fzf -m --height '40%' --reverse --border) if [[ -z "$SELECTED_DOMAINS" ]]; then echo "Nothing changed." exit fi cp --force -p --backup=numbered "$ACME_FILE" "$ACME_FILE" cp -p "$ACME_FILE" "${ACME_FILE}.new" for domain in $SELECTED_DOMAINS; do echo "Deleting certificate for '$domain'" # get sponge by installing the moreutils package jq "del(.letsencrypt.Certificates[] | select(.domain.main == \"$domain\"))" "${ACME_FILE}.new" | sponge "${ACME_FILE}.new" done cp --attributes-only --preserve=mode,ownership "$ACME_FILE" "${ACME_FILE}.new" -
DrJume created this gist
Jun 22, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/bash # tested with traefik v2.4.8 ACME_FILE="acme.json" # get jq from https://stedolan.github.io/jq/ SELECTED_DOMAINS=$(jq -r '.letsencrypt.Certificates[].domain.main' "$ACME_FILE" | fzf -m --height '40%' --reverse --border) if [[ -z "$SELECTED_DOMAINS" ]]; then echo "Nothing changed." exit fi cp --force -p --backup=numbered "$ACME_FILE" "$ACME_FILE" cp -p "$ACME_FILE" "${ACME_FILE}.new" for domain in $SELECTED_DOMAINS; do echo "Deleting certificate for '$domain'" # get sponge by installing the moreutils package jq "del(.letsencrypt.Certificates[] | select(.domain.main == \"$domain\"))" "${ACME_FILE}.new" | sponge "${ACME_FILE}.new" done cp --attributes-only --preserve=mode,ownership "$ACME_FILE" "${ACME_FILE}.new" mv "${ACME_FILE}.new" "$ACME_FILE"