Skip to content
Merged
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
92 changes: 46 additions & 46 deletions dupe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_PATH="$SCRIPT_DIR/.env"
if [ -f "$ENV_PATH" ]; then
# shellcheck source=.env
echo "Loading environment variables from $ENV_PATH file"
# shellcheck disable=SC1090 # shellcheck sucks
if source "$ENV_PATH"; then
echo "Environment variables loaded successfully"
else
echo "Error loading environment variables" >&2
exit 1
fi
# shellcheck source=.env
echo "Loading environment variables from $ENV_PATH file"
# shellcheck disable=SC1090 # shellcheck sucks
if source "$ENV_PATH"; then
echo "Environment variables loaded successfully"
else
echo "Error loading environment variables" >&2
exit 1
fi
else
echo ".env file not found in script directory ($ENV_PATH)"
echo ".env file not found in script directory ($ENV_PATH)"
fi

# Default Variables
Expand All @@ -30,52 +30,52 @@ JDUPES_INCLUDE_EXT=${JDUPES_INCLUDE_EXT:-"mp4,mkv,avi"}
DEBUG=${DEBUG:-"false"}

find_duplicates() {
local log_file="$JDUPES_OUTPUT_LOG"
local start_time
start_time=$(date +%s)
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Duplicate search started" | tee -a "$log_file"
local log_file="$JDUPES_OUTPUT_LOG"
local start_time
start_time=$(date +%s)
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Duplicate search started" | tee -a "$log_file"

if [ "$DEBUG" == "true" ]; then
echo "Running jdupes with:" | tee -a "$log_file"
echo "$JDUPES_COMMAND $JDUPES_EXCLUDE_DIRS -X onlyext:$JDUPES_INCLUDE_EXT -r -M -y $JDUPES_HASH_DB $JDUPES_SOURCE_DIR $JDUPES_DESTINATION_DIR" | tee -a "$log_file"
fi
if [ "$DEBUG" == "true" ]; then
echo "Running jdupes with:" | tee -a "$log_file"
echo "$JDUPES_COMMAND $JDUPES_EXCLUDE_DIRS -X onlyext:$JDUPES_INCLUDE_EXT -r -M -y $JDUPES_HASH_DB $JDUPES_SOURCE_DIR $JDUPES_DESTINATION_DIR" | tee -a "$log_file"
fi

local results
# shellcheck disable=SC2086
results=$("$JDUPES_COMMAND" $JDUPES_EXCLUDE_DIRS -X onlyext:"$JDUPES_INCLUDE_EXT" -r -M -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR")
local results
# shellcheck disable=SC2086
results=$("$JDUPES_COMMAND" $JDUPES_EXCLUDE_DIRS -X onlyext:"$JDUPES_INCLUDE_EXT" -r -M -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR")

if [[ $results != *"No duplicates found."* ]]; then
# shellcheck disable=SC2086
"$JDUPES_COMMAND" $JDUPES_EXCLUDE_DIRS -X onlyext:"$JDUPES_INCLUDE_EXT" -r -L -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR" >>"$log_file"
fi
if [[ $results != *"No duplicates found."* ]]; then
# shellcheck disable=SC2086
"$JDUPES_COMMAND" $JDUPES_EXCLUDE_DIRS -X onlyext:"$JDUPES_INCLUDE_EXT" -r -L -y "$JDUPES_HASH_DB" "$JDUPES_SOURCE_DIR" "$JDUPES_DESTINATION_DIR" >>"$log_file"
fi

if [ "$DEBUG" == "true" ]; then
echo -e "jdupes output: ${results}" | tee -a "$log_file"
fi
if [ "$DEBUG" == "true" ]; then
echo -e "jdupes output: ${results}" | tee -a "$log_file"
fi

parse_jdupes_output "$results" "$log_file"
local finish_time
finish_time=$(date +%s)
local run_time=$((finish_time - start_time))
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Duplicate search completed in ${run_time}s" | tee -a "$log_file"
parse_jdupes_output "$results" "$log_file"
local finish_time
finish_time=$(date +%s)
local run_time=$((finish_time - start_time))
echo "[$(date +"%Y-%m-%d %H:%M:%S")] Duplicate search completed in ${run_time}s" | tee -a "$log_file"
}

parse_jdupes_output() {
local results="$1"
local log_file="$2"
local results="$1"
local log_file="$2"

if [[ $results != *"No duplicates found."* ]]; then
field_message="❌ Unlinked files discovered..."
parsed_log=$(echo "$results" | awk -F/ '{print $NF}' | sort -u)
else
field_message="✅ No unlinked files discovered..."
parsed_log="No hardlinks created"
fi
if [[ $results != *"No duplicates found."* ]]; then
field_message="❌ Unlinked files discovered..."
parsed_log=$(echo "$results" | awk -F/ '{print $NF}' | sort -u)
else
field_message="✅ No unlinked files discovered..."
parsed_log="No hardlinks created"
fi

if [ "$DEBUG" == "true" ]; then
echo -e "$field_message" | tee -a "$log_file"
echo -e "Parsed log: ${parsed_log}" | tee -a "$log_file"
fi
if [ "$DEBUG" == "true" ]; then
echo -e "$field_message" | tee -a "$log_file"
echo -e "Parsed log: ${parsed_log}" | tee -a "$log_file"
fi
}

find_duplicates
16 changes: 8 additions & 8 deletions f2b-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ temp_file=$(mktemp)

# Function to add content to the temporary file
add_content() {
# shellcheck disable=SC2129
echo -e "\n$1\n" >>"$temp_file"
cat "$2" >>"$temp_file" 2>/dev/null
echo -e "\n" >>"$temp_file"
# shellcheck disable=SC2129
echo -e "\n$1\n" >>"$temp_file"
cat "$2" >>"$temp_file" 2>/dev/null
echo -e "\n" >>"$temp_file"
}

# List all active jails
Expand All @@ -18,8 +18,8 @@ fail2ban-client status >>"$temp_file"
# Get status for each jail
jails=$(fail2ban-client status | grep 'Jail list:' | sed -E 's/^[^:]+:\s+//;s/,//g')
for jail in $jails; do
echo -e "\nStatus of $jail jail:\n" >>"$temp_file"
fail2ban-client status "$jail" >>"$temp_file"
echo -e "\nStatus of $jail jail:\n" >>"$temp_file"
fail2ban-client status "$jail" >>"$temp_file"
done

# Global configurations
Expand All @@ -29,8 +29,8 @@ add_content "Custom Global Configuration (/etc/fail2ban/jail.local):" "/etc/fail
# Custom jail configurations in jail.d/
echo "Custom Jail Configurations in /etc/fail2ban/jail.d/:" >>"$temp_file"
for config_file in /etc/fail2ban/jail.d/*; do
[ -e "$config_file" ] || continue
add_content "Custom Jail Configuration ($config_file):" "$config_file"
[ -e "$config_file" ] || continue
add_content "Custom Jail Configuration ($config_file):" "$config_file"
done

# Upload to termbin
Expand Down
10 changes: 5 additions & 5 deletions omegabrr_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ service_name="omegabrr@bakerboy448"

# Function to handle errors and exit
handle_error() {
echo "Error: $1" >&2
exit 1
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)

# Validate the download URL
if [ -z "$dlurl" ]; then
handle_error "Failed to fetch download URL."
handle_error "Failed to fetch download URL."
fi

# Download the latest release
Expand Down
58 changes: 29 additions & 29 deletions pic-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,48 @@ CURRENT_UID=$(id -u)

# Check if Plex-Image-Cleanup is installed and the current user owns it
check_pic_installation() {
if [ -d "$PIC_PATH" ]; then
local pic_repo_owner
pic_repo_owner=$(stat -c '%u' "$PIC_PATH")
if [ "$pic_repo_owner" != "$CURRENT_UID" ]; then
echo "You do not own the Plex-Image-Cleanup repo. Please run this script as the user that owns the repo [$pic_repo_owner]."
exit 1
fi
else
echo "Plex-Image-Cleanup folder does not exist. Please install Plex-Image-Cleanup before running this script."
exit 1
if [ -d "$PIC_PATH" ]; then
local pic_repo_owner
pic_repo_owner=$(stat -c '%u' "$PIC_PATH")
if [ "$pic_repo_owner" != "$CURRENT_UID" ]; then
echo "You do not own the Plex-Image-Cleanup repo. Please run this script as the user that owns the repo [$pic_repo_owner]."
exit 1
fi
else
echo "Plex-Image-Cleanup folder does not exist. Please install Plex-Image-Cleanup before running this script."
exit 1
fi
}

# Update Plex-Image-Cleanup if necessary
update_pic() {
current_branch=$(git -C "$PIC_PATH" rev-parse --abbrev-ref HEAD)
echo "Current Branch: $current_branch. Checking for updates..."
git -C "$PIC_PATH" fetch
if [ "$(git -C "$PIC_PATH" rev-parse HEAD)" = "$(git -C "$PIC_PATH" rev-parse @'{u}')" ] && [ "$force_update" != true ]; then
current_version=$(cat "$PIC_VERSION_FILE")
echo "=== Already up to date $current_version on $current_branch ==="
exit 0
fi
git -C "$PIC_PATH" reset --hard "$PIC_UPSTREAM_GIT_REMOTE/$current_branch"
current_branch=$(git -C "$PIC_PATH" rev-parse --abbrev-ref HEAD)
echo "Current Branch: $current_branch. Checking for updates..."
git -C "$PIC_PATH" fetch
if [ "$(git -C "$PIC_PATH" rev-parse HEAD)" = "$(git -C "$PIC_PATH" rev-parse @'{u}')" ] && [ "$force_update" != true ]; then
current_version=$(cat "$PIC_VERSION_FILE")
echo "=== Already up to date $current_version on $current_branch ==="
exit 0
fi
git -C "$PIC_PATH" reset --hard "$PIC_UPSTREAM_GIT_REMOTE/$current_branch"
}

# Update venv if necessary
update_venv() {
current_requirements=$(sha1sum "$PIC_REQUIREMENTS_FILE" | awk '{print $1}')
new_requirements=$(sha1sum "$PIC_REQUIREMENTS_FILE" | awk '{print $1}')
if [ "$current_requirements" != "$new_requirements" ] || [ "$force_update" = true ]; then
echo "=== Requirements changed, updating venv ==="
"$PIC_VENV_PATH/bin/python3" "$PIC_VENV_PATH/bin/pip" install -r "$PIC_REQUIREMENTS_FILE"
fi
current_requirements=$(sha1sum "$PIC_REQUIREMENTS_FILE" | awk '{print $1}')
new_requirements=$(sha1sum "$PIC_REQUIREMENTS_FILE" | awk '{print $1}')
if [ "$current_requirements" != "$new_requirements" ] || [ "$force_update" = true ]; then
echo "=== Requirements changed, updating venv ==="
"$PIC_VENV_PATH/bin/python3" "$PIC_VENV_PATH/bin/pip" install -r "$PIC_REQUIREMENTS_FILE"
fi
}

# Restart the Plex-Image-Cleanup service
restart_service() {
echo "=== Restarting Plex-Image-Cleanup Service ==="
sudo systemctl restart "$PIC_SERVICE_NAME"
new_version=$(cat "$PIC_VERSION_FILE")
echo "=== Updated to $new_version on $current_branch ==="
echo "=== Restarting Plex-Image-Cleanup Service ==="
sudo systemctl restart "$PIC_SERVICE_NAME"
new_version=$(cat "$PIC_VERSION_FILE")
echo "=== Updated to $new_version on $current_branch ==="
}

# Main script execution
Expand Down
56 changes: 28 additions & 28 deletions pmm-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@ CURRENT_UID=$(id -u)

# Check if PMM is installed and the current user owns it
check_pmm_installation() {
if [ -d "$PMM_PATH" ]; then
pmm_repo_owner=$(stat -c '%u' "$PMM_PATH")
if [ "$pmm_repo_owner" != "$CURRENT_UID" ]; then
echo "You do not own the Plex Meta Manager repo. Please run this script as the user that owns the repo [$pmm_repo_owner]."
exit 1
fi
else
echo "Plex Meta Manager folder does not exist. Please install Plex Meta Manager before running this script."
exit 1
if [ -d "$PMM_PATH" ]; then
pmm_repo_owner=$(stat -c '%u' "$PMM_PATH")
if [ "$pmm_repo_owner" != "$CURRENT_UID" ]; then
echo "You do not own the Plex Meta Manager repo. Please run this script as the user that owns the repo [$pmm_repo_owner]."
exit 1
fi
else
echo "Plex Meta Manager folder does not exist. Please install Plex Meta Manager before running this script."
exit 1
fi
}

# Update PMM if necessary
update_pmm() {
current_branch=$(git -C "$PMM_PATH" rev-parse --abbrev-ref HEAD)
echo "Current Branch: $current_branch. Checking for updates..."
git -C "$PMM_PATH" fetch
if [ "$(git -C "$PMM_PATH" rev-parse HEAD)" = "$(git -C "$PMM_PATH" rev-parse @'{u}')" ] && [ "$force_update" != true ]; then
current_version=$(cat "$PMM_VERSION_FILE")
echo "=== Already up to date $current_version on $current_branch ==="
exit 0
fi
git -C "$PMM_PATH" reset --hard "$PMM_UPSTREAM_GIT_REMOTE/$current_branch"
current_branch=$(git -C "$PMM_PATH" rev-parse --abbrev-ref HEAD)
echo "Current Branch: $current_branch. Checking for updates..."
git -C "$PMM_PATH" fetch
if [ "$(git -C "$PMM_PATH" rev-parse HEAD)" = "$(git -C "$PMM_PATH" rev-parse @'{u}')" ] && [ "$force_update" != true ]; then
current_version=$(cat "$PMM_VERSION_FILE")
echo "=== Already up to date $current_version on $current_branch ==="
exit 0
fi
git -C "$PMM_PATH" reset --hard "$PMM_UPSTREAM_GIT_REMOTE/$current_branch"
}

# Update venv if necessary
update_venv() {
current_requirements=$(sha1sum "$PMM_REQUIREMENTS_FILE" | awk '{print $1}')
new_requirements=$(sha1sum "$PMM_REQUIREMENTS_FILE" | awk '{print $1}')
if [ "$current_requirements" != "$new_requirements" ] || [ "$force_update" = true ]; then
echo "=== Requirements changed, updating venv ==="
"$PMM_VENV_PATH/bin/python3" "$PMM_VENV_PATH/bin/pip" install -r "$PMM_REQUIREMENTS_FILE"
fi
current_requirements=$(sha1sum "$PMM_REQUIREMENTS_FILE" | awk '{print $1}')
new_requirements=$(sha1sum "$PMM_REQUIREMENTS_FILE" | awk '{print $1}')
if [ "$current_requirements" != "$new_requirements" ] || [ "$force_update" = true ]; then
echo "=== Requirements changed, updating venv ==="
"$PMM_VENV_PATH/bin/python3" "$PMM_VENV_PATH/bin/pip" install -r "$PMM_REQUIREMENTS_FILE"
fi
}

# Restart the PMM service
restart_service() {
echo "=== Restarting PMM Service ==="
sudo systemctl restart "$PMM_SERVICE_NAME"
new_version=$(cat "$PMM_VERSION_FILE")
echo "=== Updated to $new_version on $current_branch"
echo "=== Restarting PMM Service ==="
sudo systemctl restart "$PMM_SERVICE_NAME"
new_version=$(cat "$PMM_VERSION_FILE")
echo "=== Updated to $new_version on $current_branch"
}

# Main script execution
Expand Down
18 changes: 9 additions & 9 deletions qbm-api-trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ API_URL="http://127.0.0.1:4269/api/run-command"
COMMANDS='["tag_update", "share_limits", "rem_unregistered", "recheck"]'

if [[ $# -lt 1 || -z "$1" ]]; then
echo "Usage: $0 <torrent_hash>" >&2
exit 1
echo "Usage: $0 <torrent_hash>" >&2
exit 1
fi

TORRENT_HASH="$1"
Expand All @@ -34,15 +34,15 @@ LOG_FILE="${SCRIPT_DIR}/run_qbit_manage_commands.log"
JSON="{\"commands\":${COMMANDS},\"hashes\":[\"${TORRENT_HASH}\"]}"

{
echo "Sending API call for hash: ${TORRENT_HASH}"
echo "Payload: ${JSON}"
echo "Sending API call for hash: ${TORRENT_HASH}"
echo "Payload: ${JSON}"
} | tee -a "${LOG_FILE}"

if curl -fsSL -X POST \
-H "Content-Type: application/json" \
-d "${JSON}" \
"${API_URL}" | tee -a "${LOG_FILE}"; then
echo "Success" | tee -a "${LOG_FILE}"
-H "Content-Type: application/json" \
-d "${JSON}" \
"${API_URL}" | tee -a "${LOG_FILE}"; then
echo "Success" | tee -a "${LOG_FILE}"
else
echo "Error: qBit Manage API call failed for hash ${TORRENT_HASH}" | tee -a "${LOG_FILE}"
echo "Error: qBit Manage API call failed for hash ${TORRENT_HASH}" | tee -a "${LOG_FILE}"
fi
Loading
Loading