From a1edfa7740c1adab65cce4ecb0cde9b03a1df707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Tue, 10 Oct 2023 23:02:26 +0200 Subject: [PATCH 1/2] SOLR-16644: Only warn entropy on Linux --- solr/bin/solr | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/solr/bin/solr b/solr/bin/solr index 101fde35a51..ed1bbf45c89 100644 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -1913,26 +1913,29 @@ function start_solr() { # shellcheck disable=SC2086 nohup "$JAVA" "${SOLR_START_OPTS[@]}" $SOLR_ADDL_ARGS -Dsolr.log.muteconsole \ -jar start.jar "${SOLR_JETTY_CONFIG[@]}" $SOLR_JETTY_ADDL_CONFIG \ - 1>"$SOLR_LOGS_DIR/solr-$SOLR_PORT-console.log" 2>&1 & echo $! > "$SOLR_PID_DIR/solr-$SOLR_PORT.pid" + 1>"$SOLR_LOGS_DIR/solr-$SOLR_PORT-console.log" 2>&1 & echo $! > "$SOLR_PID_DIR/solr-$SOLR_PORT.pid" - # Get the current entropy available - entropy_avail=$(cat /proc/sys/kernel/random/entropy_avail) + # Check and warn about low entropy on Linux systems + if [ -e /proc/sys/kernel/random ]; then + # Get the current entropy available + entropy_avail=$(cat /proc/sys/kernel/random/entropy_avail) - # Get the pool size - pool_size=$(cat /proc/sys/kernel/random/poolsize) + # Get the pool size + pool_size=$(cat /proc/sys/kernel/random/poolsize) - # Check if entropy is available and pool size is non-zero - if [[ $entropy_avail -gt 0 && $pool_size -ne 0 ]]; then + # Check if entropy is available and pool size is non-zero + if [[ $entropy_avail -gt 0 && $pool_size -ne 0 ]]; then # Compute the ratio of entropy available to pool size ratio=$(awk -v ea="$entropy_avail" -v ps="$pool_size" 'BEGIN {print (ea/ps)*100}') - + # Check if the ratio is less than 25% if (( $(echo "$ratio < 25" | bc -l) )); then echo "Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require" echo "RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'." fi - else + else echo "Error: Either no entropy is available or the pool size is zero." + fi fi # no lsof on cygwin though From 7b0e65903c53b098de1fa5a8fcf2a98026397c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Tue, 10 Oct 2023 23:14:39 +0200 Subject: [PATCH 2/2] Replace tab with spaces --- solr/bin/solr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solr/bin/solr b/solr/bin/solr index ed1bbf45c89..30c3e3aa52b 100644 --- a/solr/bin/solr +++ b/solr/bin/solr @@ -1913,7 +1913,7 @@ function start_solr() { # shellcheck disable=SC2086 nohup "$JAVA" "${SOLR_START_OPTS[@]}" $SOLR_ADDL_ARGS -Dsolr.log.muteconsole \ -jar start.jar "${SOLR_JETTY_CONFIG[@]}" $SOLR_JETTY_ADDL_CONFIG \ - 1>"$SOLR_LOGS_DIR/solr-$SOLR_PORT-console.log" 2>&1 & echo $! > "$SOLR_PID_DIR/solr-$SOLR_PORT.pid" + 1>"$SOLR_LOGS_DIR/solr-$SOLR_PORT-console.log" 2>&1 & echo $! > "$SOLR_PID_DIR/solr-$SOLR_PORT.pid" # Check and warn about low entropy on Linux systems if [ -e /proc/sys/kernel/random ]; then