feat: add check-autobrr-space script to autobrr
All checks were successful
ci / treefmt (push) Successful in 1m40s
All checks were successful
ci / treefmt (push) Successful in 1m40s
This commit is contained in:
parent
2304b7899a
commit
d073496c19
1 changed files with 38 additions and 5 deletions
|
|
@ -36,16 +36,49 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
services.autobrr.serviceConfig = let
|
||||
services.autobrr = let
|
||||
autobrrUser = config.users.users.autobrr;
|
||||
|
||||
checkAutobrrSpace = pkgs.writeShellScriptBin "check-autobrr-space" ''
|
||||
set -euo pipefail
|
||||
|
||||
required_space=$((250 * 1024 * 1024))
|
||||
path="/var/lib/qBittorrent/qBittorrent/downloads/autobrr"
|
||||
|
||||
available_space=$(${pkgs.coreutils}/bin/df "$path" | \
|
||||
${pkgs.gawk}/bin/awk 'END {print $4}')
|
||||
|
||||
[ "$available_space" -gt "$required_space" ]
|
||||
'';
|
||||
in {
|
||||
DynamicUser = mkForce false;
|
||||
User = autobrrUser.name;
|
||||
Group = autobrrUser.group;
|
||||
UMask = mkForce "0002";
|
||||
path = [checkAutobrrSpace];
|
||||
serviceConfig = {
|
||||
DynamicUser = mkForce false;
|
||||
User = autobrrUser.name;
|
||||
Group = autobrrUser.group;
|
||||
UMask = mkForce "0002";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "check-autobrr-space" ''
|
||||
set -euo pipefail
|
||||
|
||||
required_space=$((250 * 1024 * 1024))
|
||||
path="/var/lib/qBittorrent/qBittorrent/downloads/autobrr"
|
||||
|
||||
available_space=$(${pkgs.coreutils}/bin/df "$path" | \
|
||||
${pkgs.gawk}/bin/awk 'END {print $4}')
|
||||
|
||||
if [ "$available_space" -le "$required_space" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
'')
|
||||
];
|
||||
|
||||
sops.secrets = {
|
||||
"autobrr" = {
|
||||
owner = config.users.users.autobrr.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue