Skip to content
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

nixos/unifi: use systemd tmpfiles instead of preStart #78419

Merged
merged 1 commit into from Jan 29, 2020

Conversation

utsl42
Copy link
Contributor

@utsl42 utsl42 commented Jan 24, 2020

Motivation for this change

I installed unifi on 19.09, and noticed that the unifi service would not start. After investigating for a bit, I concluded that the preStart script was silently failing to set up the /var/lib/unifi directory.

Things done

My tests for this change included:

  1. Removing unifi completely, rm -rf /var/lib/unifi, and installing again.
  2. Switching from unifiLTS to unifi, and verifying that the switch updates the symlink at /var/lib/unifi/webapps/ROOT
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@aanderse
Copy link
Member

Is anything ever written to ${stateDir}/webapp? Maybe we should make the permissions on that 0500 to ensure it remains pure? 🤔 if that would work...

What do you think about that?

@utsl42
Copy link
Contributor Author

utsl42 commented Jan 26, 2020

Is anything ever written to ${stateDir}/webapp? Maybe we should make the permissions on that 0500 to ensure it remains pure? 🤔 if that would work...

What do you think about that?

I really don't know if anything is written there. My guess is no, but given that I'm brand new to NixOS, I figured I'd try a minimal change. ;)

I'm more concerned that it seems that upgrading unifi will redo the symlink (which is good), but not restart the systemd unit, leaving it in a state where the old backend is running, but with upgraded html.

But at least this change makes it so it will start up. I don't know how much of a pain it is, but given that this is broken for new installs of unifi, I'd favor backporting to 19.09.

@aanderse
Copy link
Member

@utsl42 do you need both and e and a d entry, or is d alone sufficient?

@peterhoeg @M-Gregoire how does this look to you?

@utsl42
Copy link
Contributor Author

utsl42 commented Jan 29, 2020

The directory needs to exist, and have the right permissions for the unifi unit to start. So I think d is the right one to use. At any rate, after this change, I can reliably uninstall unifi, rm -rf /var/lib/unifi, reinstall, and have it come up. Couldn't do that before.

@aanderse
Copy link
Member

aanderse commented Jan 29, 2020

Thanks for the fix @utsl42 🎉

@aanderse aanderse merged commit 7adffb1 into NixOS:master Jan 29, 2020
@M-Gregoire
Copy link
Member

Awesome, thank you @utsl42 !

anna328p pushed a commit to anna328p/nixpkgs that referenced this pull request Feb 2, 2020
nixos/unifi: use systemd tmpfiles instead of preStart
@utsl42 utsl42 deleted the fix-unifi-install branch March 30, 2020 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants