git: 467e569d02e8 - main - net-mgmt/librenms: Update to 22.2.1

From: Dan Langille <dvl_at_FreeBSD.org>
Date: Fri, 18 Feb 2022 15:21:05 UTC
The branch main has been updated by dvl:

URL: https://cgit.FreeBSD.org/ports/commit/?id=467e569d02e854b4e3abd762b796da449b57ff72

commit 467e569d02e854b4e3abd762b796da449b57ff72
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2022-02-18 15:19:22 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2022-02-18 15:21:02 +0000

    net-mgmt/librenms: Update to 22.2.1
    
    re: https://github.com/librenms/librenms/releases/tag/22.2.1
    
    This port update skips over several releases.
    See: https://github.com/librenms/librenms/releases
    
    See UPDATING for details on storage directory which needs to
    move to /var/db/librenms
    
    LiberNMS wants to write to the %%WWWDIR%%/storage directory. To comply
    with man 7 hier, this entry is now a symlink to /var/db/librenms/storage
    Please adjust your filesystem accordingly.
    
    The contrib directory has been removed from the upstream tarball. As such,
    the port now installs the log rotation file to
    /${PREFIX}/etc/newsyslog.conf.d/librenms.conf.sample
    
    PR:             260085 261031
---
 UPDATING                                         |   8 ++
 net-mgmt/librenms/Makefile                       |  45 +++++----
 net-mgmt/librenms/distinfo                       |  10 +-
 net-mgmt/librenms/files/patch-config.php.default |  12 +--
 net-mgmt/librenms/files/patch-poller-wrapper.py  |  17 ++--
 net-mgmt/librenms/files/pkg-message.in           | 116 +++++++++++++----------
 6 files changed, 122 insertions(+), 86 deletions(-)

diff --git a/UPDATING b/UPDATING
index 6537ee19d194..27b47b867a55 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,14 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20220218:
+  AFFECTS: users of net-mgmt/librenms
+  AUTHOR: dvl@FreeBSD.org
+
+  The storage directory has moved from WWWDIR to /var/db/librenms/storage
+  to comply with man 7 hier. When upgrading, you may need to manually create
+  this symlink.
+
 20220212:
   AFFECTS: users of lang/php8[01][-extensions]?
   AUTHOR: bofh@FreeBSD.org
diff --git a/net-mgmt/librenms/Makefile b/net-mgmt/librenms/Makefile
index 37283690fcba..bfb190a60aa7 100644
--- a/net-mgmt/librenms/Makefile
+++ b/net-mgmt/librenms/Makefile
@@ -1,6 +1,5 @@
 PORTNAME=	librenms
-PORTVERSION=	21.5.1
-PORTREVISION=	3
+PORTVERSION=	22.2.1
 PORTEPOCH=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	LOCAL/dvl:vendor
@@ -39,6 +38,7 @@ SHEBANG_FILES=	../${PORTNAME}-vendor-${PORTVERSION}/swiftmailer/swiftmailer/lib/
 		scripts/Migration/XML_Conversion/convert.sh \
 		scripts/Migration/XML_Conversion/destwork.sh \
 		scripts/Migration/XML_Conversion/mkdir.sh \
+		scripts/dynamic_check_requirements.py \
 		scripts/removespikes.php scripts/removespikes.pl \
 		scripts/watchmaillog/watchmaillog.pl
 
@@ -57,6 +57,8 @@ USERS=		www
 PORTDOCS=	*
 PORTEXAMPLES=	snmpd.conf.example
 
+DBDIR=		/var/db/${PORTNAME}
+
 OPTIONS_DEFINE=		DOCS EXAMPLES FPING IPMITOOL LIBVIRT MYSQLD NAGPLUGINS \
 			NMAP WMIC X11
 OPTIONS_DEFAULT=	FPING IPMITOOL LIBVIRT NAGPLUGINS NMAP PYPOLLER WMIC
@@ -92,17 +94,21 @@ _SCRIPT_FILES=		daily.sh lnms
 # _RELEASE_TIMESTAMP is used for a patch inside the vendor code
 # it represents the release date via: git show --pretty='%H|%ct' -s 1.42.01
 # It sits here so you remember to update it with each release
-_RELEASE_TIMESTAMP=	1621427246
-_ROOT_DIRS=		LibreNMS app bootstrap config contrib database doc html \
+_RELEASE_TIMESTAMP=	1645175566
+_ROOT_DIRS=		LibreNMS app bootstrap config database doc html \
 			includes licenses mibs misc resources routes scripts \
-			sql-schema storage tests
+			sql-schema tests
 _DOCS=			AUTHORS.md CHANGELOG.md CONTRIBUTING.md LICENSE.txt \
 			README.md
+
+# these are directories which require a generic @DIR entry in pkg-plist
+_STORAGE_DIRS=		app app/public debugbar framework framework/cache framework/cache/data framework/sessions \
+			framework/testing framework/views logs
+
 # these are directories which require a generic @DIR entry in pkg-plist
-_OTHER_DIRS=		html/js/lang resources/views/overview/custom \
-			storage/app/public storage/debugbar \
-			storage/framework/cache/data storage/framework/testing \
-			storage/logs tests/Browser/console \
+_OTHER_DIRS=		database/seeders/config html/plugins \
+			html/js/lang resources/views/overview/custom \
+			tests/Browser/console \
 			tests/Browser/screenshots \
 			vendor/librenms/laravel-vue-i18n-generator/tests/output \
 			vendor/ramsey/collection/bin \
@@ -155,8 +161,10 @@ do-install:
 	       '*.php' -exec ${CHMOD} +x {} \;
 # these values should be outside the www tree now
 	${MKDIR} ${STAGEDIR}/var/log/${PORTNAME}
-	${MKDIR} ${STAGEDIR}/var/db/${PORTNAME}
+	${MKDIR} ${STAGEDIR}${DBDIR}
+	${MKDIR} ${STAGEDIR}${DBDIR}/storage
 	${MKDIR} ${STAGEDIR}/var/run/${PORTNAME}
+	(cd ${STAGEDIR}/${WWWDIR} && ${LN} -s ../../../..${DBDIR}/storage)
 
 do-install-DOCS-on:
 	${MKDIR} ${STAGEDIR}/${DOCSDIR}
@@ -179,23 +187,24 @@ post-install:
 # we do this file separately because it needs a different chmod/chown
 # it will eventually contains secrets
 	${INSTALL_DATA} ${WRKSRC}/.env.example ${STAGEDIR}/${WWWDIR}
+	${ECHO_CMD} "@dir(www,www,0775) ${DBDIR}/storage" >> ${TMPPLIST}
+	${ECHO_CMD} "@dir(www,www,0775) ${DBDIR}" >> ${TMPPLIST}
+	${ECHO_CMD} "@dir(www,www,0775) /var/log/${PORTNAME}" >> ${TMPPLIST}
 	${ECHO_CMD} "@(root,www,0750) ${WWWDIR}/.env.example" >> ${TMPPLIST}
 
 	${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/bootstrap/cache" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/storage" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/storage/framework/cache" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/storage/framework/sessions" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) ${WWWDIR}/storage/framework/views" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) /var/log/${PORTNAME}" >> ${TMPPLIST}
-	${ECHO_CMD} "@dir(www,www,0775) /var/db/${PORTNAME}" >> ${TMPPLIST}
 	${ECHO_CMD} "@dir(www,www,0775) /var/run/${PORTNAME}" >> ${TMPPLIST}
+.for f in ${_STORAGE_DIRS}
+	${MKDIR} ${STAGEDIR}/${DBDIR}/storage/${f}
+	${ECHO_CMD} "@dir(root,www,0775) ${DBDIR}/storage/${f}" >> ${TMPPLIST}
+.endfor
 .for f in ${_OTHER_DIRS}
 	${ECHO_CMD} "@dir(root,www,0775) ${WWWDIR}/${f}" >> ${TMPPLIST}
 .endfor
 
 	${MKDIR} ${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d
-	${INSTALL_DATA} ${FILESDIR}/newsyslog.conf.sample ${STAGEDIR}/${WWWDIR}/contrib/newsyslog.conf.sample
+	${INSTALL_DATA} ${FILESDIR}/newsyslog.conf.sample ${STAGEDIR}/${PREFIX}/etc/newsyslog.conf.d/librenms.conf.sample
 	${ECHO_CMD} "@dir etc/newsyslog.conf.d" >> ${TMPPLIST}
-	${ECHO_CMD} "@sample ${WWWDIR}/contrib/newsyslog.conf.sample etc/newsyslog.conf.d/librenms.conf" >> ${TMPPLIST}
+	${ECHO_CMD} "@sample etc/newsyslog.conf.d/librenms.conf.sample" >> ${TMPPLIST}
 
 .include <bsd.port.mk>
diff --git a/net-mgmt/librenms/distinfo b/net-mgmt/librenms/distinfo
index 6c271717904b..022be39b32f6 100644
--- a/net-mgmt/librenms/distinfo
+++ b/net-mgmt/librenms/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1621543700
-SHA256 (librenms-vendor-21.5.1.tar.gz) = 746a0ffd58a0f9d7428283c9b3b706e514b405781a5fc4c2685492479bad2580
-SIZE (librenms-vendor-21.5.1.tar.gz) = 28282743
-SHA256 (librenms-librenms-21.5.1_GH0.tar.gz) = 4baa930bb0c884b2d596047a01f79d717992dafefb5e744b1b5438f5570dbb8b
-SIZE (librenms-librenms-21.5.1_GH0.tar.gz) = 50159109
+TIMESTAMP = 1645192012
+SHA256 (librenms-vendor-22.2.1.tar.gz) = 61d377bb05ba7cb3129d71092437582cc450a7ba029f71a5aadccd988304a490
+SIZE (librenms-vendor-22.2.1.tar.gz) = 28184306
+SHA256 (librenms-librenms-22.2.1_GH0.tar.gz) = a84dd3b30f412ee2e42b51b74472c6ffbc98e63900caf19fefa15679e44057a6
+SIZE (librenms-librenms-22.2.1_GH0.tar.gz) = 53897718
diff --git a/net-mgmt/librenms/files/patch-config.php.default b/net-mgmt/librenms/files/patch-config.php.default
index 27d957e2e7a3..b10e78dc6ef1 100644
--- a/net-mgmt/librenms/files/patch-config.php.default
+++ b/net-mgmt/librenms/files/patch-config.php.default
@@ -1,4 +1,4 @@
---- config.php.default.orig	2020-07-10 19:56:16 UTC
+--- config.php.default.orig	2022-01-23 14:47:41 UTC
 +++ config.php.default
 @@ -2,10 +2,26 @@
  
@@ -14,7 +14,7 @@
 +
  // This is the user LibreNMS will run as
 -//Please ensure this user is created and has the correct permissions to your install
--$config['user'] = 'librenms';
+-#$config['user'] = 'librenms';
 +// Please ensure this user is created and has the correct permissions to your install
 +// The FreeBSD package sets this.
 +// It's up to you to install a webserver, such as Apache or Nginx. By default, they
@@ -29,7 +29,7 @@
  ### This should *only* be set if you want to *force* a particular hostname/port
  ### It will prevent the web interface being usable form any other hostname
  #$config['base_url']        = "/";
-@@ -27,7 +43,8 @@ $config['auth_mechanism'] = "mysql"; # default, other 
+@@ -27,7 +43,8 @@
  #$config['nets'][] = "192.168.0.0/16";
  
  # Uncomment the next line to disable daily updates
@@ -38,11 +38,11 @@
 +$config['update'] = 0;
  
  # Number in days of how long to keep old rrd files. 0 disables this feature
- $config['rrd_purge'] = 0;
-@@ -43,3 +60,22 @@ $config['enable_billing'] = 1;
+ #$config['rrd_purge'] = 0;
+@@ -43,3 +60,22 @@
  
  # Enable the in-built services support (Nagios plugins)
- $config['show_services'] = 1;
+ #$config['show_services'] = 1;
 +
 +# These paths are supplied by the FreeBSD port and correct those found in
 +# the code.
diff --git a/net-mgmt/librenms/files/patch-poller-wrapper.py b/net-mgmt/librenms/files/patch-poller-wrapper.py
index 9b42e406c9a9..496a9777bd77 100644
--- a/net-mgmt/librenms/files/patch-poller-wrapper.py
+++ b/net-mgmt/librenms/files/patch-poller-wrapper.py
@@ -1,11 +1,12 @@
---- poller-wrapper.py.orig	2021-01-14 02:21:36 UTC
+--- poller-wrapper.py.orig	2022-01-26 18:26:32 UTC
 +++ poller-wrapper.py
-@@ -44,6 +44,8 @@ except ImportError as exc:
-     print('ERROR: %s' % exc)
-     sys.exit(2)
- 
+@@ -40,6 +40,9 @@ if not config:
+     logger = logging.getLogger(__name__)
+     logger.critical("Could not run {} wrapper. Missing config".format(WRAPPER_TYPE))
+     sys.exit(1)
++
 +os.environ['PATH'] += ':%%LOCALBASE%%/sbin:%%LOCALBASE%%/bin'
 +
- 
- APP_NAME = "poller_wrapper"
- LOG_FILE = "logs/" + APP_NAME + ".log"
+ log_dir = config["log_dir"]
+ log_file = os.path.join(log_dir, WRAPPER_TYPE + "_wrapper.log")
+ logger = LibreNMS.logger_get_logger(log_file, debug=args.debug)
diff --git a/net-mgmt/librenms/files/pkg-message.in b/net-mgmt/librenms/files/pkg-message.in
index a32321373e84..91fb89cb092e 100644
--- a/net-mgmt/librenms/files/pkg-message.in
+++ b/net-mgmt/librenms/files/pkg-message.in
@@ -8,19 +8,37 @@ http://docs.librenms.org/
 with the following notes:
 - Installation directory is %%WWWDIR%%
 
-NOTE: setting sql-mode="" is no longer required. You can remove
-it from %%LOCALBASE%%/etc/mysql/my.cnf
+NOTE: setting sql-mode="" is no longer required. You can remove it from
+%%LOCALBASE%%/etc/mysql/my.cnf
 
-However, 'lower_case_table_names=0' is required.
+LibreNMS requires specific entries in my.cnf for MySQL. In MySQL 8, once the
+service is started for the first time, the lower_case_table_names value can not
+be changed. It is recommended that you my.cnf before starting MySQL for the
+first time or pass specific values on the command-line when starting MySQL. 
 
-HEADS UP
+NOTE that the lower_case_table_names entry needs to be set before you start
+MySQL for the first time.
 
-Polling via cron job has been removed.. Please use the Dispatcher.
+innodb_file_per_table=1
+lower_case_table_names=0
 
-LibreNMS will be dropped support for PHP 7.1 and Python 2
-see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
+By default MySQL 8 uses a different authentication plugin to auth database users.
+If you see errors in the logs like this:
 
-Your existing crontab entries are no longer useful and should be deleted.
+"The server requested authentication method unknown to the client..."
+
+Add this to my.cnf:
+
+[mysqld]
+default-authentication-plugin=mysql_native_password
+
+The following MySQL configuration is required. Adjust 'localhost' as
+required if MySQL is on a different host.
+
+CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+CREATE USER 'librenms'@'localhost' IDENTIFIED with mysql_native_password BY 'password';
+GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
+FLUSH PRIVILEGES;
 
 Enable the poller service with this command:
 
@@ -28,30 +46,12 @@ sysrc librenms_enable="YES"
 
 The service will log to /var/log/librems/librenms-service.log
 
-see also https://docs.librenms.org/Extensions/Dispatcher-Service/
-
 For log file rotation
 
 * sample file installed to %%WWWDIR%%/contrib/newsyslog.conf.sample
 * actual file installed, never overwriting, to %%PREFIX%%/etc/newsyslog.conf.d/librenms.conf
 
-When converting from PYPOLLER to the Dispatcher Service (PYSERVICE),
-these steps will help you get started:
-
-* compile with PYSERVICE enabled and PYPOLLER disabled
-* comment out the crontab entries listed above under PYPOLLER
-* populate %%WWWDIR%%/.env with:
-  * APP_KEY - see farther below for how to create
-  * NODE_ID - see just below for how to create
-  * DB_HOST
-  * DB_DATABASE
-  * DB_USERNAME
-  * DB_PASSWORD
-* you can create a NODE_ID with: php -r 'echo uniqid() . "\n";'
-
-When setting up a new install, you need a %%WWWDIR%%/.env file.
-
-To create:
+For new installs, you need a %%WWWDIR%%/.env file. To create:
 
 cd %%WWWDIR%%
 cp -i .env.example .env
@@ -60,29 +60,39 @@ That file will eventually contain secrets.  Make sure it is not world-readable.
 
 Database connection details are required in that file.
 
+When trying to run /install for the first time you need to have (INSTALL=true)
+in your .env file. If you don't set it you will get a 403 error on the
+webpage.
+
 Then run:
 
 sudo php artisan key:generate
 
-It should write directly to your .env file
-
-The output should look something like this:
+It should write directly to your .env file. The output should look something
+like this:
 
 $ sudo php artisan key:generate
 Application key set successfully.
 
-When migrating to PYSERVICE (also known as the Dispatcher Service):
-
-It is also a good idea to:
-cd %%WWWDIR%%
-sudo ./validate.php
-
 You need an APP_KEY.
 
+* %%WWWDIR%%/.env should now contain:
+  * APP_KEY
+  * NODE_I
+  * DB_HOST
+  * DB_DATABASE
+  * DB_USERNAME
+  * DB_PASSWORD
+
+* you can create a NODE_ID with: php -r 'echo uniqid() . "\n";'
 
 After that, follow the LibreNMS documentation for configuration.
 
-You probably want to install lang/python3 to get validate.php clean.
+It is also a good idea to validate your configuation after MySQL has been
+started:
+
+cd %%WWWDIR%%
+sudo ./validate.php
 
 EOM
 }
@@ -97,26 +107,34 @@ Or the database upgrade script:
 
 ./lnms migrate
 
-re: https://docs.librenms.org/#General/Updating/
+NOTE: that script is particular about who runs it and ownership.
+You might have to chown www first, then:
+
+chown www lnms
+su -fm www
+./lnms migrate
+exit
+chown root lnms
+
 
-HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP
-HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP HEADS UP
+re: https://docs.librenms.org/General/Updating/
 
-Polling via cron job is now gone. Please use the Dispatcher.
+LibreNMS requires specific entries in my.cnf for MySQL.
 
-LibreNMS will be droppped support for PHP 7.1 and Python 2.
-see https://community.librenms.org/t/dropping-support-for-php-7-1-and-python-2/11851
+NOTE that the lower_case_table_names entry needs to be set before you start
+MySQL for the first time.
 
-Your existing crontab entries can be deleted.
+innodb_file_per_table=1
+lower_case_table_names=0
 
-For more information, see pkg info --pkg-message librenms
+For MySQL 8, you need to update the my.cnf
 
-You probably want to install lang/python3 to get validate.php clean.
+And adjust the login (adjusting localhost as required):
 
-Logs have been relocated to /var/log/librenms - see UPDATING 20200726
-Logs which were going to /var/log/messages and /var/log/librenms/ now only go
-to /var/log/librenms/
+alter user 'librenms'@'localhost' identified with mysql_native_password by 'passwordhere';
 
+NOTE: Starting with the 22.2.1 port the %%%WWWDIR%%/storage directory has
+been replaced with a symlink to /var/db/librenms/storage
 
 EOM
 }