50 lines
1.8 KiB
Bash
Executable File
50 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# To be run by user mkt. DANGEROUS: disables and removes the EspoCRM pod,
|
|
# all containers, the generated systemd units AND ALL DATA (DB + files).
|
|
# Requires an exact confirmation phrase.
|
|
|
|
# Environment variables
|
|
POD_NAME='espocrm_pod'
|
|
DB_CTR='mariadb_ctr'
|
|
WEB_CTR='espocrm_ctr'
|
|
DAEMON_CTR='espocrm_daemon_ctr'
|
|
BIND_DIR="$HOME/.local/share/$POD_NAME"
|
|
USER_SYSTEMD_DIR="$HOME/.config/systemd/user"
|
|
|
|
# Extra safety prompt
|
|
read -r -p "WARNING: this deletes the pod, containers, and ALL data under $BIND_DIR. To confirm, type 'RESET espocrm_pod': " C
|
|
[ "$C" = "RESET espocrm_pod" ] || { echo "Aborted."; exit 1; }
|
|
|
|
# Disable & stop the systemd-managed services
|
|
systemctl --user disable --now "container-${DAEMON_CTR}.service"
|
|
echo "Disabled container-${DAEMON_CTR}.service (rc=$?)"
|
|
systemctl --user disable --now "container-${WEB_CTR}.service"
|
|
echo "Disabled container-${WEB_CTR}.service (rc=$?)"
|
|
systemctl --user disable --now "container-${DB_CTR}.service"
|
|
echo "Disabled container-${DB_CTR}.service (rc=$?)"
|
|
systemctl --user disable --now "pod-${POD_NAME}.service"
|
|
echo "Disabled pod-${POD_NAME}.service (rc=$?)"
|
|
|
|
# Remove the live pod and containers (if any)
|
|
podman pod rm -f --ignore "$POD_NAME"
|
|
echo "Removed pod $POD_NAME (rc=$?)"
|
|
|
|
# Delete the generated unit files
|
|
rm -f \
|
|
"$USER_SYSTEMD_DIR/pod-${POD_NAME}.service" \
|
|
"$USER_SYSTEMD_DIR/container-${DB_CTR}.service" \
|
|
"$USER_SYSTEMD_DIR/container-${WEB_CTR}.service" \
|
|
"$USER_SYSTEMD_DIR/container-${DAEMON_CTR}.service"
|
|
echo "Removed generated systemd unit files (rc=$?)"
|
|
|
|
systemctl --user daemon-reload
|
|
echo "Reloaded systemd --user daemon (rc=$?)"
|
|
|
|
# Delete all data (point of no return)
|
|
rm -rf "$BIND_DIR"
|
|
echo "Deleted data directory $BIND_DIR (rc=$?)"
|
|
|
|
echo ""
|
|
echo "Reset complete. Run create_pod_espocrm.sh again to reinstall EspoCRM."
|