Closed Br1ght0ne closed 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.
You're right, I can omit sudo
. Thanks!
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.
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.
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.
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.
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.