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

initial PR for librenms #1704

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ct/librenms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: svennd
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.librenms.org/

# App Default Values
APP="LibreNMS"
var_tags="monitor;foss"
var_cpu="2"
var_ram="2048"
var_disk="4"
var_os="debian"
var_version="12"
var_unprivileged="1"

# App Output & Base Settings
header_info "$APP"
base_settings

# Core
variables
color
catch_errors

function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/librenms ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_ok "${APP} automatically updated!"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app updates on its own without user input?

exit
}

start
build_container
description

msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"
140 changes: 140 additions & 0 deletions install/librenms-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/usr/bin/env bash

svennd marked this conversation as resolved.
Show resolved Hide resolved

# Copyright (c) 2021-2025 community-scripts ORG
# Author: SvennD
# License: MIT
MickLesk marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE


source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os

# dependencies
msg_info "Installing Dependencies"
$STD apt-get install -y \
lsb-release ca-certificates wget acl curl fping git graphviz imagemagick \
mariadb-client mariadb-server \
mtr-tiny nginx-full nmap \
php8.2-{bcmath,common,ctype,curl,fileinfo,gmp,fpm,gd,iconv,intl,mbstring,mysql,soap,xml,xsl,zip,cli,snmp} \
python3-{dotenv,pymysql,redis,setuptools,systemd,pip}\
rrdtool snmp snmpd unzip whois\
composer\
sudo

# system user is required
$STD useradd librenms -d /opt/librenms -M -r

# set timezone
$STD timedatectl set-timezone Etc/UTC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formating?

msg_ok "Installed Dependencies"


msg_info "php config"
# do a move since we don't need www pool
mv /etc/php/8.2/fpm/pool.d/www.conf /etc/php/8.2/fpm/pool.d/librenms.conf
sed -i -e "s|^\[www\]|\[librenms\]|" \
-e "s|^listen = /run/php/php8.2-fpm.sock|listen = /run/php/librenms.sock|" \
-e "s|^user = www-data|user = librenms|" \
-e "s|^group = www-data|group = librenms|" /etc/php/8.2/fpm/pool.d/librenms.conf

# set timezone
sed -i 's/^;date\.timezone =/date.timezone = Etc\/UTC/' /etc/php/8.2/fpm/php.ini

systemctl restart php8.2-fpm
msg_ok "php config"

msg_info "download librenms"
cd /opt
$STD git clone https://github.com/librenms/librenms.git --depth 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No git clone if possible. Download latest release. have a look at the guides in the wiki.

chown -R librenms:librenms /opt/librenms && chmod 771 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
$STD sudo -u librenms /opt/librenms/scripts/composer_wrapper.php install --no-dev

# cron
cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms

# scheduler
cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
$STD systemctl enable librenms-scheduler.timer
$STD systemctl start librenms-scheduler.timer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$STD systemctl enable librenms-scheduler.timer
$STD systemctl start librenms-scheduler.timer
systemctl enable -q —now librenms-scheduler.timer


msg_ok "download librenms"

# database stuff
msg_info "Setting up database"
DB_NAME=librenms_db
DB_USER=librenms
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
mysql -u root -e "CREATE DATABASE $DB_NAME;"
mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{
echo "librenms-Credentials"
echo "librenms Database User: $DB_USER"
echo "librenms Database Password: $DB_PASS"
echo "librenms Database Name: $DB_NAME"
} >> ~/librenms.creds

cd /opt/librenms
IPADDRESS=$(hostname -I | awk '{print $1}')

sed -i -e "s|^#APP_URL=.*|APP_URL=http://$IPADDRESS|" \
-e "s|^#DB_DATABASE=.*|DB_DATABASE=$DB_NAME|" \
-e "s|^#DB_USERNAME=.*|DB_USERNAME=$DB_USER|" \
-e "s|^#DB_PASSWORD=.*|DB_PASSWORD=$DB_PASS|" .env

# requested by librenms
echo innodb_file_per_table=1 >> /etc/mysql/mariadb.conf.d/50-server.cnf
echo lower_case_table_names=0 >> /etc/mysql/mariadb.conf.d/50-server.cnf

# restart to activate
systemctl restart mariadb

msg_ok "Set up database"

msg_info "configure nginx"
cat <<EOF >/etc/nginx/conf.d/librenms.conf
server {
listen 80;
root /opt/librenms/html;
server_name $IPADDRESS;
index index.php;

location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}

location ~ \.php\$ {
include fastcgi.conf;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/librenms.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
rm /etc/nginx/sites-enabled/default
systemctl reload nginx
msg_ok "Configured Service"

msg_info "validation steps"
sudo ln -s /opt/librenms/lnms /usr/local/bin/lnms
sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
msg_ok "validation steps"

motd_ssh
customize

msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
39 changes: 39 additions & 0 deletions json/librenms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "LibreNMS",
"slug": "librenms",
"categories": [
9
],
"date_created": "2025-01-24",
"type": "ct",
"updateable": false,
"privileged": false,
"interface_port": 80,
"documentation": "https://docs.librenms.org",
"website": "https://www.librenms.org",
"logo": "https://raw.githubusercontent.com/librenms/librenms/33dbd98d7302091fdadcdbd66fec9d38808d82ce/html/images/librenms_logo_dark.svg",
"description": "LibreNMS, a fully featured network monitoring system that provides a wealth of features and device support.",
"install_methods": [
{
"type": "default",
"script": "ct/librenms.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 4,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "After install you can follow the web installer to complete the install.",
"type": "info"
}
svennd marked this conversation as resolved.
Show resolved Hide resolved
]
}
Loading