taylorthurlow / panda-motd

a utility for generating a more useful MOTD
MIT License
134 stars 6 forks source link

Add runit init system support #6

Closed Br1ght0ne closed 6 years ago

Br1ght0ne commented 6 years ago

The tests need some more work, going to finish soon. Also, the command needs to be run with sudo, so automation is difficult for now.

taylorthurlow commented 6 years ago

Sweet, thanks for contributing. As far as sudo privileges are concerned, I think it's pretty typical that MOTD scripts are run as root. At least that's the case with Ubuntu. So I think it's probably safe to assume that any system calls will be run as root.

Br1ght0ne commented 6 years ago

You're right, I can omit sudo. Thanks!

Br1ght0ne commented 6 years ago

By the way, as I understand, config.rb here puts config file in a directory relative to Dir.home. Does that equal to "/root" when ran with sudo? As irb is concerned, it is.

taylorthurlow commented 6 years ago

Funny you ask about this. I'm actually in the process of figuring out exactly how all that works, and you're correct. At least in the case of Ubuntu, the environment that the /etc/update-motd.d scripts are run in is run as root, but it seems like the $HOME variable is not set during execution.

We could either move the config file to /root/.config/panda-motd.yaml, which I guess works, but seems weird. On top of that, the /root/.config directory probably doesn't exist already (for a good reason, I imagine). I think the best thing to do would be to allow a command line flag, or even a mandatory argument, to supply the config file, and read it from there instead.

In the meantime I've got it all working temporarily by copying my config to /root/.config/panda-motd.yaml, and making my update-motd.d script something like this:

HOME=/root panda-motd 2> /var/log/panda-motd.error.log

I'll keep you updated on this one.

taylorthurlow commented 6 years ago

Okay I fixed it. You now need to run the executable with a single config file argument. Check the README for an example update-motd.d script.

Br1ght0ne commented 6 years ago

This implementation is far out of date, and it should be more robust. I'm currently on OpenRC, and adding support for it is not that hard. So, I'm closing this PR for now, and I'm maybe going to rethink how to do this better.