#!/bin/sh
#
# Cleans up after the package is removed: includes removing symlinks, stopping any optional service (if the script failed earlier), and cleaning up configuration files (if the user chooses to purge).

set -e

case "$1" in
    remove)
        # Remove the symlink created in postinst
        rm -f /usr/bin/CuttingBoard
        
        # Remove the systemd service file
#        rm -f /etc/systemd/system/CuttingBoard.service
#        systemctl daemon-reload
        ;;
    
    purge)
        # If purging, remove the entire application directory and config
        rm -rf /opt/CuttingBoard
#        rm -f /etc/systemd/system/CuttingBoard.service
#        systemctl daemon-reload
        ;;
    
    failed-upgrade|abort-install|abort-upgrade|disappear)
        # If the upgrade failed, we might need to restart the old version
        # For simplicity, we just reload systemd
#        systemctl daemon-reload
        ;;
esac

exit 0