Implement email_tunnel service and installation scripts for Proton Bridge integration
This commit is contained in:
parent
c10b9e634d
commit
28a1fbe59a
5 changed files with 496 additions and 2 deletions
113
uninstall_email_tunnel.sh
Normal file
113
uninstall_email_tunnel.sh
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Uninstallation script for email_tunnel systemd service
|
||||
|
||||
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 "email_tunnel 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
|
||||
|
||||
SERVICE_NAME="email_tunnel.service"
|
||||
|
||||
# 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 "$SERVICE_NAME"; then
|
||||
echo -e "${YELLOW}$SERVICE_NAME is not installed${NC}"
|
||||
echo "Nothing to uninstall."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Confirm uninstallation
|
||||
echo -e "${YELLOW}This will remove the $SERVICE_NAME systemd service.${NC}"
|
||||
echo "Your 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 service if running
|
||||
echo "Stopping $SERVICE_NAME..."
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
sudo systemctl stop "$SERVICE_NAME"
|
||||
echo -e "${GREEN}✓ Service stopped${NC}"
|
||||
else
|
||||
echo "Service is not running"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Disable the service
|
||||
echo "Disabling $SERVICE_NAME..."
|
||||
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
|
||||
sudo systemctl disable "$SERVICE_NAME"
|
||||
echo -e "${GREEN}✓ Service disabled${NC}"
|
||||
else
|
||||
echo "Service was not enabled"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Remove service file
|
||||
echo "Removing service file..."
|
||||
if [ -f /etc/systemd/system/$SERVICE_NAME ]; then
|
||||
sudo rm /etc/systemd/system/$SERVICE_NAME
|
||||
echo -e "${GREEN}✓ Removed $SERVICE_NAME${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}No service file found to remove${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 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 "$SERVICE_NAME" 2>/dev/null || true
|
||||
|
||||
# Verify uninstallation
|
||||
echo "Verifying uninstallation..."
|
||||
if systemctl list-unit-files | grep -q "email_tunnel"; then
|
||||
echo -e "${RED}Warning: Some email_tunnel units still found${NC}"
|
||||
systemctl list-unit-files | grep email_tunnel
|
||||
else
|
||||
echo -e "${GREEN}✓ Service unit removed${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "======================================"
|
||||
echo "Uninstallation Complete!"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
echo -e "${GREEN}The email_tunnel systemd service has been removed.${NC}"
|
||||
echo ""
|
||||
echo "Your files are still available:"
|
||||
echo " - email_tunnel.py (relay script)"
|
||||
echo " - .env (configuration)"
|
||||
echo " - email_tunnel.service (service template)"
|
||||
echo ""
|
||||
echo "You can reinstall with: ./install_email_tunnel.sh"
|
||||
Loading…
Add table
Add a link
Reference in a new issue