Skip to content

Commit 6fa77cf

Browse files
LibreNMS (#9148)
* 'Add new script' * Fix application name to 'LibreNMS' * Refactor LibreNMS installation script Updated the installation script for LibreNMS, changing the source URL and reorganizing the setup process for PHP, MariaDB, and Python dependencies. Removed cleanup commands and added a call to cleanup_lxc. --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ <[email protected]>
1 parent be383e9 commit 6fa77cf

File tree

4 files changed

+224
-0
lines changed

4 files changed

+224
-0
lines changed

ct/headers/librenms

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__ _ __
2+
/ / (_) /_ ________ ____ ____ ___ _____
3+
/ / / / __ \/ ___/ _ \/ __ \/ __ `__ \/ ___/
4+
/ /___/ / /_/ / / / __/ / / / / / / / (__ )
5+
/_____/_/_.___/_/ \___/_/ /_/_/ /_/ /_/____/
6+

ct/librenms.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: michelroegl-brunner
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://librenms.org
7+
8+
APP="LibreNMS"
9+
var_tags="${var_tags:-monitoring}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-2048}"
12+
var_disk="${var_disk:-4}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-13}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [ ! -d /opt/librenms ]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
msg_info "Updating LibreNMS"
31+
su librenms
32+
cd /opt/librenms
33+
./daily.sh
34+
msg_ok "Updated LibreNMS"
35+
exit
36+
}
37+
38+
start
39+
build_container
40+
description
41+
42+
msg_ok "Completed Successfully!\n"
43+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
44+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
45+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

frontend/public/json/librenms.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "LibreNMS",
3+
"slug": "librenms",
4+
"categories": [
5+
9
6+
],
7+
"date_created": "2025-03-24",
8+
"type": "ct",
9+
"updateable": false,
10+
"privileged": false,
11+
"interface_port": 80,
12+
"documentation": "https://docs.librenms.org/",
13+
"website": "https://librenms.org/",
14+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/librenms.webp",
15+
"config_path": "/opt/librenms/config.php and /opt/librenms/.env",
16+
"description": "LibreNMS is an open-source, community-driven network monitoring system that provides automatic discovery, alerting, and performance tracking for network devices. It supports a wide range of hardware and integrates with various notification and logging platforms.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/librenms.sh",
21+
"resources": {
22+
"cpu": 2,
23+
"ram": 2048,
24+
"hdd": 4,
25+
"os": "Debian",
26+
"version": "12"
27+
}
28+
}
29+
],
30+
"default_credentials": {
31+
"username": "admin",
32+
"password": "admin"
33+
},
34+
"notes": []
35+
}

install/librenms-install.sh

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: michelroegl-brunner
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://www.librenms.org/
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt install -y \
18+
acl \
19+
fping \
20+
graphviz \
21+
imagemagick \
22+
mtr-tiny \
23+
nginx \
24+
nmap \
25+
rrdtool \
26+
snmp \
27+
snmpd \
28+
whois
29+
msg_ok "Installed Dependencies"
30+
31+
msg_info "Installing Python Dependencies"
32+
$STD apt install -y \
33+
python3-dotenv \
34+
python3-pymysql \
35+
python3-redis \
36+
python3-setuptools \
37+
python3-systemd \
38+
python3-pip
39+
msg_ok "Installed Python Dependencies"
40+
41+
PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="gmp,mysql,snmp" setup_php
42+
setup_mariadb
43+
setup_composer
44+
PYTHON_VERSION="3.13" setup_uv
45+
MARIADB_DB_NAME="librenms" MARIADB_DB_USER="librenms" MARIADB_DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)" setup_mariadb_db
46+
fetch_and_deploy_gh_release "librenms" "librenms/librenms"
47+
48+
msg_info "Configuring LibreNMS"
49+
$STD useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
50+
mkdir -p /opt/librenms/{rrd,logs,bootstrap/cache,storage,html}
51+
cd /opt/librenms
52+
APP_KEY=$(openssl rand -base64 40 | tr -dc 'a-zA-Z0-9')
53+
$STD uv venv .venv
54+
$STD source .venv/bin/activate
55+
$STD uv pip install -r requirements.txt
56+
cat <<EOF >/opt/librenms/.env
57+
DB_DATABASE=${MARIADB_DB_NAME}
58+
DB_USERNAME=${MARIADB_DB_USER}
59+
DB_PASSWORD=${MARIADB_DB_PASS}
60+
APP_KEY=${APP_KEY}
61+
EOF
62+
chown -R librenms:librenms /opt/librenms
63+
chmod 771 /opt/librenms
64+
chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd
65+
msg_ok "Configured LibreNMS"
66+
67+
msg_info "Configure MariaDB"
68+
sed -i "/\[mysqld\]/a innodb_file_per_table=1\nlower_case_table_names=0" /etc/mysql/mariadb.conf.d/50-server.cnf
69+
systemctl enable -q --now mariadb
70+
msg_ok "Configured MariaDB"
71+
72+
msg_info "Configure PHP-FPM"
73+
cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/librenms.conf
74+
sed -i "s/\[www\]/\[librenms\]/g" /etc/php/8.4/fpm/pool.d/librenms.conf
75+
sed -i "s/user = www-data/user = librenms/g" /etc/php/8.4/fpm/pool.d/librenms.conf
76+
sed -i "s/group = www-data/group = librenms/g" /etc/php/8.4/fpm/pool.d/librenms.conf
77+
sed -i "s/listen = \/run\/php\/php8.4-fpm.sock/listen = \/run\/php-fpm-librenms.sock/g" /etc/php/8.4/fpm/pool.d/librenms.conf
78+
msg_ok "Configured PHP-FPM"
79+
80+
msg_info "Configure Nginx"
81+
IP_ADDR=$(hostname -I | awk '{print $1}')
82+
cat >/etc/nginx/sites-enabled/librenms <<'EOF'
83+
server {
84+
listen 80;
85+
server_name ${IP_ADDR};
86+
root /opt/librenms/html;
87+
index index.php;
88+
89+
charset utf-8;
90+
gzip on;
91+
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
92+
location / {
93+
try_files $uri $uri/ /index.php?$query_string;
94+
}
95+
location ~ [^/]\.php(/|$) {
96+
fastcgi_pass unix:/run/php-fpm-librenms.sock;
97+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
98+
include fastcgi.conf;
99+
}
100+
location ~ /\.(?!well-known).* {
101+
deny all;
102+
}
103+
}
104+
EOF
105+
rm /etc/nginx/sites-enabled/default
106+
$STD systemctl reload nginx
107+
systemctl restart php8.4-fpm
108+
msg_ok "Configured Nginx"
109+
110+
msg_info "Configure Services"
111+
ln -s /opt/librenms/lnms /usr/bin/lnms
112+
mkdir -p /etc/bash_completion.d/
113+
cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
114+
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
115+
116+
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev"
117+
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && php8.4 artisan migrate --force"
118+
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && php8.4 artisan key:generate --force"
119+
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && lnms db:seed --force"
120+
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && lnms user:add -p admin -r admin admin"
121+
122+
RANDOM_STRING=$(openssl rand -base64 16 | tr -dc 'a-zA-Z0-9')
123+
sed -i "s/RANDOMSTRINGHERE/$RANDOM_STRING/g" /etc/snmp/snmpd.conf
124+
echo "SNMP Community String: $RANDOM_STRING" >>~/librenms.creds
125+
curl -qso /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
126+
chmod +x /usr/bin/distro
127+
systemctl enable -q --now snmpd
128+
129+
cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms
130+
cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
131+
132+
systemctl enable -q --now librenms-scheduler.timer
133+
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
134+
msg_ok "Configured Services"
135+
136+
motd_ssh
137+
customize
138+
cleanup_lxc

0 commit comments

Comments
 (0)