Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update init checks to be less restrictive #347

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Image: librenms/librenms:latest
* `LOG_IP_VAR`: Use another variable to retrieve the remote IP address for access [log_format](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format) on Nginx. (default `remote_addr`)
* `SESSION_DRIVER`: [Driver to use for session storage](https://github.com/librenms/librenms/blob/master/config/session.php) (default `file`)
* `CACHE_DRIVER`: [Driver to use for cache and locks](https://github.com/librenms/librenms/blob/master/config/cache.php) (default `database`)
* `IGNORE_ERRORS`: If set to `1`, startup scripts won't exit if any failure is found. (default not defined).

### Redis

Expand Down
14 changes: 10 additions & 4 deletions rootfs/etc/cont-init.d/03-config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
if [ -z "${IGNORE_ERRORS}" ]; then
set -e
fi

# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L21-L41
# usage: file_env VAR [DEFAULT]
Expand Down Expand Up @@ -115,7 +117,7 @@ fi

touch /data/logs/librenms.log
rm -rf ${LIBRENMS_PATH}/logs
rm -f ${LIBRENMS_PATH}/config.d/*
rm -f ${LIBRENMS_PATH}/config.d/* || true
mkdir -p /etc/logrotate.d
touch /etc/logrotate.d/librenms

Expand Down Expand Up @@ -172,10 +174,12 @@ ipmitool: /usr/sbin/ipmitool
EOL

# Config : Disable autoupdate (set in config.php so it cannot be overridden in the webui)
cat >${LIBRENMS_PATH}/config.d/autoupdate.php <<EOL
if [ -w ${LIBRENMS_PATH}/config.d ]; then
cat >${LIBRENMS_PATH}/config.d/autoupdate.php <<EOL
<?php
\$config['update'] = 0;
EOL
fi

# Config : Services
cat >${LIBRENMS_PATH}/database/seeders/config/services.yaml <<EOL
Expand All @@ -184,7 +188,7 @@ nagios_plugins: /usr/lib/monitoring-plugins
EOL

# Config : RRDCached, apply RRDCACHED_SERVER as php as it would be expected to change with the variable
if [ -n "${RRDCACHED_SERVER}" ]; then
if [ -n "${RRDCACHED_SERVER}" ] && [ -w ${LIBRENMS_PATH}/config.d ]; then
cat >${LIBRENMS_PATH}/config.d/rrdcached.php <<EOL
<?php
\$config['rrdcached'] = "${RRDCACHED_SERVER}";
Expand Down Expand Up @@ -219,7 +223,9 @@ done
# Fix perms
echo "Fixing perms..."
chown librenms:librenms /data/config /data/monitoring-plugins /data/plugins /data/rrd /data/weathermap /data/alert-templates
chown -R librenms:librenms /data/logs ${LIBRENMS_PATH}/config.d ${LIBRENMS_PATH}/bootstrap ${LIBRENMS_PATH}/logs ${LIBRENMS_PATH}/storage
for FOLDER in /data/logs ${LIBRENMS_PATH}/config.d ${LIBRENMS_PATH}/bootstrap ${LIBRENMS_PATH}/logs ${LIBRENMS_PATH}/storage; do
[ -w ${FOLDER} ] && chown -R librenms:librenms ${FOLDER}
done
chmod ug+rw /data/logs /data/rrd ${LIBRENMS_PATH}/bootstrap/cache ${LIBRENMS_PATH}/storage ${LIBRENMS_PATH}/storage/framework/*

# Check additional Monitoring plugins
Expand Down
2 changes: 2 additions & 0 deletions rootfs/etc/cont-init.d/04-svc-main.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash
if [ -z "${IGNORE_ERRORS}" ]; then
set -e
fi

# From https://github.com/docker-library/mariadb/blob/master/docker-entrypoint.sh#L21-L41
# usage: file_env VAR [DEFAULT]
Expand Down