From a2ae2d338439c035afbdf821bebc4dfde09ee8b2 Mon Sep 17 00:00:00 2001 From: thebluepotato Date: Fri, 8 Sep 2017 17:12:47 +0200 Subject: [PATCH] Enhance the service installation on MacOS (#1793) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make the script self-executing * Update script with colors Since it’s self-executing, at least the output is more visible * Changes to README * Update Jackett.Console.csproj * Clarify README --- README.md | 3 ++- src/Jackett.Console/Jackett.Console.csproj | 2 +- ...ll_service_macos.sh => install_service_macos} | 16 +++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) rename src/Jackett.Console/{install_service_macos.sh => install_service_macos} (72%) diff --git a/README.md b/README.md index 56c840441..05fec2496 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,8 @@ Install [Mono 4](http://www.mono-project.com/download/#download-mac) or better ( ### Install as service 1. Download and extract the latest `Jackett.Binaries.Mono.tar.gz` release from the [releases page](https://github.com/Jackett/Jackett/releases). -2. In Terminal, run the install script from the extracted directory using `./install_service_macos.sh` +2. Open the extracted folder and double-click on `install_service_macos`. +3. If the installation was a success, you can close the Terminal window. The service will start on each logon. You can always stop it by running `launchctl unload ~/Library/LaunchAgents/org.user.Jackett.plist` from Terminal. You can start it again it using `launchctl load ~/Library/LaunchAgents/org.user.Jackett.plist`. Logs are stored as usual under `~/.config/Jackett/log.txt`. diff --git a/src/Jackett.Console/Jackett.Console.csproj b/src/Jackett.Console/Jackett.Console.csproj index 8af4a4af1..4355d0799 100644 --- a/src/Jackett.Console/Jackett.Console.csproj +++ b/src/Jackett.Console/Jackett.Console.csproj @@ -153,7 +153,7 @@ - + PreserveNewest diff --git a/src/Jackett.Console/install_service_macos.sh b/src/Jackett.Console/install_service_macos similarity index 72% rename from src/Jackett.Console/install_service_macos.sh rename to src/Jackett.Console/install_service_macos index bc0913284..b0a6572ac 100755 --- a/src/Jackett.Console/install_service_macos.sh +++ b/src/Jackett.Console/install_service_macos @@ -1,5 +1,10 @@ #!/bin/bash +#Setting up colors +BOLDRED="$(printf '\033[1;31m')" +BOLDGREEN="$(printf '\033[1;32m')" +NC="$(printf '\033[0m')" # No Color + # Stop and unload the service if it's running launchctl remove org.user.Jackett @@ -8,18 +13,18 @@ cd "$(dirname "$0")" # Check if we're running from Jackett's directory if [ ! -f ./JackettConsole.exe ]; then - echo "Couldn't locate JackettConsole.exe. Is the script in the right directory?" +echo "${BOLDRED}ERROR${NC}: Couldn't locate JackettConsole.exe. Is the script in the right directory?" exit 1 fi jackettdir="$(pwd)" # Check if mono is installed -command -v mono >/dev/null 2>&1 || { echo >&2 "Jackett requires Mono but it's not installed. Aborting."; exit 1; } +command -v mono >/dev/null 2>&1 || { echo >&2 "${BOLDRED}ERROR${NC}: Jackett requires Mono but it's not installed. Aborting."; exit 1; } monodir="$(dirname $(command -v mono))" # Check that no other service called Jackett is already running if [[ $(launchctl list | grep org.user.Jackett) ]]; then - echo "Jackett already seems to be running as a service. Please stop it before running this script again." + echo "${BOLDRED}ERROR${NC}: Jackett already seems to be running as a service. Please stop it before running this script again." exit 1 fi @@ -59,12 +64,13 @@ launchctl load ~/Library/LaunchAgents/org.user.Jackett.plist # Check that it's running if [[ $(launchctl list | grep org.user.Jackett) ]]; then - echo "Agent successfully installed and launched!" +echo "${BOLDGREEN}Agent successfully installed and launched!${NC}" else cat << EOL -Could not launch agent. The installation might have failed. +${BOLDRED}ERROR${NC}: Could not launch agent. The installation might have failed. Please open an issue on https://github.com/Jackett/Jackett/issues and paste following information: Mono directory: \`${monodir}\` Jackett directory: \`${jackettdir}\` + EOL fi