diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b78e39895..e66405030 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -180,7 +180,9 @@ stages: condition: and(succeeded(), startsWith(variables['buildDescription'], 'macOS')) inputs: SourceFolder: $(Build.SourcesDirectory) - contents: install_service_macos + contents: | + install_service_macos + uninstall_jackett_macos targetFolder: $(Build.BinariesDirectory)/Jackett - task: CopyFiles@2 @@ -229,6 +231,7 @@ stages: chmod 755 JackettUpdater if [ -f install_service_systemd_mono.sh ]; then chmod 755 install_service_systemd_mono.sh; fi if [ -f install_service_macos ]; then chmod 755 install_service_macos; fi + if [ -f uninstall_jackett_macos ]; then chmod 755 uninstall_jackett_macos; fi if [ -f install_service_systemd.sh ]; then chmod 755 install_service_systemd.sh; fi if [ -f jackett_launcher.sh ]; then chmod 755 jackett_launcher.sh; fi diff --git a/src/Jackett.Common/Services/UpdateService.cs b/src/Jackett.Common/Services/UpdateService.cs index 8bca29160..6c30d8934 100644 --- a/src/Jackett.Common/Services/UpdateService.cs +++ b/src/Jackett.Common/Services/UpdateService.cs @@ -311,8 +311,8 @@ namespace Jackett.Common.Services if (variant == Variants.JackettVariant.CoreMacOs) { - var macosServicePath = tempDir + "/Jackett/install_service_macos"; - filePermissionService.MakeFileExecutable(macosServicePath); + filePermissionService.MakeFileExecutable(tempDir + "/Jackett/install_service_macos"); + filePermissionService.MakeFileExecutable(tempDir + "/Jackett/uninstall_jackett_macos"); } else if (variant == Variants.JackettVariant.Mono) { diff --git a/uninstall_jackett_macos b/uninstall_jackett_macos new file mode 100755 index 000000000..508508f7d --- /dev/null +++ b/uninstall_jackett_macos @@ -0,0 +1,59 @@ +#!/bin/zsh + +#Setting up colors +BOLDRED="$(printf '\033[1;31m')" +BOLDGREEN="$(printf '\033[1;32m')" +NC="$(printf '\033[0m')" # No Color + +# Move working directory to Jackett's +cd "$(dirname "$0")" + +# Check if we're running from Jackett's directory +if [ ! -f ./jackett ]; then +echo "${BOLDRED}ERROR${NC}: Couldn't locate ./jackett - Is the script in the right directory?" + exit 1 +fi +jackettdir="$(pwd)" + +echo "This script will uninstall Jackett. Do you want to proceed?" +select yn in "Yes" "No"; do + case $yn in + Yes ) break;; + No ) exit;; + esac +done + +echo "What should be removed? ${BOLDRED}WARNING${NC}: deleting binaries will remove all files located in ${jackettdir}. ${BOLDRED}WARNING${NC}: deleting config files prevents Jackett from being reinstalled." +select yn in "Only agent" "Only agent and binaries" "Agent, binaries and config"; do + case $yn in + "Only agent" ) delagent=true; break;; + "Only agent and binaries" ) delagent=true; delbin=true; break;; + "Agent, binaries and config" ) delagent=true; delbin=true; delconf=true; break;; + esac +done + +# Unload and delete agent +if [[ "$delagent" = true ]]; then + echo "Deleting agent..." + launchctl unload ~/Library/LaunchAgents/org.user.Jackett.plist + rm ~/Library/LaunchAgents/org.user.Jackett.plist +fi + +# Deleting the current folder +if [[ "$delbin" = true ]]; then + echo "Deleting binaries..." + rm -R $jackettdir +else + echo "Binaries have not been deleted from ${jackettdir}" +fi + +# Remove config files +if [[ "$delconf" = true ]]; then + echo "Deleting config files..." + rm -R ~/.config/Jackett/ +else + echo "Configuration files have been kept in ~/.config/Jackett/" +fi + +echo "${BOLDGREEN}Uninstall completed.${NC}" +