COMPLETE: Add chown and validate.php to daily.sh

Sorry if this sounds like it’s coming from a position of ignorance, but we just started testing librenms.
I noticed after I run ./validate.php it almost ALWAYS says that my local git is out of date, and recommends and update.
When I run ./daily.sh it downloads some stuff, but I have to run the chown command to fix the permissions.

On my daily.sh I added (and call) a function to set the permissions afterward, and then to again call .validate.php.

This seems to work for me, but when I run it, it gives me another warning because I’ve had locally edited files and says

[WARN] Your local git contains modified files, this could prevent automatic updates.

I’m curious if there’s a way this type of functionality could be added daily.sh to allow it to be done in a single command?

Thanks in advance…
I included my code below, but mine is just junky ‘Works for me’ code.

set_ownership(){
status_run “Updating Ownership” “chown -R librenms:librenms /opt/librenms”;
}


main "$@"
set_ownership
./validate.php

This pull request is working towards stopping you running daily.sh as a non-librenms user.

I’m not sure we should run chown automatically as people are free to customise their installs.

However the short of this, when you are in /opt/librenms - be the librenms user rather than anyone else, especially root.

1 Like

If you run ./daily.sh as the librenms user, you will not have to fix permissions afterwards.
It tells you your git is out of date because it is, but this is only a warning. It also prints a date, if this is within the last day, everything is working fine. Things get merged upstream almost every day during the week.

We cannot add chown to the daily.sh script because:
a) it is run by the librenms user, so this will fail. (It works for you because you are running it as root)
b) not all users run librenms as a dedicated users, although this should be almost none hopefully

I may have an idea to allow you to run ./daily.sh as root, but please run it as the librenms user for now.

1 Like

Thank you both for the replies. I will change the way I’m running the daily.sh. I just happened to be sudo’d when I ran it because I was still setting it all up. I won’t do it again :slight_smile:

Murrant,

what are you thinking?

Already done. daily.sh uses su if applicable.

ah, Okay, I knew you added that, I wasn’t sure if you were talking about anything else

COMPLETE:

LibreNMS is already taking care of changing the user to librenms when needed.