First Commit
This commit is contained in:
parent
51ca26f5ce
commit
7d1ba02c42
8 changed files with 1106 additions and 61 deletions
149
uninstall.sh
Executable file
149
uninstall.sh
Executable file
|
|
@ -0,0 +1,149 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Uninstallation script for Porkbun Dynamic DNS systemd service
|
||||
#
|
||||
# This script will:
|
||||
# 1. Stop and disable the timer
|
||||
# 2. Remove service files from systemd
|
||||
# 3. Reload systemd daemon
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo "======================================"
|
||||
echo "Porkbun DDNS Service Uninstaller"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo -e "${RED}Error: Do not run this script as root or with sudo${NC}"
|
||||
echo "The script will request sudo privileges when needed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if systemctl is available
|
||||
if ! command -v systemctl &> /dev/null; then
|
||||
echo -e "${RED}Error: systemctl not found${NC}"
|
||||
echo "This script requires systemd."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if service is installed
|
||||
if ! systemctl list-unit-files | grep -q "porkbun-ddns.timer"; then
|
||||
echo -e "${YELLOW}porkbun-ddns service is not installed${NC}"
|
||||
echo "Nothing to uninstall."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Confirm uninstallation
|
||||
echo -e "${YELLOW}This will remove the porkbun-ddns systemd service.${NC}"
|
||||
echo "Your DNS update script and configuration will NOT be deleted."
|
||||
echo ""
|
||||
read -p "Continue with uninstallation? (y/N) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Uninstallation cancelled."
|
||||
exit 0
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Stop the timer if running
|
||||
echo "Stopping porkbun-ddns.timer..."
|
||||
if systemctl is-active --quiet porkbun-ddns.timer; then
|
||||
sudo systemctl stop porkbun-ddns.timer
|
||||
echo -e "${GREEN}✓ Timer stopped${NC}"
|
||||
else
|
||||
echo "Timer is not running"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Stop the service if running
|
||||
echo "Stopping porkbun-ddns.service..."
|
||||
if systemctl is-active --quiet porkbun-ddns.service; then
|
||||
sudo systemctl stop porkbun-ddns.service
|
||||
echo -e "${GREEN}✓ Service stopped${NC}"
|
||||
else
|
||||
echo "Service is not running"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Disable the timer
|
||||
echo "Disabling porkbun-ddns.timer..."
|
||||
if systemctl is-enabled --quiet porkbun-ddns.timer; then
|
||||
sudo systemctl disable porkbun-ddns.timer
|
||||
echo -e "${GREEN}✓ Timer disabled${NC}"
|
||||
else
|
||||
echo "Timer was not enabled"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Remove service files
|
||||
echo "Removing service files..."
|
||||
REMOVED=0
|
||||
|
||||
if [ -f /etc/systemd/system/porkbun-ddns.service ]; then
|
||||
sudo rm /etc/systemd/system/porkbun-ddns.service
|
||||
echo -e "${GREEN}✓ Removed porkbun-ddns.service${NC}"
|
||||
((REMOVED++))
|
||||
fi
|
||||
|
||||
if [ -f /etc/systemd/system/porkbun-ddns.timer ]; then
|
||||
sudo rm /etc/systemd/system/porkbun-ddns.timer
|
||||
echo -e "${GREEN}✓ Removed porkbun-ddns.timer${NC}"
|
||||
((REMOVED++))
|
||||
fi
|
||||
|
||||
if [ $REMOVED -eq 0 ]; then
|
||||
echo -e "${YELLOW}No service files found to remove${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Remove override directory if it exists
|
||||
if [ -d /etc/systemd/system/porkbun-ddns.service.d ]; then
|
||||
sudo rm -rf /etc/systemd/system/porkbun-ddns.service.d
|
||||
echo -e "${GREEN}✓ Removed service override directory${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Reload systemd
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
echo -e "${GREEN}✓ Systemd reloaded${NC}"
|
||||
echo ""
|
||||
|
||||
# Reset failed state if exists
|
||||
sudo systemctl reset-failed porkbun-ddns.service 2>/dev/null || true
|
||||
sudo systemctl reset-failed porkbun-ddns.timer 2>/dev/null || true
|
||||
|
||||
# Verify uninstallation
|
||||
echo "Verifying uninstallation..."
|
||||
if systemctl list-unit-files | grep -q "porkbun-ddns"; then
|
||||
echo -e "${RED}Warning: Some porkbun-ddns units still found${NC}"
|
||||
systemctl list-unit-files | grep porkbun-ddns
|
||||
else
|
||||
echo -e "${GREEN}✓ All service units removed${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "======================================"
|
||||
echo "Uninstallation Complete!"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
echo -e "${GREEN}The porkbun-ddns systemd service has been removed.${NC}"
|
||||
echo ""
|
||||
echo "Your files are still available:"
|
||||
echo " - updateDNS.sh (DNS update script)"
|
||||
echo " - .env (configuration)"
|
||||
echo " - porkbun-ddns.service (service template)"
|
||||
echo " - porkbun-ddns.timer (timer template)"
|
||||
echo ""
|
||||
echo "You can:"
|
||||
echo " - Reinstall with: ./install.sh"
|
||||
echo " - Run manually with: ./updateDNS.sh"
|
||||
echo " - Delete all files if no longer needed"
|
||||
Loading…
Add table
Add a link
Reference in a new issue