Files
my-cd-webhook/install/uninstall.sh
T
fisher 3a6fafb5c7 Generic host/repo/branch-aware CD on adnanh/webhook
Replaces the per-project deploy scripts and self-contained webhook
receivers with one manifest-driven implementation that lives outside the
application repositories and can be updated independently of them.

First targets: domaindingo test and prod on s5.
2026-08-23 07:49:52 +00:00

37 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Remove the CD webhook receiver from this host.
#
# Stops and deletes the user service. Deliberately leaves the secrets file and
# the deploy logs in place -- removing a receiver is not a reason to destroy
# credentials or the record of what was deployed. Pass --purge to remove them.
set -Eeuo pipefail
readonly CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/cd-webhook"
readonly STATE_DIR="${XDG_STATE_HOME:-${HOME}/.local/state}/cd-webhook"
readonly SYSTEMD_DIR="${HOME}/.config/systemd/user"
readonly UNIT_NAME="cd-webhook.service"
PURGE=0
[[ "${1:-}" == "--purge" ]] && PURGE=1
echo "Stopping ${UNIT_NAME} ..."
systemctl --user disable --now "$UNIT_NAME" 2>/dev/null || true
rm -f "${SYSTEMD_DIR}/${UNIT_NAME}"
systemctl --user daemon-reload
# The rendered hooks file holds the webhook secrets, so it goes regardless; it
# is regenerated from targets.json plus secrets.env on the next install.
rm -f "${CONFIG_DIR}/hooks.json"
if [[ $PURGE -eq 1 ]]; then
echo "Purging secrets and deploy logs ..."
rm -rf "$CONFIG_DIR" "$STATE_DIR"
else
echo "Kept ${CONFIG_DIR}/secrets.env and deploy logs in ${STATE_DIR}"
echo " (re-run with --purge to remove them too)"
fi
echo "Done."