From c55706accbc5464ccb566c309823fbe0cd629d91 Mon Sep 17 00:00:00 2001 From: Tigerblue77 <37409593+tigerblue77@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:27:31 +0000 Subject: [PATCH] Added Docker healthcheck to README.md --- Dockerfile | 5 ++++- healthcheck.sh | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 healthcheck.sh diff --git a/Dockerfile b/Dockerfile index 523ca2a..3918d02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,15 @@ RUN apt-get update RUN apt-get install ipmitool -y ADD functions.sh /app/functions.sh +ADD healthcheck.sh /app/healthcheck.sh ADD Dell_iDRAC_fan_controller.sh /app/Dell_iDRAC_fan_controller.sh -RUN chmod 0777 /app/functions.sh /app/Dell_iDRAC_fan_controller.sh +RUN chmod 0777 /app/functions.sh /app/healthcheck.sh /app/Dell_iDRAC_fan_controller.sh WORKDIR /app +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD_SHELL [ "/app/healthcheck.sh" ] + # you should override these default values when running. See README.md #ENV IDRAC_HOST 192.168.1.100 ENV IDRAC_HOST local diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100644 index 0000000..0bdbe12 --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Enable strict bash mode to stop the script if an uninitialized variable is used, if a command fails, or if a command with a pipe fails +# Not working in some setups : https://github.com/tigerblue77/Dell_iDRAC_fan_controller/issues/48 +# set -euo pipefail + +source functions.sh + +# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly +if [[ $IDRAC_HOST == "local" ]] +then + # Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container + if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then + echo "/!\ Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0, check that you added the device to your Docker container or stop using local mode. Exiting." >&2 + exit 1 + fi + IDRAC_LOGIN_STRING='open' +else + echo "iDRAC/IPMI username: $IDRAC_USERNAME" + echo "iDRAC/IPMI password: $IDRAC_PASSWORD" + IDRAC_LOGIN_STRING="lanplus -H $IDRAC_HOST -U $IDRAC_USERNAME -P $IDRAC_PASSWORD" +fi + +ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature