From d7496bbadef4f69b3db7d099f14222d9600b97a6 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 14 Aug 2022 15:29:29 +0200 Subject: [PATCH] Fix container restart state with Weathermap (#304) Co-authored-by: CrazyMax --- rootfs/etc/cont-init.d/02-fix-perms.sh | 1 - rootfs/etc/cont-init.d/03-config.sh | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rootfs/etc/cont-init.d/02-fix-perms.sh b/rootfs/etc/cont-init.d/02-fix-perms.sh index dd490c4..f6ff9e5 100644 --- a/rootfs/etc/cont-init.d/02-fix-perms.sh +++ b/rootfs/etc/cont-init.d/02-fix-perms.sh @@ -11,7 +11,6 @@ chown librenms:librenms \ "${LIBRENMS_PATH}" \ "${LIBRENMS_PATH}/.env" chown -R librenms:librenms \ - "${LIBRENMS_PATH}/html/plugins/Weathermap/output" \ /home/librenms \ /tpls \ /var/lib/nginx \ diff --git a/rootfs/etc/cont-init.d/03-config.sh b/rootfs/etc/cont-init.d/03-config.sh index de0d3ba..7f438f9 100644 --- a/rootfs/etc/cont-init.d/03-config.sh +++ b/rootfs/etc/cont-init.d/03-config.sh @@ -89,24 +89,26 @@ sed -i -e "s/RANDOMSTRINGGOESHERE/${LIBRENMS_SNMP_COMMUNITY}/" /etc/snmp/snmpd.c echo "Initializing LibreNMS files / folders..." mkdir -p /data/config /data/logs /data/monitoring-plugins /data/plugins /data/rrd /data/weathermap /data/alert-templates -if [ -d "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ] && [ ! -L "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ]; then - rm -rf ${LIBRENMS_PATH}/html/plugins/Weathermap/configs +if [ -d "${LIBRENMS_PATH}/html/plugins/Weathermap" ]; then + if [ -d "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ] && [ ! -L "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ]; then + rm -rf ${LIBRENMS_PATH}/html/plugins/Weathermap/configs + fi + if [ ! -L "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ]; then + ln -sf /data/weathermap ${LIBRENMS_PATH}/html/plugins/Weathermap/configs + fi + chown -h librenms:librenms ${LIBRENMS_PATH}/html/plugins/Weathermap/configs + chown -R librenms:librenms /data/weathermap ${LIBRENMS_PATH}/html/plugins/Weathermap/output + + # FIXME: bring back when weathermap plugin compatible with PHP 8 + # https://github.com/librenms/docker/issues/296 + rm -rf ${LIBRENMS_PATH}/html/plugins/Weathermap fi -if [ ! -L "${LIBRENMS_PATH}/html/plugins/Weathermap/configs" ]; then - ln -sf /data/weathermap ${LIBRENMS_PATH}/html/plugins/Weathermap/configs -fi -chown -h librenms:librenms ${LIBRENMS_PATH}/html/plugins/Weathermap/configs -chown -R librenms:librenms /data/weathermap # cleanup bad symlink: https://github.com/librenms/docker/issues/294#issuecomment-1190389960 if [ -L "/data/weathermap/weathermap" ]; then rm /data/weathermap/weathermap fi -# FIXME: bring back when weathermap plugin compatible with PHP 8 -# https://github.com/librenms/docker/issues/296 -rm -rf ${LIBRENMS_PATH}/html/plugins/Weathermap - touch /data/logs/librenms.log rm -rf ${LIBRENMS_PATH}/logs rm -f ${LIBRENMS_PATH}/config.d/*