From d8d911abf8565b4aee42e50aa04f0b67e5cf6715 Mon Sep 17 00:00:00 2001 From: thebluepotato Date: Mon, 28 Aug 2017 11:05:41 +0200 Subject: [PATCH] Add a script to install Jackett as service on macOS (#1705) * Add instructions tu run Jackett as service on macOS * Changed restart logic * Replace plist with install script * Update README and add some more checks * Fix README * Move and rename script * Include script inside project * README corrections and cleanup * Slight improvement of the script Put `launchctl remove` earlier so it has the time to quit the service before testing if it's still running. --- README.md | 29 ++++++--- src/Jackett.Console/Jackett.Console.csproj | 5 +- src/Jackett.Console/install_service_macos.sh | 67 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 10 deletions(-) create mode 100755 src/Jackett.Console/install_service_macos.sh diff --git a/README.md b/README.md index c28d10d7f..3a1bc0d50 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Jackett +# Jackett [![GitHub issues](https://img.shields.io/github/issues/Jackett/Jackett.svg?maxAge=60&style=flat-square)](https://github.com/Jackett/Jackett/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/Jackett/Jackett.svg?maxAge=60&style=flat-square)](https://github.com/Jackett/Jackett/pulls) @@ -271,14 +271,25 @@ Jackett can also be run from the command line if you would like to see log messa Detailed instructions for [Ubuntu 14.x](http://www.htpcguides.com/install-jackett-on-ubuntu-14-x-for-custom-torrents-in-sonarr/) and [Ubuntu 15.x](http://www.htpcguides.com/install-jackett-ubuntu-15-x-for-custom-torrents-in-sonarr/) -## Installation on OSX - 1. Install [Mono 4](http://www.mono-project.com/download/#download-mac) or better (version 4.8 is recommended) - * Setup ssl support by running - ``` - https://curl.haxx.se/ca/cacert.pem - cert-sync --user ~/Downloads/cacert.pem - ``` - 1. Download and extract the latest `Jackett.Binaries.Mono.tar.gz` release from the [releases page](https://github.com/Jackett/Jackett/releases) and run Jackett using mono with the command `mono --debug JackettConsole.exe`. +## Installation on macOS + +### Prerequisites +Install [Mono 4](http://www.mono-project.com/download/#download-mac) or better (version 4.8 is recommended). + * Setup ssl support by running + ``` + https://curl.haxx.se/ca/cacert.pem + cert-sync --user ~/Downloads/cacert.pem + ``` + +### 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` + +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`. + +### Run without installing as a service +Download and extract the latest `Jackett.Binaries.Mono.tar.gz` release from the [releases page](https://github.com/Jackett/Jackett/releases) and run Jackett using mono with the command `mono --debug JackettConsole.exe`. ## Installation using Docker Detailed instructions are available at [LinuxServer.io Jackett Docker](https://hub.docker.com/r/linuxserver/jackett/). The Jackett Docker is highly recommended, especially if you are having Mono stability issues or having issues running Mono on your system eg. QNAP, Synology. Thanks to [LinuxServer.io](https://linuxserver.io) diff --git a/src/Jackett.Console/Jackett.Console.csproj b/src/Jackett.Console/Jackett.Console.csproj index 0869c7e70..8af4a4af1 100644 --- a/src/Jackett.Console/Jackett.Console.csproj +++ b/src/Jackett.Console/Jackett.Console.csproj @@ -153,6 +153,9 @@ + + PreserveNewest + @@ -182,4 +185,4 @@ --> - \ No newline at end of file + diff --git a/src/Jackett.Console/install_service_macos.sh b/src/Jackett.Console/install_service_macos.sh new file mode 100755 index 000000000..25f303a63 --- /dev/null +++ b/src/Jackett.Console/install_service_macos.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Stop and unload the service if it's running +launchctl remove org.user.Jackett + +# Check if we're running from Jackett's directory +if [ ! -f ./JackettConsole.exe ]; then + echo "Couldn't locate JackettConsole.exe. Are you running from 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; } +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." + exit 1 +fi + +# Write the plist to LaunchAgents +cat >~/Library/LaunchAgents/org.user.Jackett.plist < + + + + EnvironmentVariables + + PATH + /usr/bin:/bin:/usr/sbin:/sbin:${monodir} + + KeepAlive + + Label + org.user.Jackett + ProgramArguments + + ${monodir}/mono + --debug + JackettConsole.exe + --NoRestart + + RunAtLoad + + WorkingDirectory + ${jackettdir} + + + +EOL + +# Run the agent +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!" +else + cat << EOL +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