From 71d5d29dbbec41eaa03af581e3f8a348b620df5b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 29 Jun 2020 16:17:07 -0500 Subject: [PATCH] Automatically change all tabs in install docs Reduced the likelihood of a user viewing info for the wrong os. --- doc/Installation/Install-LibreNMS.md | 121 +++++++++++++++------------ doc/librenms-docs.js | 69 +++++++++++++++ mkdocs.yml | 2 + 3 files changed, 137 insertions(+), 55 deletions(-) create mode 100644 doc/librenms-docs.js diff --git a/doc/Installation/Install-LibreNMS.md b/doc/Installation/Install-LibreNMS.md index 8d4ee6ffc2..c37feaa424 100644 --- a/doc/Installation/Install-LibreNMS.md +++ b/doc/Installation/Install-LibreNMS.md @@ -4,7 +4,7 @@ path: blob/master/doc/ # Prepare Linux Server You should have an installed Linux server running one of the supported OS. -Make sure you select the correct OS in the tabbed options below each time. +Make sure you select your server's OS in the tabbed options below. Choice of web server is your preference, NGINX is recommended. Connect to the server command line and follow the instructions below. @@ -96,17 +96,17 @@ Ensure date.timezone is set in php.ini to your preferred time zone. vi /etc/php/7.4/cli/php.ini ``` +=== "CentOS 8" + ``` + vi /etc/php.ini + ``` + === "Debian 10" ```bash vi /etc/php/7.3/fpm/php.ini vi /etc/php/7.3/cli/php.ini ``` -=== "CentOS 8" - ``` - vi /etc/php.ini - ``` - Remember to set the system timezone as well. ``` @@ -116,16 +116,21 @@ timedatectl set-timezone Etc/UTC # Configure MariaDB -=== "Ubuntu 20.04 / Debian 10" +=== "Ubuntu 20.04" ``` vi /etc/mysql/mariadb.conf.d/50-server.cnf ``` - + === "CentOS 8" ``` vi /etc/my.cnf.d/mariadb-server.cnf ``` +=== "Debian 10" + ``` + vi /etc/mysql/mariadb.conf.d/50-server.cnf + ``` + Within the `[mysqld]` section add: ```bash @@ -160,18 +165,18 @@ exit vi /etc/php/7.4/fpm/pool.d/librenms.conf ``` -=== "Debian 10" - ```bash - cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf - vi /etc/php/7.3/fpm/pool.d/librenms.conf - ``` - === "CentOS 8" ```bash cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/librenms.conf vi /etc/php-fpm.d/librenms.conf ``` +=== "Debian 10" + ```bash + cp /etc/php/7.3/fpm/pool.d/www.conf /etc/php/7.3/fpm/pool.d/librenms.conf + vi /etc/php/7.3/fpm/pool.d/librenms.conf + ``` + ``` # Change "www" to "librenms" [librenms] @@ -265,45 +270,6 @@ Feel free to tune the performance settings in librenms.conf to meet your needs. systemctl restart php7.4-fpm ``` -=== "Debian 10" - === "NGINX" - ```bash - vi /etc/nginx/sites-enabled/librenms.vhost - ``` - - Add the following config, edit `server_name` as required: - - ```nginx - server { - listen 80; - server_name librenms.example.com; - 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; - } - } - ``` - - ```bash - rm /etc/nginx/sites-enabled/default - systemctl reload nginx - systemctl restart php7.3-fpm - ``` - - === "CentOS 8" === "NGINX" ``` @@ -386,9 +352,47 @@ Feel free to tune the performance settings in librenms.conf to meet your needs. systemctl enable --now php-fpm ``` +=== "Debian 10" + === "NGINX" + ```bash + vi /etc/nginx/sites-enabled/librenms.vhost + ``` + + Add the following config, edit `server_name` as required: + + ```nginx + server { + listen 80; + server_name librenms.example.com; + 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; + } + } + ``` + + ```bash + rm /etc/nginx/sites-enabled/default + systemctl reload nginx + systemctl restart php7.3-fpm + ``` + # SELinux -=== "Ubuntu 20.04 / Debian 10" +=== "Ubuntu 20.04" SELinux not enabled by default === "CentOS 8" @@ -444,9 +448,12 @@ Feel free to tune the performance settings in librenms.conf to meet your needs. audit2why < /var/log/audit/audit.log ``` +=== "Debian 10" + SELinux not enabled by default + # Allow access through firewall -=== "Ubuntu 20.04 / Debian 10" +=== "Ubuntu 20.04" Firewall not enabled by default === "CentOS 8" @@ -456,6 +463,10 @@ Feel free to tune the performance settings in librenms.conf to meet your needs. firewall-cmd --permanent --zone public --add-service http --add-service https ``` +=== "Debian 10" + Firewall not enabled by default + + # Enable lnms command completion This feature grants you the opportunity to use tab for completion on lnms commands as you would diff --git a/doc/librenms-docs.js b/doc/librenms-docs.js new file mode 100644 index 0000000000..86f4db3f49 --- /dev/null +++ b/doc/librenms-docs.js @@ -0,0 +1,69 @@ +document.addEventListener('DOMContentLoaded', function () { + + [].forEach.call(document.getElementsByClassName('tabbed-set'), function (tabSet) { + [].forEach.call(tabSet.getElementsByTagName('label'), function (tab) { + tab.addEventListener("click", changeInstallTab); + }); + }); +}, false); + +function changeInstallTab(e) { + e = e || window.event; + var target = e.target || e.srcElement; + var text = target.textContent || target.innerText; + + [].forEach.call(document.getElementsByClassName('tabbed-set'), function (tabSet) { + var tabs = []; + var children = tabSet.children; + var found = false; + for (i = 0; i < children.length; i++) { + var el = children[i]; + if (el.tagName === 'LABEL') { + var tabText = el.textContent || el.innerText; + if (tabText === text) { + found = true; + } + tabs.push({id: el.htmlFor, checked: tabText === text}); + } + } + + // apply changes if tab found in group + if (found) { + tabs.forEach(function (tab) { + document.getElementById(tab.id).checked = tab.checked; + }); + } + }); + + // make sure original element did not get pushed off screen + target.scrollIntoViewIfNeeded(); +} + +// scrollIntoViewIfNeeded Polyfill +if (!Element.prototype.scrollIntoViewIfNeeded) { + Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) { + centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded; + + var parent = this.parentNode, + parentComputedStyle = window.getComputedStyle(parent, null), + parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width')), + parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width')), + overTop = this.offsetTop - parent.offsetTop < parent.scrollTop, + overBottom = (this.offsetTop - parent.offsetTop + this.clientHeight - parentBorderTopWidth) > (parent.scrollTop + parent.clientHeight), + overLeft = this.offsetLeft - parent.offsetLeft < parent.scrollLeft, + overRight = (this.offsetLeft - parent.offsetLeft + this.clientWidth - parentBorderLeftWidth) > (parent.scrollLeft + parent.clientWidth), + alignWithTop = overTop && !overBottom; + + if ((overTop || overBottom) && centerIfNeeded) { + parent.scrollTop = this.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + this.clientHeight / 2; + } + + if ((overLeft || overRight) && centerIfNeeded) { + parent.scrollLeft = this.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + this.clientWidth / 2; + } + + if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) { + this.scrollIntoView(alignWithTop); + } + }; +} diff --git a/mkdocs.yml b/mkdocs.yml index c7ce63fe24..f0eddf890c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -19,6 +19,8 @@ markdown_extensions: extra_css: - https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css - librenms.css +extra_javascript: + - librenms-docs.js extra: article_nav_top: false article_nav_bottom: true