mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-03-03 09:25:55 +01:00
* fix(error-handler): prevent silent() from re-enabling error handling during recovery Root cause: silent() (core.func) unconditionally calls set -Eeuo pipefail and trap 'error_handler' ERR after every command. When build_container() intentionally disables error handling for its recovery section, any intermediate call through silent()/ re-enables it. This causes the grep/sed pipeline for missing_cmd extraction to trigger error_handler (grep returns exit code 1 on no match + pipefail = fatal). Fixes: 1. silent(): Save errexit state before disabling, only restore if it was active. Callers that intentionally disabled error handling (e.g. build_container recovery) are no longer silently re-enabled. 2. build.func: Add || true to missing_cmd grep pipeline as defense-in-depth against pipeline failure propagation. 3. build.func: Add explicit set +Eeuo pipefail / trap - ERR after post_update_to_api() call, before error classification grep/sed section. 4. build.func: Remove stale global combined_log variable from variables() that used a different path format (/tmp/install-SESSION-combined.log) than the actual local variable (/tmp/NSAPP-CTID-SESSION.log). The global was never written to and caused confusion when error_handler displayed it. * Update build.func * chore(install): add Github source links to all setup_nodejs scripts 52 install scripts had a project website in '# Source:' but no GitHub link. Merged the GitHub repo URL into the Source header as: # Source: https://website.com/ | Github: https://github.com/OWNER/REPO Repos sourced from fetch_and_deploy_gh_release calls, get_latest_github_release calls, or known project repos for npm/pip installed apps. Two scripts (fumadocs, pve-scripts-local) had no Source line at all — added one. Shinobi skipped (GitLab-only, no GitHub repo). * chore(install): add Github source links to all fetch_and_deploy scripts 77 additional install scripts had fetch_and_deploy_gh_release calls but no GitHub link in the Source header. Merged the primary app repo into the Source header as: # Source: https://website.com/ | Github: https://github.com/OWNER/REPO Where multiple fetch_and_deploy calls existed (app + dependency), the primary app repo was selected: - ersatztv: ErsatzTV/ErsatzTV (not ffmpeg) - firefly: firefly-iii/firefly-iii (not data-importer) - komga: gotson/komga (not kepubify dep) - sabnzbd: sabnzbd/sabnzbd (not par2cmdline-turbo dep) - signoz: SigNoz/signoz (not otel-collector) - tunarr: chrisbenincasa/tunarr (not ffmpeg dep) Also fixed cosmos-install.sh double https:// in Source URL. Skipped: autocaliweb (source already on codeberg, GitHub repos are deps only) * revert: restore misc/build.func and misc/core.func to main state These error-handler fixes belong to fix/error-handler-recovery, not to this sources-only branch. * chore(ct,tools): sync Source headers with install/ and add Github links to addon scripts
148 lines
4.8 KiB
Bash
148 lines
4.8 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
|
# Author: michelroegl-brunner
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://www.librenms.org/ | Github: https://github.com/librenms/librenms
|
|
|
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
|
color
|
|
verb_ip6
|
|
catch_errors
|
|
setting_up_container
|
|
network_check
|
|
update_os
|
|
|
|
msg_info "Installing Dependencies"
|
|
$STD apt install -y \
|
|
acl \
|
|
fping \
|
|
graphviz \
|
|
imagemagick \
|
|
mtr-tiny \
|
|
nginx \
|
|
nmap \
|
|
rrdtool \
|
|
snmp \
|
|
snmpd \
|
|
whois
|
|
msg_ok "Installed Dependencies"
|
|
|
|
msg_info "Installing Python Dependencies"
|
|
$STD apt install -y \
|
|
python3-dotenv \
|
|
python3-pymysql \
|
|
python3-redis \
|
|
python3-setuptools \
|
|
python3-systemd \
|
|
python3-pip \
|
|
python3-psutil \
|
|
python3-command-runner
|
|
msg_ok "Installed Python Dependencies"
|
|
|
|
PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="cli,snmp,gmp" setup_php
|
|
setup_mariadb
|
|
setup_composer
|
|
PYTHON_VERSION="3.13" setup_uv
|
|
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
|
|
fetch_and_deploy_gh_release "librenms" "librenms/librenms" "tarball"
|
|
|
|
msg_info "Configuring LibreNMS"
|
|
$STD useradd librenms -d /opt/librenms -M -r -s "$(which bash)"
|
|
mkdir -p /opt/librenms/{rrd,logs,bootstrap/cache,storage,html}
|
|
cd /opt/librenms
|
|
APP_KEY=$(openssl rand -base64 40 | tr -dc 'a-zA-Z0-9')
|
|
$STD uv venv --clear .venv
|
|
$STD source .venv/bin/activate
|
|
$STD uv pip install -r requirements.txt
|
|
cat <<EOF >/opt/librenms/.env
|
|
DB_DATABASE=${MARIADB_DB_NAME}
|
|
DB_USERNAME=${MARIADB_DB_USER}
|
|
DB_PASSWORD=${MARIADB_DB_PASS}
|
|
APP_KEY=${APP_KEY}
|
|
EOF
|
|
chown -R librenms:librenms /opt/librenms
|
|
chmod 771 /opt/librenms
|
|
chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd
|
|
msg_ok "Configured LibreNMS"
|
|
|
|
msg_info "Configure MariaDB"
|
|
sed -i "/\[mariadb\]/a innodb_file_per_table=1\nlower_case_table_names=0" /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
systemctl enable -q --now mariadb
|
|
msg_ok "Configured MariaDB"
|
|
|
|
msg_info "Configure PHP-FPM"
|
|
cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/librenms.conf
|
|
sed -i "s/\[www\]/\[librenms\]/g" /etc/php/8.4/fpm/pool.d/librenms.conf
|
|
sed -i "s/user = www-data/user = librenms/g" /etc/php/8.4/fpm/pool.d/librenms.conf
|
|
sed -i "s/group = www-data/group = librenms/g" /etc/php/8.4/fpm/pool.d/librenms.conf
|
|
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
|
|
msg_ok "Configured PHP-FPM"
|
|
|
|
msg_info "Configure Nginx"
|
|
cat <<EOF >/etc/nginx/sites-enabled/librenms
|
|
server {
|
|
listen 80;
|
|
server_name ${LOCAL_IP};
|
|
root /opt/librenms/html;
|
|
index index.php;
|
|
|
|
charset utf-8;
|
|
gzip on;
|
|
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;
|
|
location / {
|
|
try_files \$uri \$uri/ /index.php?\$query_string;
|
|
}
|
|
location ~ [^/]\.php(/|$) {
|
|
fastcgi_pass unix:/run/php-fpm-librenms.sock;
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
include fastcgi.conf;
|
|
}
|
|
location ~ /\.(?!well-known).* {
|
|
deny all;
|
|
}
|
|
}
|
|
EOF
|
|
rm /etc/nginx/sites-enabled/default
|
|
$STD systemctl reload nginx
|
|
systemctl restart php8.4-fpm
|
|
msg_ok "Configured Nginx"
|
|
|
|
msg_info "Configure Services"
|
|
ln -s /opt/librenms/lnms /usr/bin/lnms
|
|
mkdir -p /etc/bash_completion.d/
|
|
cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/
|
|
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
|
|
|
|
APP_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
|
APP_USER="admin"
|
|
{
|
|
echo "LibreNMS Credentials"
|
|
echo "Username: ${APP_USER}"
|
|
echo "Password: ${APP_PASSWORD}"
|
|
} >>~/librenms.creds
|
|
|
|
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev"
|
|
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && php8.4 artisan migrate --force"
|
|
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && php8.4 artisan key:generate --force"
|
|
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && lnms db:seed --force"
|
|
$STD su - librenms -s /bin/bash -c "cd /opt/librenms && lnms user:add -p ${APP_PASSWORD} ${APP_USER} --role=admin"
|
|
|
|
RANDOM_STRING=$(openssl rand -base64 16 | tr -dc 'a-zA-Z0-9')
|
|
sed -i "s/RANDOMSTRINGHERE/$RANDOM_STRING/g" /etc/snmp/snmpd.conf
|
|
echo "SNMP Community String: $RANDOM_STRING" >>~/librenms.creds
|
|
curl -qso /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
|
|
chmod +x /usr/bin/distro
|
|
systemctl enable -q --now snmpd
|
|
|
|
cp /opt/librenms/dist/librenms.cron /etc/cron.d/librenms
|
|
cp /opt/librenms/dist/librenms-scheduler.service /opt/librenms/dist/librenms-scheduler.timer /etc/systemd/system/
|
|
|
|
systemctl enable -q --now librenms-scheduler.timer
|
|
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
|
|
msg_ok "Configured Services"
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|