├── LICENSE ├── README.md └── scripts ├── diskutil-hbd ├── README.md └── diskutil.sh ├── freebandwidth-hbd ├── README.md └── freebandwidth.sh ├── freespace-docker ├── README.md └── freespace.sh ├── freespace-generic ├── README.md └── freespace.sh ├── freespace-hbd ├── README.md └── freespace.sh └── not_after ├── README.md └── not_after.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 autobrr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # community-scripts 2 | 3 | Scripts created by the autobrr community to be used as **External Filter** or **Action**. 4 | 5 | ## Add new 6 | 7 | Open a PR with your script added in a new directory in `scripts` and add a `README.md` with some basic instructions on what the script does and how to use it. You can copy and paste from `scripts/freespace-generic`. 8 | 9 | ## License 10 | 11 | All scripts are under MIT license so you can edit and modify as you please. We do however welcome new variants. 12 | -------------------------------------------------------------------------------- /scripts/diskutil-hbd/README.md: -------------------------------------------------------------------------------- 1 | # diskutil-hbd 2 | 3 | This is a disk util script that only works for HBD Shared App Slots. 4 | 5 | ```shell 6 | touch ~/diskutil.sh && chmod +x ~/diskutil.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | This script checks the total disk util of your alocated disk. 14 | 15 | It checks multiple times. This can be configured by changing the constant `ITERATIONS`. And calculates the average. Each iteration takes one second. 16 | 17 | It takes a command line argument which is the max percentage. 18 | 19 | ```shell 20 | ./diskutil.sh 80 21 | ``` 22 | If the util exceeds this value the script exits with a value of 1. 23 | Else it exits 0. -------------------------------------------------------------------------------- /scripts/diskutil-hbd/diskutil.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Set the number of iterations to calculate the average disk util 4 | readonly ITERATIONS=4 5 | 6 | # Check if a threshold was provided as a command-line argument 7 | if [ -z "$1" ]; then 8 | echo "Error: No threshold provided." 9 | exit 1 10 | fi 11 | 12 | # Set the threshold value from the first command-line argument 13 | THRESHOLD=$1 14 | 15 | # Function to get disk utilization (trims percentage symbol) 16 | get_disk_util() { 17 | iostat -xmyh 1 1 $(findmnt $HOME | awk '{ print $2 }' | tail -n1 | cut -d[ -f1) | awk 'NR == 17 {print $(NF-1)}' | tr -d '%' 18 | } 19 | 20 | # Initialize variables to store total utilization and individual values 21 | total_util=0 22 | util_values=() 23 | 24 | # Loop to gather disk utilization multiple times 25 | for (( i=1; i<=$ITERATIONS; i++ )) 26 | do 27 | # Get the current disk utilization and add it to the array 28 | current_util=$(get_disk_util) 29 | util_values+=("$current_util") 30 | 31 | # Add the current utilization to the total 32 | total_util=$(echo "$total_util + $current_util" | bc -l) 33 | 34 | # Optional: Sleep for 1 second before the next iteration 35 | # sleep 1 36 | done 37 | 38 | # Calculate the average utilization 39 | average_util=$(echo "$total_util / $ITERATIONS" | bc -l) 40 | 41 | # Log the individual disk utilization readings and the calculated average 42 | echo "Disk utilization readings (over $ITERATIONS iterations):" 43 | for (( i=0; i<${#util_values[@]}; i++ )) 44 | do 45 | echo "Utilization $(($i+1)): ${util_values[$i]}%" 46 | done 47 | echo "Average utilization: $average_util%" 48 | echo "Threshold: $THRESHOLD%" 49 | 50 | # Compare the average disk utilization with the threshold 51 | if (( $(echo "$average_util > $THRESHOLD" | bc -l) )); then 52 | # Log message and return 1 if average disk utilization is higher than the threshold 53 | echo "Average utilization ($average_util%) exceeds the threshold ($THRESHOLD%). Exiting with status 1." 54 | exit 1 55 | else 56 | # Log message and return 0 if average disk utilization is lower than or equal to the threshold 57 | echo "Average utilization ($average_util%) is below the threshold ($THRESHOLD%). Exiting with status 0." 58 | exit 0 59 | fi -------------------------------------------------------------------------------- /scripts/freebandwidth-hbd/README.md: -------------------------------------------------------------------------------- 1 | # freebandwidth-hbd 2 | 3 | This is a freebandwidth script that only works for HBD Shared App Slots. 4 | 5 | ```shell 6 | touch ~/freebandwidth.sh && chmod +x ~/freebandwidth.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | If the script sees that there is enough network bandwidth available, it will return exit code 0 and autobrr will push the torrent to the download client. 14 | 15 | If available bandwidth falls below your limit, the script will return exit code 1 and autobrr will skip it. 16 | 17 | This script uses a command line argument so that you can pass the `100G` or `1T` variable from autobrr. 18 | It adds a 10gb buffer to this value and then calculates if you have enough bandwidth. 19 | 20 | Returns 0 if has bandwidth available, else returns 1. 21 | -------------------------------------------------------------------------------- /scripts/freebandwidth-hbd/freebandwidth.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | threshold=$(numfmt --from=iec ${1:-0}) # Defaults 0 if missing the argument 5 | required_data=$((threshold + 10000000000)) # Add 10gb to keep small buffer 6 | required_data_fmt=$(numfmt --to=iec --format='%.3f' $required_data) 7 | echo "Needs this much of bandwidth: $required_data_fmt" 8 | 9 | # Get the available bandwidth via `sudo box bw`, strip ascii modifiers via regex 10 | box_bw=$(TERM=xterm sudo box bw | sed 's/\x1b\[[^m]*m//g; s/\x1b(B//g; s/\x1b\[0m//g') 11 | total_data_fmt=$(grep 'Total' <<< $box_bw | awk '{print $3}') 12 | used_data_fmt=$(grep 'Used' <<< $box_bw | awk '{print $3}') 13 | available_data_fmt=$(grep 'Remaining' <<< $box_bw | awk '{print $3}') 14 | available_data=$(numfmt --from=iec $available_data_fmt) 15 | 16 | echo "---These values are rounded down---" 17 | echo "Total Bandwidth: $total_data_fmt" 18 | echo "Used Bandwidth: $used_data_fmt" 19 | echo "Available Bandwidth: $available_data_fmt" 20 | 21 | # Check if the available bandwidth is greater than or equal to the required bandwidth 22 | if [ "$available_data" -ge "$required_data" ]; then 23 | echo "Has enough bandwidth available." 24 | else 25 | echo "Insufficient bandwidth: $available_data_fmt available, needed: $required_data_fmt." 26 | exit 1 27 | fi 28 | 29 | exit 0 30 | -------------------------------------------------------------------------------- /scripts/freespace-docker/README.md: -------------------------------------------------------------------------------- 1 | # freespace-docker 2 | 3 | This is a generic freespace script that works in the autobrr docker container. We place it in `/config` which you already have mounted. 4 | 5 | ```shell 6 | mkdir -p /config/scripts && touch /config/scripts/freespace.sh && chmod +x /config/scriptsfreespace.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | If the script sees that there is enough space available, it will return exit code 0 and autobrr will push the torrent to the download client. 14 | 15 | If free space falls below your limit, the script will return exit code 1 and autobrr will skip it. 16 | 17 | Adjust `reqSpace` to fit your needs. -------------------------------------------------------------------------------- /scripts/freespace-docker/freespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | reqSpace=250000000 # 250GB 5 | SPACE=$(df "/torrents" | awk 'END{print $4}') 6 | if [ "$SPACE" -le $reqSpace ] 7 | then 8 | echo "not enough space" 9 | echo "free $SPACE" 10 | exit 1 11 | fi 12 | echo "got space" 13 | echo "free $SPACE" 14 | exit 0 -------------------------------------------------------------------------------- /scripts/freespace-generic/README.md: -------------------------------------------------------------------------------- 1 | # freespace-generic 2 | 3 | This is a generic freespace script that should work in most environments. 4 | 5 | ```shell 6 | touch ~/freespace.sh && chmod +x ~/freespace.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | If the script sees that there is enough space available, it will return exit code 0 and autobrr will push the torrent to the download client. 14 | 15 | If free space falls below your limit, the script will return exit code 1 and autobrr will skip it. 16 | 17 | Adjust `reqSpace` to fit your needs. -------------------------------------------------------------------------------- /scripts/freespace-generic/freespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | reqSpace=100000000 # 100GB 5 | SPACE=`df "$HOME/torrents" | awk 'END{print $4}'` 6 | if [[ $SPACE -le reqSpace ]] 7 | then 8 | #echo "not enough space" 9 | #echo "free $SPACE" 10 | exit 1 11 | fi 12 | #echo "got space" 13 | #echo "free $SPACE" 14 | exit 0 -------------------------------------------------------------------------------- /scripts/freespace-hbd/README.md: -------------------------------------------------------------------------------- 1 | # freespace-hbd 2 | 3 | This is a freespace script that only works for HBD Shared App Slots. 4 | 5 | ```shell 6 | touch ~/freespace.sh && chmod +x ~/freespace.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | If the script sees that there is enough space available, it will return exit code 0 and autobrr will push the torrent to the download client. 14 | 15 | If free space falls below your limit, the script will return exit code 1 and autobrr will skip it. 16 | 17 | This script uses a command line argument so that you can pass the `{{.Size}}` variable from autobrr. 18 | It adds a 10gb buffer to this value and then calculates if you have enough space. 19 | 20 | Returns 0 if enough space, else returns 1. -------------------------------------------------------------------------------- /scripts/freespace-hbd/freespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | readonly BILLION=1000000000 5 | 6 | required_space=$(($1 + 10000000000)) #Add 10gb to keep small buffer 7 | echo "Needs this much space: $((required_space / BILLION))GB" 8 | 9 | # Get the available disk space via quota, remove non-numericals via regex 10 | total_space=$(quota -s -u $(whoami) | grep "/dev/" | awk '{print $4}' | sed 's/[^0-9]*//g') 11 | used_space=$(quota -s -u $(whoami) | grep "/dev/" | awk '{print $2}' | sed 's/[^0-9]*//g') 12 | available_space=$(( (total_space - used_space) * BILLION)) 13 | 14 | echo "---These values are rounded down---" 15 | echo "Total Space: $total_space GB" 16 | echo "Used Space: $used_space GB" 17 | echo "Available Space: $((available_space / BILLION))GB" 18 | 19 | # Check if the available space is greater than or equal to the required space 20 | if [ "$available_space" -ge "$required_space" ]; then 21 | echo "Disk has enough space." 22 | else 23 | echo "Insufficient disk space: $available_space bytes available, needed: $required_space bytes." 24 | exit 1 25 | fi 26 | exit 0 -------------------------------------------------------------------------------- /scripts/not_after/README.md: -------------------------------------------------------------------------------- 1 | # not_after 2 | 3 | This is a script for Linux shell. 4 | 5 | ```shell 6 | touch ~/not_after.sh && chmod +x ~/not_after.sh 7 | ``` 8 | 9 | Then open the file and paste the contents. 10 | 11 | ## Description 12 | 13 | Returns 1 if the current date/time is past the date/time you gave on the command line. 14 | 15 | Use it in External filters if you want autobrr to reject everything after a given date/time. 16 | 17 | For example in a limited global freeleech, you don't want to download anything after FL ends. 18 | 19 | External / add External Filter 20 | 21 | Type = Exec 22 | 23 | Path to executable = ~/not_after.sh 24 | 25 | Exec arguments = "2024-12-31" "22:30:00" 26 | 27 | Test in your shell: 28 | ./not_after.sh "2024-12-25" "12:00:00" && echo 'current date before the given date' || echo 'current date after the given date' 29 | -------------------------------------------------------------------------------- /scripts/not_after/not_after.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Check if a date argument is provided 4 | if [ -z "$1" ]; then 5 | echo "Usage: $0 [