Skip to content

Commit

Permalink
Added Jackett
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyE123 committed Feb 13, 2017
1 parent 29d4948 commit 592eae4
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 5 deletions.
1 change: 1 addition & 0 deletions jackett/jackett-backup-files
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPSETTINGS
15 changes: 15 additions & 0 deletions jackett/jackett-constants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
APPNAME='jackett'
APPSHORTNAME='jk'
APPPATH='/opt/jackett'
APPTITLE='Jackett'
APPDEPS='libcurl4-openssl-dev'
APPDPORT='9117'
APPSETTINGSDIR="/home/$UNAME/.config/Jackett"
APPSETTINGS=$APPSETTINGSDIR'/ServerConfig.json'
PORTSEARCH='"Port": '
USERSEARCH='NA'
PASSSEARCH='NA'
APPSYSTEMD='jackett.service'
APPSYSTEMDLOC=$SCRIPTPATH'/jackett/'$APPSYSTEMD
APPINITDLOC=$SCRIPTPATH'/jackett/jackett.init'
15 changes: 15 additions & 0 deletions jackett/jackett-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Script Name: AtoMiC Jackett Installer
# Author: TommyE123
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.
echo
echo -e $YELLOW'--->Latest File Found...'$ENDCOLOR
OUTPUT="$(curl -s https://api.github.com/repos/jackett/jackett/releases| grep browser_download_url | head -n 1 | cut -d '"' -f 4)"
echo "${OUTPUT}"
echo
echo -e $YELLOW'--->Downloading and extracting files...'$ENDCOLOR
sudo curl -L "${OUTPUT}" | tar -xzf - -C $APPPATH --strip-components=1
1 change: 1 addition & 0 deletions jackett/jackett-folders-list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/opt/jackett
10 changes: 10 additions & 0 deletions jackett/jackett-init-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# Script Name: AtoMiC Jackett init.d update
# Author: TommyE123
# Publisher: http://www.htpcbeginner.com
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.
echo 'Updating init.d file'

sudo sed -i "s@RUN_AS=ReplaceMe@RUN_AS=$UNAME@g" /etc/init.d/$APPNAME || { echo -e $RED'Replacing RUN_AS failed.'$ENDCOLOR ; exit 1; }
35 changes: 35 additions & 0 deletions jackett/jackett-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Script Name: AtoMiC Jackett Installer
# Author: TommyE123
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.

if [[ $ISSETUP != "Yes" ]]
then
echo
echo -e '\e[91mCannot be run directly. Please run setup.sh from AtoMiC ToolKit root folder: \033[0msudo bash setup.sh'
echo
exit 0
fi
source $SCRIPTPATH/inc/commons.sh
source $SCRIPTPATH/inc/header.sh

echo -e $GREEN"AtoMiC $APPTITLE Installer Script"$ENDCOLOR

source $SCRIPTPATH/inc/pause.sh
source $SCRIPTPATH/utils/mono/mono-installer.sh
source $SCRIPTPATH/jackett/jackett-constants.sh
source $SCRIPTPATH/inc/app-move-previous.sh
source $SCRIPTPATH/inc/pkgupdate.sh
source $SCRIPTPATH/inc/app-install-deps.sh
source $SCRIPTPATH/inc/app-folders-create.sh
source $SCRIPTPATH/jackett/jackett-download.sh
source $SCRIPTPATH/inc/app-autostart-configure.sh
source $SCRIPTPATH/inc/app-set-permissions.sh
source $SCRIPTPATH/inc/app-start.sh
source $SCRIPTPATH/inc/app-install-confirmation.sh
source $SCRIPTPATH/inc/thankyou.sh
source $SCRIPTPATH/inc/exit.sh
35 changes: 35 additions & 0 deletions jackett/jackett-menu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
if [[ $ISSETUP != "Yes" ]]
then
echo
echo -e '\e[91mCannot be run directly. Please run setup.sh from AtoMiC ToolKit root folder: \033[0msudo bash setup.sh'
echo
exit 0
fi
SUBCHOICE=$(whiptail --title "AtoMiC ToolKit - Manage Jackett" --menu "What would you like to do?" --backtitle "$BACKTITLE" --fb --cancel-button "Exit" $LINES $COLUMNS $NETLINES \
"Install" "Install Jackett" \
"Uninstall" "Uninstall Jackett" \
"Backup" "Backup Jackett settings" \
"Restore" "Restore Jackett settings from a previous backup" \
"Manual Update" "Manually update Jackett" \
"Access Details" "View Jackett access details" \
"Go Back" "Back to Main Menu" 3>&1 1>&2 2>&3)

exitstatus=$?
if [ $exitstatus = 0 ]; then
source $SCRIPTPATH/jackett/jackett-constants.sh
case "$SUBCHOICE" in
"Install" ) source $SCRIPTPATH/jackett/jackett-installer.sh ;;
"Uninstall" ) source $SCRIPTPATH/jackett/jackett-uninstaller.sh ;;
"Backup" ) source $SCRIPTPATH/inc/app-backup-controller.sh ;;
"Restore" ) source $SCRIPTPATH/inc/app-restore-controller.sh ;;
"Manual Update" ) source $SCRIPTPATH/jackett/jackett-update.sh ;;
"Access Details" ) source $SCRIPTPATH/inc/app-access-details.sh ;;
"Go Back" ) source $SCRIPTPATH/menus/menu-pvrs.sh ;;
*) source $SCRIPTPATH/inc/invalid-option.sh ;;
esac
else
source $SCRIPTPATH/inc/thankyou.sh
echo
sleep 1
fi
13 changes: 13 additions & 0 deletions jackett/jackett-systemd-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Script Name: AtoMiC Jackett Systemd Update
# Author: TommyE123
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.

sudo sed -i "s@User=ReplaceMe@User=$UNAME@g" /etc/systemd/system/$APPSYSTEMD || { echo -e $RED'Modifying USER in SYSTEMD file failed.'$ENDCOLOR; exit 1; }

sudo systemctl daemon-reload
sudo systemctl enable $APPSYSTEMD
28 changes: 28 additions & 0 deletions jackett/jackett-uninstaller.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Script Name: AtoMiC Jackett Uninstaller
# Author: TommyE123
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.

if [[ $ISSETUP != "Yes" ]]
then
echo
echo -e '\e[91mCannot be run directly. Please run setup.sh from AtoMiC ToolKit root folder: \033[0msudo bash setup.sh'
echo
exit 0
fi
source $SCRIPTPATH/inc/commons.sh
source $SCRIPTPATH/inc/header.sh

echo -e $GREEN"AtoMiC $APPTITLE Uninstaller Script"$ENDCOLOR

source $SCRIPTPATH/inc/pause.sh
source $SCRIPTPATH/inc/app-stop.sh
source $SCRIPTPATH/inc/app-autostart-remove.sh
source $SCRIPTPATH/inc/app-file-del.sh
source $SCRIPTPATH/inc/app-uninstall-confirmation.sh
source $SCRIPTPATH/inc/thankyou.sh
source $SCRIPTPATH/inc/exit.sh
33 changes: 33 additions & 0 deletions jackett/jackett-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Script Name: AtoMiC Jackett Updater
# Author: TommyE123
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#

# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.

if [[ $ISSETUP != "Yes" ]]
then
echo
echo -e '\e[91mCannot be run directly. Please run setup.sh from AtoMiC ToolKit root folder: \033[0msudo bash setup.sh'
echo
exit 0
fi
source $SCRIPTPATH/inc/commons.sh
source $SCRIPTPATH/inc/header.sh

echo -e $GREEN"AtoMiC $APPTITLE Update Script"$ENDCOLOR

source $SCRIPTPATH/inc/pause.sh
source $SCRIPTPATH/inc/app-folder-check.sh
source $SCRIPTPATH/inc/pkgupdate.sh
source $SCRIPTPATH/inc/app-stop.sh
source $SCRIPTPATH/inc/app-file-del.sh
source $SCRIPTPATH/inc/app-folders-create.sh
source $SCRIPTPATH/jackett/jackett-download.sh
source $SCRIPTPATH/inc/app-set-permissions.sh
source $SCRIPTPATH/inc/app-start.sh
source $SCRIPTPATH/inc/app-update-confirmation.sh
source $SCRIPTPATH/inc/thankyou.sh
source $SCRIPTPATH/inc/exit.sh
121 changes: 121 additions & 0 deletions jackett/jackett.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: Jackett
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Jackett
# Description: starts instance of Jackett using start-stop-daemon
### END INIT INFO

############### EDIT ME ##################
# path to app
APP_PATH=/opt/jackett

# user
RUN_AS=ReplaceMe

# path to mono bin
DAEMON=$(which mono)

# Path to store PID file
PID_FILE=/var/run/jackett/jackett.pid
PID_PATH=$(dirname $PID_FILE)

# script name
NAME=jackett

# app name
DESC=Jackett

# startup args
EXENAME="JackettConsole.exe"
DAEMON_OPTS=" "$EXENAME

############### END EDIT ME ##################

JACKETT_PID=`ps auxf | grep $EXENAME | grep -v grep | awk '{print $2}'`

test -x $DAEMON || exit 0

set -e

#Look for PID and create if doesn't exist
if [ ! -d $PID_PATH ]; then
mkdir -p $PID_PATH
chown $RUN_AS $PID_PATH
fi

if [ ! -d $DATA_DIR ]; then
mkdir -p $DATA_DIR
chown $RUN_AS $DATA_DIR
fi

if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
echo "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi

echo $JACKETT_PID > $PID_FILE

case "$1" in
start)
if [ -z "${JACKETT_PID}" ]; then
echo "Starting $DESC"
rm -rf $PID_PATH || return 1
install -d --mode=0755 -o $RUN_AS $PID_PATH || return 1
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
else
echo "Jackett already running."
fi
;;
stop)
echo "Stopping $DESC"
echo $JACKETT_PID > $PID_FILE
start-stop-daemon --stop --pidfile $PID_FILE --retry 15
;;

restart|force-reload)
echo "Restarting $DESC"
start-stop-daemon --stop --pidfile $PID_FILE --retry 15
start-stop-daemon -d $APP_PATH -c $RUN_AS --start --background --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
;;
status)
# Use LSB function library if it exists
if [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
if [ -e $PID_FILE ]; then
status_of_proc -p $PID_FILE "$DAEMON" "$NAME" && exit 0 || exit $?
else
log_daemon_msg "$NAME is not running"
exit 3
fi

else
# Use basic functions
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if kill -0 $PID > /dev/null 2>&1; then
echo " * $NAME is running"
exit 0
fi
else
echo " * $NAME is not running"
exit 3
fi
fi
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac

exit 0
14 changes: 14 additions & 0 deletions jackett/jackett.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Jackett
After=network.target

[Service]
User=ReplaceMe
Restart=always
RestartSec=5
Type=simple
ExecStart=/usr/bin/mono --debug /opt/jackett/JackettConsole.exe --NoRestart
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target
8 changes: 5 additions & 3 deletions menus/menu-bittorrent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ then
exit 0
fi
SUBCHOICE=$(whiptail --title "AtoMiC ToolKit - htpcBeginner.com" --menu "Which app would you like to manage?" --backtitle "$BACKTITLE" --fb --cancel-button "Exit" $LINES $COLUMNS $NETLINES \
"qBittorrent" "Bittorent Client" \
"Transmission" "Bittorrent Client" \
"Jackett" "API Support for your favorite private trackers" \
"qBittorrent" "an open-source software alternative to µTorrent" \
"Transmission" "Fast, easy, and free BitTorrent client" \
"Go Back" "Back to Main Menu" 3>&1 1>&2 2>&3)

exitstatus=$?
if [ $exitstatus = 0 ]; then
case "$SUBCHOICE" in
"qBittorrent" ) source $SCRIPTPATH/qbittorrent-nox/qbittorrent-nox-menu.sh ;;
"Jackett" ) source $SCRIPTPATH/jackett/jackett-menu.sh ;;
"qBittorrent" ) source $SCRIPTPATH/qbittorrent-nox/qbittorrent-nox-menu.sh ;;
"Transmission" ) source $SCRIPTPATH/transmission-daemon/transmission-daemon-menu.sh ;;
"Go Back" ) source $SCRIPTPATH/menus/menu-main.sh ;;
*) source $SCRIPTPATH/inc/invalid-option.sh ;;
Expand Down
4 changes: 2 additions & 2 deletions menus/menu-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MAINCHOICE=$(whiptail --title "AtoMiC ToolKit - htpcBeginner.com" --menu "Which
"PVRs" "Automatic Media Library Manager" \
"Administration Tools" "system configuration tools e.g. Webmin" \
"Usenet Downloaders" "Download binary files from Usenet servers" \
"Bittorent Clients" "Download Torrents" \
"Bittorrent Clients" "Download Torrents" \
"Personal Media Servers" "Organise and serve Media" \
"Utilities" "Other miscellaneous tools" \
"Maintenance" "Perform maintenance tasks" 3>&1 1>&2 2>&3)
Expand All @@ -21,7 +21,7 @@ if [ $exitstatus = 0 ]; then
"PVRs" ) source $SCRIPTPATH/menus/menu-pvrs.sh ;;
"Administration Tools" ) source $SCRIPTPATH/menus/menu-administration-tools.sh ;;
"Usenet Downloaders" ) source $SCRIPTPATH/menus/menu-usenet.sh ;;
"Bittorent Clients" ) source $SCRIPTPATH/menus/menu-bittorrent.sh ;;
"Bittorrent Clients" ) source $SCRIPTPATH/menus/menu-bittorrent.sh ;;
"Personal Media Servers" ) source $SCRIPTPATH/menus/menu-personal-media-servers.sh ;;
"Utilities" ) source $SCRIPTPATH/utils/utils-menu.sh ;;
"Maintenance" ) source $SCRIPTPATH/maintenance/maintenance-menu.sh ;;
Expand Down

0 comments on commit 592eae4

Please sign in to comment.