fix: added required space arg to check-autobrr-space command
All checks were successful
ci / treefmt (push) Successful in 1m39s
All checks were successful
ci / treefmt (push) Successful in 1m39s
This commit is contained in:
parent
2b20a88c06
commit
380f6473a9
1 changed files with 17 additions and 4 deletions
|
|
@ -41,13 +41,26 @@ in {
|
|||
checkAutobrrSpace = pkgs.writeShellScriptBin "check-autobrr-space" ''
|
||||
set -euo pipefail
|
||||
|
||||
required_space=$((1024 * 1024 * 1024)) # 1 Tb
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Error: Missing argument" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
parse_space() {
|
||||
local space="''${1^^}"
|
||||
space="''${space%B}"
|
||||
${pkgs.coreutils}/bin/numfmt --from=iec "$space"
|
||||
}
|
||||
|
||||
required_space=$(parse_space "$1")
|
||||
torrent_size="$2"
|
||||
path="/mnt/nfs/servarr/torrents"
|
||||
|
||||
available_space=$(${pkgs.coreutils}/bin/df "$path" | \
|
||||
${pkgs.gawk}/bin/awk 'END {print $4}')
|
||||
available_space=$(${pkgs.coreutils}/bin/df --output=avail -B1 "$path" | \
|
||||
${pkgs.gawk}/bin/awk 'END {print $1}')
|
||||
remaining_space=$((available_space - torrent_size))
|
||||
|
||||
[ "$available_space" -gt "$required_space" ]
|
||||
[ "$remaining_space" -gt "$required_space" ]
|
||||
'';
|
||||
in {
|
||||
path = [checkAutobrrSpace];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue