mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/healthchecks: automatically invoke sudo in the wrapper
much like nextcloud-occ does
This commit is contained in:
parent
a3c39df9e8
commit
897044e435
1 changed files with 6 additions and 6 deletions
|
@ -15,14 +15,14 @@ let
|
||||||
|
|
||||||
environmentFile = pkgs.writeText "healthchecks-environment" (lib.generators.toKeyValue { } environment);
|
environmentFile = pkgs.writeText "healthchecks-environment" (lib.generators.toKeyValue { } environment);
|
||||||
|
|
||||||
healthchecksManageScript = with pkgs; (writeShellScriptBin "healthchecks-manage" ''
|
healthchecksManageScript = pkgs.writeShellScriptBin "healthchecks-manage" ''
|
||||||
|
sudo=exec
|
||||||
if [[ "$USER" != "${cfg.user}" ]]; then
|
if [[ "$USER" != "${cfg.user}" ]]; then
|
||||||
echo "please run as user 'healtchecks'." >/dev/stderr
|
sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} --preserve-env --preserve-env=PYTHONPATH'
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
export $(cat ${environmentFile} | xargs);
|
export $(cat ${environmentFile} | xargs)
|
||||||
exec ${pkg}/opt/healthchecks/manage.py "$@"
|
$sudo ${pkg}/opt/healthchecks/manage.py "$@"
|
||||||
'');
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.healthchecks = {
|
options.services.healthchecks = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue