-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cliproxyapi): bundle backup scripts to fix service failure #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,15 @@ let | |||||||
| aws = "${pkgs.awscli2}/bin/aws"; | ||||||||
| sed = "${pkgs.gnused}/bin/sed"; | ||||||||
| }; | ||||||||
|
|
||||||||
| # Bundle all backup scripts together | ||||||||
| backupScripts = pkgs.runCommand "backup-scripts" { } '' | ||||||||
| mkdir -p $out | ||||||||
| cp ${./scripts/backup-and-recover.sh} $out/backup-and-recover.sh | ||||||||
| cp ${./scripts/backup-auth.sh} $out/backup-auth.sh | ||||||||
| cp ${./scripts/recover-auth.sh} $out/recover-auth.sh | ||||||||
| chmod +x $out/*.sh | ||||||||
| ''; | ||||||||
| in | ||||||||
| { | ||||||||
| # Main cliproxyapi service | ||||||||
|
|
@@ -64,7 +73,7 @@ in | |||||||
| config = { | ||||||||
| ProgramArguments = [ | ||||||||
| "${pkgs.bash}/bin/bash" | ||||||||
| "${./scripts/backup-and-recover.sh}" | ||||||||
| "${backupScripts}/backup-and-recover.sh" | ||||||||
| ]; | ||||||||
| StartInterval = 300; # Run every 5 minutes | ||||||||
| RunAtLoad = true; | ||||||||
|
|
@@ -93,7 +102,14 @@ in | |||||||
| }; | ||||||||
| Service = { | ||||||||
| Type = "oneshot"; | ||||||||
| ExecStart = "${pkgs.bash}/bin/bash ${./scripts/backup-and-recover.sh}"; | ||||||||
| ExecStart = "${pkgs.bash}/bin/bash ${backupScripts}/backup-and-recover.sh"; | ||||||||
| Environment = "PATH=${ | ||||||||
| lib.makeBinPath [ | ||||||||
| pkgs.bash | ||||||||
| pkgs.awscli2 | ||||||||
| pkgs.coreutils | ||||||||
|
Comment on lines
+106
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The backup service now overrides PATH to only awscli2/coreutils, but Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The PATH environment variable is missing Prompt for AI agents
Suggested change
✅ Addressed in |
||||||||
| ] | ||||||||
| }"; | ||||||||
| }; | ||||||||
| }; | ||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this correctly points the
launchdservice to the bundled script, it's missing the necessaryPATHenvironment variable for the commands within the scripts to be found on macOS. The backup scripts use commands likeaws,ls, anddate, which are provided bypkgs.awscli2andpkgs.coreutils. Without setting thePATH, this service is likely to fail on macOS, similar to the original problem on Linux.To fix this, you should add an
Environmentattribute to theconfigblock for thislaunchdagent, similar to how you've done for thesystemdservice. It should set aPATHthat includes the binaries fromawscli2andcoreutils.