This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

services.flix: throttle downloads when /var/download runs low

Adds download-space-guard: a 5-min oneshot that caps sabnzbd and
transmission speeds once free space on /var/download drops below 100 GiB,
and pauses sabnzbd below a 15 GiB floor. This prevents a full disk from
hard-wedging sabnzbd with an unrecoverable "Disk full! Forcing Pause";
the guard auto-resumes once space frees up.

Assisted-by: Claude Code (claude-opus-4-8)

+53
+53
2configs/services/flix/default.nix
··· 140 140 ''; 141 141 }; 142 142 143 + # throttle downloads when /var/download runs low, so a full disk can no 144 + # longer hard-wedge sabnzbd with an unrecoverable "Disk full! Forcing Pause". 145 + # below THRESH GiB free: cap sabnzbd + transmission to a trickle. 146 + # below FLOOR GiB free: pause sabnzbd entirely (auto-resumes when space frees). 147 + systemd.services.download-space-guard = { 148 + wantedBy = [ "multi-user.target" ]; 149 + after = [ "sabnzbd.service" ]; 150 + startAt = "*:0/5"; 151 + path = [ 152 + pkgs.curl 153 + pkgs.coreutils 154 + pkgs.gnugrep 155 + pkgs.gawk 156 + pkgs.transmission_4 157 + ]; 158 + script = '' 159 + set -efu 160 + DIR=/var/download 161 + THRESH=100 162 + FLOOR=15 163 + 164 + avail=$(df -Pk "$DIR" | awk 'NR==2 {print int($4 / 1024 / 1024)}') 165 + 166 + key=$(grep -E '^api_key' /var/lib/sabnzbd/sabnzbd.ini | head -1 | cut -d= -f2 | tr -d ' ') 167 + sab() { 168 + curl -fsS --max-time 15 "http://127.0.0.1:8080/api?output=json&apikey=$key&$1" >/dev/null 169 + } 170 + tr_remote() { 171 + transmission-remote 128.0.0.1:9091 "$@" >/dev/null || : 172 + } 173 + 174 + if [ "$avail" -lt "$FLOOR" ]; then 175 + echo "free ''${avail}G < ''${FLOOR}G floor: pausing sabnzbd, throttling transmission to 500 KB/s" 176 + sab "mode=pause" 177 + tr_remote -d 500 178 + elif [ "$avail" -lt "$THRESH" ]; then 179 + echo "free ''${avail}G < ''${THRESH}G: throttling sabnzbd to 5 MB/s, transmission to 2 MB/s" 180 + sab "mode=resume" 181 + sab "mode=config&name=speedlimit&value=5M" 182 + tr_remote -d 2000 183 + else 184 + echo "free ''${avail}G >= ''${THRESH}G: removing download speed limits" 185 + sab "mode=resume" 186 + sab "mode=config&name=speedlimit&value=0" 187 + tr_remote -D 188 + fi 189 + ''; 190 + serviceConfig = { 191 + Type = "oneshot"; 192 + User = "root"; 193 + }; 194 + }; 195 + 143 196 security.acme.defaults.email = "spam@krebsco.de"; 144 197 security.acme.acceptTerms = true; 145 198 security.acme.certs."yellow.r".server = config.krebs.ssl.acmeURL;