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.
This commit is contained in:
thebluepotato 2017-08-28 11:05:41 +02:00 committed by kaso17
parent 7423e3f5bc
commit d8d911abf8
3 changed files with 91 additions and 10 deletions

View File

@ -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)

View File

@ -153,6 +153,9 @@
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<Content Include="install_service_macos.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CurlSharp\CurlSharp.csproj">
@ -182,4 +185,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@ -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 <<EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:${monodir}</string>
</dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.user.Jackett</string>
<key>ProgramArguments</key>
<array>
<string>${monodir}/mono</string>
<string>--debug</string>
<string>JackettConsole.exe</string>
<string>--NoRestart</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>${jackettdir}</string>
</dict>
</plist>
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