LibreNMS Server Install Script

I created an installation script for LibreNMS for Ubuntu server 18.04 LTS. I figured I would post it here for others to use, if needed. This was done purely as a learning exercise. If you see something that needs fixed feel free to let me know, or use git hub to submit a fix.

Nifty!

The main problem I see is it uses hard-coded passwords for mysql and snmpd community.

Also, you can automate the steps that happen in the install.php web ui.

Check the official docker if you want to see an example of automated install.

Thanks for the tips. Iā€™ll work on adding some automation, esp. for the password.

1 Like

I need to run only this ā†’ install.sh ?

Greetings

###########################################################
Adding libreNMS user to the www-data group
###########################################################
Setting permissions and file access controls
###########################################################
running PHP installer script as librenms user
###########################################################
Could not scan for classes inside "vendor/dapphp/radius" which does not appear to be a file nor a folder
> LibreNMS\ComposerHelper::preInstall
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - Root composer.json requires php ^7.3 || ^8.0 but your php version (7.2.24) does not satisfy that requirement.
  Problem 2
    - laravel/framework is locked to version v8.80.0 and an update of this package was not requested.
    - laravel/framework v8.80.0 requires php ^7.3|^8.0 -> your php version (7.2.24) does not satisfy that requirement.
  Problem 3
    - laravel/serializable-closure is locked to version v1.0.5 and an update of this package was not requested.
    - laravel/serializable-closure v1.0.5 requires php ^7.3|^8.0 -> your php version (7.2.24) does not satisfy that requirement.
  Problem 4
    - laravel/ui is locked to version v3.4.1 and an update of this package was not requested.
    - laravel/ui v3.4.1 requires php ^7.3|^8.0 -> your php version (7.2.24) does not satisfy that requirement.
  Problem 5
    - ramsey/collection is locked to version 1.2.2 and an update of this package was not requested.
    - ramsey/collection 1.2.2 requires php ^7.3 || ^8 -> your php version (7.2.24) does not satisfy that requirement.
  Problem 6
    - laravel/framework v8.80.0 requires php ^7.3|^8.0 -> your php version (7.2.24) does not satisfy that requirement.
    - tightenco/ziggy 0.9.4 requires laravel/framework >=5.4@dev -> satisfiable by laravel/framework[v8.80.0].
    - tightenco/ziggy is locked to version 0.9.4 and an update of this package was not requested.

Why this during install.sh ?

###############################################################################################
Naviagte to http://192.168.100.215/install.php in you web browser to finish the installation.
###############################################################################################```

and if navigate to... 

The page is not working 192.168.100.215 is currently unable to handle the request.
HTTP ERROR 500

@Neo85 your PHP version is too oldā€¦ apparently the script does not check that before starting.

I have updated the script for Ubuntu 22.04. I have also added a fix for PHP issue.

Any update on 24.04 install? Or just bash thru it?

Hey Jeff,
I have update the script to 24.04, with help from skender85.

I have not had a chance to run through it. Was plan on it this weekend. Give it a go and let me know if there are any issue that need to be addresses. Appreciate the ping.

Thanks very much. Gonna give it a go. Will update on result.

Jeff

Are you sure this is the updated one?

So I did get it sorted out, my bad. But ran into an issue at the very end of install.sh The other thing is that canā€™t access the librenms webpage. Iā€™ll try a few other things and get back to you.

thanks very much for script. Pretty sure what didnā€™t work isnā€™t too hard to sort out.ā€™
Jeff

Executing: /usr/lib/systemd/systemd-sysv-install enable snmpd
Installing validation fix
error: externally-managed-environment

Ɨ This environment is externally managed
ā•°ā”€> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
###############################################################################################
Naviagte to LibreNMS Install in you web browser to finish the installation.
./install.sh: line 189: unexpected EOF while looking for matching `"ā€™

Seems there maybe a package install issue. It could be a versioning issue or something got ā€œFat Fingeredā€ lol. If you find the cause let me know. I will take a browse trough the script this evening and see if I can spot the error.

Regards,
Jeff :slight_smile:

I have reviewed the script. I have removed the Validation Fix. It is not needed.
I fixed some typos, and can reach the site at the IP. I am currently troubleshooting an issue with the domain name not working.

I am getting an ā€œerror: externally-managed-environmentā€ for the PHP installer. It has something to do with pip and the Python virtual environment. I will try and track it down. Script is provided by LibreNMS, so not sure I will be ale to fix it.

The error doesnā€™t seem to be affecting the site, but I have not used the site fully to know.

Regards,

Ok so apparently the pip packages listed in ā€œ/opt/librenms/requirements.txtā€ are managed by apt, external to pip.
So we just need to install them.
python3-pymysql ā† add
python3-dotenv ā† Installed at the beginning
python3-redis ā† Installed at the beginning
python3-setuptools ā† installed at the beginning
python3-psutil ā† add
python3-command-runner ā† add

regards,

This was a DNS issue. all the issues have been resolved. and the config validation checks out.

I will run through it one last time and then send the commit to github.

Regards,

The script has been fixed and is updated to the latest version on Github.
let me know if you run into any other issues.

Thanks for the update, others will find this useful.

I however ran into a weird issue. After the install I was able to go the webpage page /install and finish it just fine. I was prompted to add 1st device which I did (snmpv3 poll on a router) then that was it. No more access to webpage. http 500 error.

I havenā€™t yet messed with the nginx yet but the log does show the deny occurring. Very strange as it was working then it was notā€¦

location ~ /. {
deny all;
}
location ^~ /.well-known/ {

allow all;

}

Iā€™m not sure yet if I want to make any rash changes as of yet. Little more research is in order.

I forgot to add that I would have replied sooner but the community forum blocks more than 3 or 4 replies in 24 hours to cut down on spamming from new user accounts.

One more edit lol. What is the code tag on this forum so the post show up properly?

thanks,
Jeff

Hey Jeff,
I am not sure what happened in your case. I have a running LNMS instance on proxmox using the script. I was able to add 2 servers to it using SNMP 2C. Took approx. 2 mins for them to add to the system, but they did. The first node was the NMS its self. The second was an ESXi server. On a side node, did you run the Validation after install? (settings > validate config)

I will spin up another instance, and see what happens.

Regards,
Jeff