Skip to content

Commit

Permalink
Added print_error and print_warning functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerblue77 committed Jan 26, 2025
1 parent 9402f05 commit 30ceee7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Dell_iDRAC_fan_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ fi
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
print_error_and_exit "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"
fi
IDRAC_LOGIN_STRING='open'
else
Expand All @@ -41,8 +40,7 @@ fi
get_Dell_server_model

if [[ ! $SERVER_MANUFACTURER == "DELL" ]]; then
echo "/!\ Your server isn't a Dell product. Exiting." >&2
exit 1
print_error_and_exit "Your server isn't a Dell product"
fi

# If server model is Gen 14 (*40) or newer
Expand Down
25 changes: 23 additions & 2 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ function graceful_exit() {
enable_third_party_PCIe_card_Dell_default_cooling_response
fi

echo "/!\ WARNING /!\ Container stopped, Dell default dynamic fan control profile applied for safety."
exit 0
print_warning_and_exit "Container stopped, Dell default dynamic fan control profile applied for safety"
}

# Helps debugging when people are posting their output
Expand All @@ -127,3 +126,25 @@ function get_Dell_server_model() {
# Define functions to check if CPU 1 and CPU 2 temperatures are above the threshold
function CPU1_OVERHEATING() { [ $CPU1_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; }
function CPU2_OVERHEATING() { [ $CPU2_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; }

function print_error() {
local ERROR_MESSAGE="$1"
echo "/!\ Error /!\ $ERROR_MESSAGE." >&2
}

function print_error_and_exit() {
local ERROR_MESSAGE="$1"
print_error "$ERROR_MESSAGE Exciting."
exit 1
}

function print_warning() {
local WARNING_MESSAGE="$1"
echo "/!\ Warning /!\ $WARNING_MESSAGE."
}

function print_warning_and_exit() {
local WARNING_MESSAGE="$1"
print_warning "$WARNING_MESSAGE Exciting."
exit 0
}
3 changes: 1 addition & 2 deletions healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ source functions.sh
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
print_error_and_exit "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"
fi
IDRAC_LOGIN_STRING='open'
else
Expand Down

0 comments on commit 30ceee7

Please sign in to comment.