From e745b02c5538e9b34b79c0d270ac5ec24ec2fdbc Mon Sep 17 00:00:00 2001 From: flightlevel Date: Sun, 24 Mar 2019 15:57:11 +1100 Subject: [PATCH] Attempt to make install_service_macos .NET Core compatible --- install_service_macos | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 install_service_macos diff --git a/install_service_macos b/install_service_macos new file mode 100644 index 000000000..1d16a0e79 --- /dev/null +++ b/install_service_macos @@ -0,0 +1,70 @@ +#!/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 + +# 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)" + +# Check that no other service called Jackett is already running +if [[ $(launchctl list | grep org.user.Jackett) ]]; then + echo "${BOLDRED}ERROR${NC}: 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 +mkdir -p ~/Library/LaunchAgents/ +cat >~/Library/LaunchAgents/org.user.Jackett.plist < + + + + EnvironmentVariables + + PATH + /usr/bin:/bin:/usr/sbin:/sbin + + KeepAlive + + Label + org.user.Jackett + ProgramArguments + + ${jackettdir}/jackett + --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 "${BOLDGREEN}Agent successfully installed and launched!${NC}" +else + cat << EOL +${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: +Jackett directory: \`${jackettdir}\` + +EOL +fi