Skip to content

Commit

Permalink
Auto-detect required bash, sed, and JDK versions (#297)
Browse files Browse the repository at this point in the history
* Only start Hadoop Yarn if using Java 11 or older, since it doesn't
  start using newer Java versions (definitely doesn't work with 17, but
  the change that broke it occurred somewhere between 11 and 17, and may
  depend on whether you're running it with experimental flags; I'm not
  certain of which change broke it, but this gets Uno working again for
  both 11 and 17)
* Stop making assumptions about sed version based on Darwin OS. The user
  could have installed GNU sed. Instead, check for GNU sed vs. BSD sed
  explicitly
* Stop making assumptions about bash version based on Darwin OS. The
  user could have installed a newer version of bash. Instead, check the
  bash version explicitly for the feature that requires 4.1 or later
  • Loading branch information
ctubbsii authored Nov 14, 2023
1 parent 6974b46 commit 189f898
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 5 additions & 3 deletions bin/impl/load-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ fi
hash shasum 2>/dev/null || { echo >&2 "shasum must be installed & on PATH. Aborting."; exit 1; }
hash sed 2>/dev/null || { echo >&2 "sed must be installed & on PATH. Aborting."; exit 1; }

if [[ $OSTYPE =~ ^darwin ]]; then
export SED="sed -i .bak"
else
if sed --version >/dev/null 2>&1; then
# GNU sed supports --version and -i without a backup suffix parameter
export SED="sed -i"
else
# BSD sed requires backup suffix parameter with -i
export SED="sed -i .bak"
fi

# load-env.sh
8 changes: 7 additions & 1 deletion bin/impl/run/hadoop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ trap 'echo "[ERROR] Error occurred at $BASH_SOURCE:$LINENO command: $BASH_COMMAN

"$HADOOP_HOME"/bin/hdfs namenode -format
"$HADOOP_HOME"/sbin/start-dfs.sh
"$HADOOP_HOME"/sbin/start-yarn.sh
# Yarn won't start on newer versions of Java
jver=$("$JAVA_HOME"/bin/java -version 2>&1 | grep version | cut -f2 -d'"' | cut -f1 -d.)
if [[ $jver -gt 11 ]]; then
echo "Skipping yarn because it doesn't start on Java $jver"
else
"$HADOOP_HOME"/sbin/start-yarn.sh
fi

namenode_port=9870
if [[ $HADOOP_VERSION =~ ^2\..*$ ]]; then
Expand Down
4 changes: 3 additions & 1 deletion bin/impl/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ function setup_component() {
}

function save_console_fd {
if [[ -z $UNO_CONSOLE_FD && ! $OSTYPE =~ ^darwin ]]; then
# this requires at least bash 4.1
local v=("${BASH_VERSINFO[@]}")
if [[ -z $UNO_CONSOLE_FD ]] && (( v[0]>4 || (v[0]==4 && v[1]>=1) )); then
# Allocate an unused file descriptor and make it dup stdout
# https://stackoverflow.com/a/41620630/7298689
exec {UNO_CONSOLE_FD}>&1
Expand Down

0 comments on commit 189f898

Please sign in to comment.