Secured every user-accessible variable with double quotes
This commit is contained in:
parent
b2ec8afc67
commit
b92b18159a
3 changed files with 19 additions and 19 deletions
|
|
@ -14,25 +14,25 @@ trap 'graceful_exit' SIGINT SIGQUIT SIGTERM
|
||||||
# readonly DELL_FRESH_AIR_COMPLIANCE=45
|
# readonly DELL_FRESH_AIR_COMPLIANCE=45
|
||||||
|
|
||||||
# Check if FAN_SPEED variable is in hexadecimal format. If not, convert it to hexadecimal
|
# Check if FAN_SPEED variable is in hexadecimal format. If not, convert it to hexadecimal
|
||||||
if [[ $FAN_SPEED == 0x* ]]; then
|
if [[ "$FAN_SPEED" == 0x* ]]; then
|
||||||
readonly DECIMAL_FAN_SPEED=$(convert_hexadecimal_value_to_decimal "$FAN_SPEED")
|
readonly DECIMAL_FAN_SPEED=$(convert_hexadecimal_value_to_decimal "$FAN_SPEED")
|
||||||
readonly HEXADECIMAL_FAN_SPEED=$FAN_SPEED
|
readonly HEXADECIMAL_FAN_SPEED="$FAN_SPEED"
|
||||||
else
|
else
|
||||||
readonly DECIMAL_FAN_SPEED=$FAN_SPEED
|
readonly DECIMAL_FAN_SPEED="$FAN_SPEED"
|
||||||
readonly HEXADECIMAL_FAN_SPEED=$(convert_decimal_value_to_hexadecimal "$FAN_SPEED")
|
readonly HEXADECIMAL_FAN_SPEED=$(convert_decimal_value_to_hexadecimal "$FAN_SPEED")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
|
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
|
||||||
if [[ $IDRAC_HOST == "local" ]]; then
|
if [[ "$IDRAC_HOST" == "local" ]]; then
|
||||||
# Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container
|
# 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
|
if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then
|
||||||
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"
|
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
|
fi
|
||||||
IDRAC_LOGIN_STRING='open'
|
IDRAC_LOGIN_STRING='open'
|
||||||
else
|
else
|
||||||
echo "iDRAC/IPMI username: $IDRAC_USERNAME"
|
echo "iDRAC/IPMI username: \"$IDRAC_USERNAME\""
|
||||||
#echo "iDRAC/IPMI password: $IDRAC_PASSWORD"
|
#echo "iDRAC/IPMI password: \"$IDRAC_PASSWORD\""
|
||||||
IDRAC_LOGIN_STRING="lanplus -H $IDRAC_HOST -U $IDRAC_USERNAME -P $IDRAC_PASSWORD"
|
IDRAC_LOGIN_STRING="lanplus -H \"$IDRAC_HOST\" -U \"$IDRAC_USERNAME\" -P \"$IDRAC_PASSWORD\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_Dell_server_model
|
get_Dell_server_model
|
||||||
|
|
@ -54,11 +54,11 @@ fi
|
||||||
|
|
||||||
# Log main informations
|
# Log main informations
|
||||||
echo "Server model: $SERVER_MANUFACTURER $SERVER_MODEL"
|
echo "Server model: $SERVER_MANUFACTURER $SERVER_MODEL"
|
||||||
echo "iDRAC/IPMI host: $IDRAC_HOST"
|
echo "iDRAC/IPMI host: \"$IDRAC_HOST\""
|
||||||
|
|
||||||
# Log the fan speed objective, CPU temperature threshold and check interval
|
# Log the fan speed objective, CPU temperature threshold and check interval
|
||||||
echo "Fan speed objective: $DECIMAL_FAN_SPEED%"
|
echo "Fan speed objective: $DECIMAL_FAN_SPEED%"
|
||||||
echo "CPU temperature threshold: $CPU_TEMPERATURE_THRESHOLD°C"
|
echo "CPU temperature threshold: "$CPU_TEMPERATURE_THRESHOLD"°C"
|
||||||
echo "Check interval: ${CHECK_INTERVAL}s"
|
echo "Check interval: ${CHECK_INTERVAL}s"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ fi
|
||||||
# Start monitoring
|
# Start monitoring
|
||||||
while true; do
|
while true; do
|
||||||
# Sleep for the specified interval before taking another reading
|
# Sleep for the specified interval before taking another reading
|
||||||
sleep $CHECK_INTERVAL &
|
sleep "$CHECK_INTERVAL" &
|
||||||
SLEEP_PROCESS_PID=$!
|
SLEEP_PROCESS_PID=$!
|
||||||
|
|
||||||
retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
|
retrieve_temperatures $IS_EXHAUST_TEMPERATURE_SENSOR_PRESENT $IS_CPU2_TEMPERATURE_SENSOR_PRESENT
|
||||||
|
|
@ -124,7 +124,7 @@ while true; do
|
||||||
# Check if user fan control profile is applied then apply it if not
|
# Check if user fan control profile is applied then apply it if not
|
||||||
if $IS_DELL_FAN_CONTROL_PROFILE_APPLIED; then
|
if $IS_DELL_FAN_CONTROL_PROFILE_APPLIED; then
|
||||||
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=false
|
IS_DELL_FAN_CONTROL_PROFILE_APPLIED=false
|
||||||
COMMENT="CPU temperature decreased and is now OK (<= $CPU_TEMPERATURE_THRESHOLD°C), user's fan control profile applied."
|
COMMENT="CPU temperature decreased and is now OK (<= \"$CPU_TEMPERATURE_THRESHOLD\"°C), user's fan control profile applied."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ while true; do
|
||||||
if ! $DELL_POWEREDGE_GEN_14_OR_NEWER; then
|
if ! $DELL_POWEREDGE_GEN_14_OR_NEWER; then
|
||||||
# Enable or disable, depending on the user's choice, third-party PCIe card Dell default cooling response
|
# Enable or disable, depending on the user's choice, third-party PCIe card Dell default cooling response
|
||||||
# No comment will be displayed on the change of this parameter since it is not related to the temperature of any device (CPU, GPU, etc...) but only to the settings made by the user when launching this Docker container
|
# No comment will be displayed on the change of this parameter since it is not related to the temperature of any device (CPU, GPU, etc...) but only to the settings made by the user when launching this Docker container
|
||||||
if $DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE; then
|
if "$DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE"; then
|
||||||
disable_third_party_PCIe_card_Dell_default_cooling_response
|
disable_third_party_PCIe_card_Dell_default_cooling_response
|
||||||
THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Disabled"
|
THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE_STATUS="Disabled"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ function graceful_exit() {
|
||||||
apply_Dell_fan_control_profile
|
apply_Dell_fan_control_profile
|
||||||
|
|
||||||
# Reset third-party PCIe card cooling response to Dell default depending on the user's choice at startup
|
# Reset third-party PCIe card cooling response to Dell default depending on the user's choice at startup
|
||||||
if ! $KEEP_THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE_STATE_ON_EXIT; then
|
if ! "$KEEP_THIRD_PARTY_PCIE_CARD_COOLING_RESPONSE_STATE_ON_EXIT"; then
|
||||||
enable_third_party_PCIe_card_Dell_default_cooling_response
|
enable_third_party_PCIe_card_Dell_default_cooling_response
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -124,8 +124,8 @@ function get_Dell_server_model() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define functions to check if CPU 1 and CPU 2 temperatures are above the threshold
|
# 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 CPU1_OVERHEATING() { [ $CPU1_TEMPERATURE -gt "$CPU_TEMPERATURE_THRESHOLD" ]; }
|
||||||
function CPU2_OVERHEATING() { [ $CPU2_TEMPERATURE -gt $CPU_TEMPERATURE_THRESHOLD ]; }
|
function CPU2_OVERHEATING() { [ $CPU2_TEMPERATURE -gt "$CPU_TEMPERATURE_THRESHOLD" ]; }
|
||||||
|
|
||||||
function print_error() {
|
function print_error() {
|
||||||
local -r ERROR_MESSAGE="$1"
|
local -r ERROR_MESSAGE="$1"
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@
|
||||||
source functions.sh
|
source functions.sh
|
||||||
|
|
||||||
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
|
# Check if the iDRAC host is set to 'local' or not then set the IDRAC_LOGIN_STRING accordingly
|
||||||
if [[ $IDRAC_HOST == "local" ]]; then
|
if [[ "$IDRAC_HOST" == "local" ]]; then
|
||||||
# Check that the Docker host IPMI device (the iDRAC) has been exposed to the Docker container
|
# 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
|
if [ ! -e "/dev/ipmi0" ] && [ ! -e "/dev/ipmi/0" ] && [ ! -e "/dev/ipmidev/0" ]; then
|
||||||
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"
|
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
|
fi
|
||||||
IDRAC_LOGIN_STRING='open'
|
IDRAC_LOGIN_STRING='open'
|
||||||
else
|
else
|
||||||
echo "iDRAC/IPMI username: $IDRAC_USERNAME"
|
echo "iDRAC/IPMI username: \"$IDRAC_USERNAME\""
|
||||||
#echo "iDRAC/IPMI password: $IDRAC_PASSWORD"
|
#echo "iDRAC/IPMI password: \"$IDRAC_PASSWORD\""
|
||||||
IDRAC_LOGIN_STRING="lanplus -H $IDRAC_HOST -U $IDRAC_USERNAME -P $IDRAC_PASSWORD"
|
IDRAC_LOGIN_STRING="lanplus -H \"$IDRAC_HOST\" -U \"$IDRAC_USERNAME\" -P \"$IDRAC_PASSWORD\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature
|
ipmitool -I $IDRAC_LOGIN_STRING sdr type temperature
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue