Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .env
# Environment Configuration StarrScripts Sample 2024-04
# Rename this file to .env and fill in the values accordingly.
# Xseed
## Download Client Names
TORRENT_CLIENT_NAME="" # Example: "Qbit"
USENET_CLIENT_NAME="" # Example: "SABnzbd"
## Cross Seed API configuration
XSEED_HOST="" # Example: "crossseed"
XSEED_PORT="" # Example: "2468"
## API Key for Cross Seed, if applicable
XSEED_APIKEY="" # Example: "your-api-key"
## Path to store the script's database of prior searches
LOG_FILE="" # Example: "/config/xseed_db.log"
# ZFS Destory
VERBOSE=0
MAX_FREQ=2
MAX_HOURLY=2
MAX_DAILY=1
MAX_WEEKLY=0
MAX_MONTHLY=0
# Jdupes
JDUPES_OUTPUT_LOG="" # Example: "/.config/jdupes.log"
JDUPES_SOURCE_DIR="" # Example: "/mnt/data/media/"
JDUPES_DESTINATION_DIR="" # Example: "/mnt/data/torrents/"
JDUPES_HASH_DB="" # Example: "/.config/jdupes_hashdb"
# Qbittorrent Manage
QBIT_MANAGE_LOCK_FILE_PATH="" # Example: "/var/lock/qbm-qbit.lock"
QBIT_MANAGE_PATH="" # Example: "/opt/qbit-manage"
QBIT_MANAGE_VENV_PATH="" # Example: "/opt/qbit-manage/.venv"
QBIT_MANAGE_CONFIG_PATH="" # Example: "/opt/qbit-manage/config.yml"
QBIT_MANAGE_OPTIONS="" # Example: "-cs -re -cu -tu -ru -sl -r"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# Ignore .env
.env
34 changes: 24 additions & 10 deletions dupe.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
#!/bin/bash

jdupes_command="/usr/bin/jdupes"
exclude_dirs="-X nostr:.RecycleBin -X nostr:.trash"
include_ext="-X onlyext:mp4,mkv,avi"
output_log="/.config/jdupes.log"
source_dir="/mnt/data/media/"
destination_dir="/mnt/data/torrents/"
hash_db="/.config/jdupes_hashdb"
# Load environment variables from .env file
# Load environment variables from .env file if it exists
if [ -f ".env" ]; then
# shellcheck source=.env
source ".env"
fi
# Variables
JDUPES_OUTPUT_LOG=${JDUPES_OUTPUT_LOG:-"/var/log/jdupes.log"}
JDUPES_SOURCE_DIR=${JDUPES_SOURCE_DIR:-"/mnt/data/media/"}
JDUPES_DESTINATION_DIR=${JDUPES_DESTINATION_DIR:-"/mnt/data/torrents/"}
JDUPES_HASH_DB=${JDUPES_HASH_DB:-"/var/lib/jdupes_hashdb"}
## Secret Variables
JDUPES_COMMAND=${JDUPES_COMMAND:-"/usr/bin/jdupes"}
JDUPES_EXCLUDE_DIRS=${JDUPES_EXCLUDE_DIRS:-"-X nostr:.RecycleBin -X nostr:.trash"}
JDUPES_INCLUDE_EXT=${JDUPES_INCLUDE_EXT:-"mp4,mkv,avi"}

# Logging the start of the operation
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
echo "[$timestamp] Duplicate search started for $source_dir and $destination_dir." >> "$output_log"
$jdupes_command $exclude_dirs $include_ext -L -r -Z -y "$hash_db" "$source_dir" "$destination_dir" >> "$output_log"
echo "[$timestamp] Duplicate search started for $JDUPES_SOURCE_DIR and $JDUPES_DESTINATION_DIR." >>"$JDUPES_OUTPUT_LOG"
echo "command is"
# Running jdupes with the loaded environment variables
echo $JDUPES_COMMAND "$JDUPES_EXCLUDE_DIRS" "$JDUPES_INCLUDE_EXT" -L -r -Z -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR"
$JDUPES_COMMAND $JDUPES_EXCLUDE_DIRS -X onlyext:$JDUPES_INCLUDE_EXT -L -r -Z -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR" >>"$JDUPES_OUTPUT_LOG"

# Logging the completion of the operation
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
echo "[$timestamp] Duplicate search completed for $source_dir and $destination_dir." >> "$output_log"
echo "[$timestamp] Duplicate search completed for $JDUPES_SOURCE_DIR and $JDUPES_DESTINATION_DIR." >>"$JDUPES_OUTPUT_LOG"
130 changes: 46 additions & 84 deletions notifiarr-branch-builder.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,43 @@
#!/bin/bash

# Extend the PATH to include the go binary directory
export PATH=$PATH:/usr/local/go/bin

# Function to display an error message and exit
# Function to display error messages and exit with status 1
handle_error() {
echo "Error: $1"
echo "Error: $1" >&2
exit 1
}

# Display usage information
# Function to display usage information
display_help() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -h Display this help message"
echo " --repo-url URL Set the repository URL (default: https://github.com/Notifiarr/notifiarr.git)"
echo " --repo-dir DIR Set the repository directory (default: /home/bakerboy448/notifiarr)"
echo " --bin-path PATH Set the binary path (default: /usr/bin/notifiarr)"
echo " --branch BRANCH Set the branch (default: master)"
echo " --reinstall-apt Reinstall Notifiarr using apt without prompting."
echo " -h, --help Display this help message"
echo " --repo-url URL Set the repository URL (default: https://github.com/Notifiarr/notifiarr.git)"
echo " --repo-dir DIR Set the repository directory (default: /opt/notifiarr-repo)"
echo " --bin-path PATH Set the binary path (default: /usr/bin/notifiarr)"
echo " --branch BRANCH Set the branch (default: master)"
echo " --reinstall-apt Reinstall Notifiarr using apt without prompting."
exit 0
}

#TODO Fix this later
# Check if Golang is installed, install if not
#if ! command -v go &>/dev/null; then
# read -p "Golang is not installed. Do you want to install it? [Y/n] " go_install_choice
# if [[ "$go_install_choice" == [Yy]* ]]; then
# # Download Go tarball to /tmp directory
# if curl -o /tmp/go1.21.3.linux-amd64.tar.gz https://go.dev/dl/go1.21.3.linux-amd64.tar.gz; then
# # Remove any existing Go installation, extract Go, update PATH, and check Go version
# sudo rm -rf /usr/local/go && \
# sudo tar -C /usr/local -xzf /tmp/go1.21.3.linux-amd64.tar.gz && \
# echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.bashrc && \
# source ~/.bashrc && \
# go version && \
# rm /tmp/go1.21.3.linux-amd64.tar.gz
# else
# echo "Failed to download Golang."
# exit 1
# fi
# else
# echo "Golang is required for this script. Exiting."
# exit 1
# fi
#fi

# Check if Make is installed, install if not
if ! command -v make &>/dev/null; then
read -p "Make is not installed. Do you want to install it? [Y/n] " make_install_choice
if [[ "$make_install_choice" == [Yy]* ]]; then
sudo apt update && sudo apt install -y make || handle_error "Failed to install Make."
else
echo "Make is required for this script. Exiting."
exit 1
# Function to check and prompt for installation of a required tool
ensure_tool_installed() {
local tool=$1
local install_cmd=$2
if ! command -v "$tool" &>/dev/null; then
read -p "$tool is not installed. Do you want to install it? [Y/n] " response
if [[ "$response" =~ ^[Yy] ]]; then
eval "$install_cmd" || handle_error "Failed to install $tool."
else
echo "$tool is required for this script. Exiting."
exit 1
fi
fi
fi
}

# Default parameter values
# Default parameters
repo_url="https://github.com/Notifiarr/notifiarr.git"
repo_dir="/opt/notifiarr-repo"
bin_path="/usr/bin/notifiarr"
Expand All @@ -65,7 +47,7 @@ apt_reinstall=false
# Parse command line options
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
-h|--help)
display_help
;;
--repo-url)
Expand All @@ -86,8 +68,7 @@ while [[ $# -gt 0 ]]; do
;;
--reinstall-apt)
apt_reinstall=true
;;

;;
*)
echo "Invalid option: $1. Use -h for help."
exit 1
Expand All @@ -96,81 +77,62 @@ while [[ $# -gt 0 ]]; do
shift
done

# Check if user wants to reinstall using apt
if [[ $apt_reinstall == true || ( $apt_reinstall == false && $(read -p "Do you want to reinstall Notifiarr using apt? [Y/n] " apt_choice; echo "$apt_choice") == [Yy]* ) ]]; then
# Ensure required tools are installed
ensure_tool_installed "make" "sudo apt update && sudo apt install -y make"

# Reinstallation condition handling
reinstall_notifiarr() {
sudo apt update && sudo apt install --reinstall notifiarr || handle_error "Failed to reinstall Notifiarr using apt."
exit 0
fi
}

[[ $apt_reinstall == true ]] && reinstall_notifiarr

# Clone the repo if it doesn't exist, else fetch the latest
# Repository management
if [[ ! -d "$repo_dir" ]]; then
git clone "$repo_url" "$repo_dir" || handle_error "Failed to clone repository."
else
git -C "$repo_dir" fetch --all --prune || handle_error "Failed to fetch updates from remote."
fi

# Get the current branch
# Branch handling and updating
current_branch=$(git -C "$repo_dir" rev-parse --abbrev-ref HEAD)
echo "Current branch is: $current_branch"
read -p "Do you want to use the current branch? [Y/n] " choice

if [[ "$choice" != [Yy]* ]]; then
# List all available branches
branches=$(git -C "$repo_dir" branch -r | sed 's/origin\///' | sed 's/* //')
read -p "Do you want to use the current branch ($current_branch)? [Y/n] " choice
if [[ "$choice" =~ ^[Nn] ]]; then
branches=$(git -C "$repo_dir" branch -r | sed 's/origin\///;s/* //')
echo "Available branches:"
echo "$branches"

while true; do
read -p "Enter the branch name you want to use: " branch
if [[ $branches =~ $branch ]]; then
git -C "$repo_dir" checkout "$branch" || handle_error "Failed to checkout branch $branch."
break
else
echo "Invalid choice. Please select a valid branch."
fi
done

# Checkout the selected branch
git -C "$repo_dir" checkout "$branch" || handle_error "Failed to checkout branch $branch."
else
branch=$current_branch
fi

# Pull latest changes from the selected branch
git -C "$repo_dir" pull || handle_error "Failed to pull latest changes."

# Compile the code (assuming the repository requires a 'make' step)
make --directory="$repo_dir" || handle_error "Failed to compile."

# Service management
echo "Stopping notifiarr..."
sudo systemctl stop notifiarr

# Move the binaries
if [[ -f "$bin_path" ]]; then
sudo mv "$bin_path" "$repo_dir".old && echo "Old binary moved to $repo_dir.old"
fi

sudo mv "$repo_dir/notifiarr" "$bin_path" && echo "New binary moved to $bin_path"
# Change owner of the compiled binary
sudo chown "root:root" "$bin_path"
sudo chown root:root "$bin_path"

# Start the service again
echo "Starting Notifiarr..."
sudo systemctl start notifiarr

# Check if the service started successfully
if [[ $? -eq 0 ]]; then
echo "Notifiarr service started successfully"

# Check the status of the service
sudo systemctl is-active --quiet notifiarr
if [[ $? -eq 0 ]]; then
echo "Notifiarr service is currently running"
else
echo "Notifiarr service is not running"
fi
if sudo systemctl is-active –quiet notifiarr; then
echo “Notifiarr service started and is currently running”
else
echo "Failed to start Notifiarr service"
handle_error “Failed to start Notifiarr service
fi

# Exit the script
exit 0
47 changes: 29 additions & 18 deletions omegabrr_upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/bin/bash

# Define service name as a variable
service_name="omegabrr@bakerboy448"

# Function to handle errors and exit
handle_error() {
echo "Error: $1" >&2
exit 1
}

# Get the old version of omegabrr
old_version=$(omegabrr version)

# Fetch the URL of the latest release for linux_x86_64
dlurl=$(curl -s https://api.github.com/repos/autobrr/omegabrr/releases/latest | grep -E 'browser_download_url.*linux_x86_64' | cut -d\" -f4)
dlurl=$(curl -s https://api.github.com/repos/autobrr/omegabrr/releases/latest | \
grep -E 'browser_download_url.*linux_x86_64' | cut -d\" -f4)

# Download the latest release
if [ -n "$dlurl" ]; then
wget "$dlurl"
# Extract the downloaded archive
sudo tar -xzf omegabrr*.tar.gz
# Move omegabrr to /usr/bin
sudo mv omegabrr /usr/bin/omegabrr
# Clean up downloaded files
rm omegabrr*.tar.gz
echo "Omegabrr Updated"
else
echo "Failed to fetch download URL. Exiting..."
exit 1
# Validate the download URL
if [ -z "$dlurl" ]; then
handle_error "Failed to fetch download URL."
fi

# Download the latest release
wget "$dlurl" -O omegabrr_latest.tar.gz || handle_error "Failed to download the latest version."

# Extract the downloaded archive
sudo tar -xzf omegabrr_latest.tar.gz -C /usr/bin/ || handle_error "Failed to extract files."

# Clean up downloaded files
rm omegabrr_latest.tar.gz

# Display old and new versions
echo "Old Version: $old_version"
echo "New Version: $(omegabrr version)"
new_version=$(omegabrr version)
echo "Omegabrr updated from $old_version to $new_version"

# Restart the specified service
sudo systemctl restart $service_name || handle_error "Failed to restart the service $service_name."

# Restart the omegabrr service (assuming sysrestart command exists)
sysrestart omegabrr@bakerboy448
echo "Update and restart successful!"
Loading