run temp instance of sabnzbd to generate config file

This commit is contained in:
Richard Carter
2024-05-07 04:49:26 -04:00
parent 3594605256
commit e96666189b
+32 -24
View File
@@ -28,12 +28,20 @@ with lib; let
}: }:
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "set-sabnzbd-ini-values"; name = "set-sabnzbd-ini-values";
runtimeInputs = with pkgs; [initool]; runtimeInputs = with pkgs; [initool sabnzbd sudo coreutils];
text = with lib.strings; ( text = with lib.strings; (
# set download dirs # set download dirs
'' ''
if [ ! -f ${sabnzbd-state-dir}/sabnzbd.ini ]; then if [ ! -f ${sabnzbd-state-dir}/sabnzbd.ini ]; then
exit 0 sudo -u usenet -g media sabnzbd -p -d -f ${sabnzbd-state-dir}/sabnzbd.ini
sab_pid=$!
until [ -f "${sabnzbd-state-dir}/sabnzbd.ini" ]
do
sleep 1
done
kill -INT $sab_pid
fi fi
initool set ${sabnzbd-state-dir}/sabnzbd.ini "" __comment__ '${edited-flag}' \ initool set ${sabnzbd-state-dir}/sabnzbd.ini "" __comment__ '${edited-flag}' \
@@ -169,28 +177,28 @@ in {
) )
]; ];
ExecStartPost = mkBefore [ # ExecStartPost = mkBefore [
( # (
"+" + pkgs.writeShellApplication { # "+" + pkgs.writeShellApplication {
name = "ensure-sabnzbd-config-edits"; # name = "ensure-sabnzbd-config-edits";
runtimeInputs = with pkgs; [initool coreutils systemd]; # runtimeInputs = with pkgs; [initool coreutils systemd];
text = '' # text = ''
until [ -f "${cfg.stateDir}/sabnzbd.ini" ] # until [ -f "${cfg.stateDir}/sabnzbd.ini" ]
do # do
sleep 1 # sleep 1
done # done
#
if ! initool get "${cfg.stateDir}/sabnzbd.ini" "" __comment__; then # if ! initool get "${cfg.stateDir}/sabnzbd.ini" "" __comment__; then
# force sabnzbd.service restart for ExecStartPre to run now # # force sabnzbd.service restart for ExecStartPre to run now
# that sabnzbd.ini has been created by the instance # # that sabnzbd.ini has been created by the instance
systemctl restart -f sabnzbd.service # systemctl restart -f sabnzbd.service
fi # fi
#
exit # exit
''; # '';
} + "/bin/ensure-sabnzbd-config-edits" # } + "/bin/ensure-sabnzbd-config-edits"
) # )
]; # ];
Restart = "on-failure"; Restart = "on-failure";
StartLimitInterval = 15; StartLimitInterval = 15;
StartLimitBurst = 5; StartLimitBurst = 5;