Shell Compatibility Issue in Nexus Repository 3.78.2-04 Startup Script - Sonatype Nexus Repository - Sonatype Community

Shell Compatibility Issue in Nexus Repository 3.78.2-04 Startup Script

Environment

Issue

During service startup, the following error appears:

/opt/nexus-3.78.2-04/bin/nexus: 155: [[: not found

Root Cause

The startup script (bin/nexus) uses bash-specific syntax with /bin/sh shebang:

#!/bin/sh
# ...
if [[ "${data_dir}" != /* ]]; then  # Line 155
  data_dir="${PARENT}/${data_dir}"
fi

On systems where /bin/sh links to a POSIX-compliant shell like dash, the [[ syntax is unsupported.

Reproduction

Standard startup via systemd produces the error:

Mar 20 21:33:46 host systemd[1]: Starting nexus.service - nexus service...
Mar 20 21:33:46 host nexus[92263]: /opt/nexus-3.78.2-04/bin/nexus: 155: [[: not found
Mar 20 21:33:46 host nexus[92263]: Starting nexus
Mar 20 21:33:46 host systemd[1]: Started nexus.service - nexus service.

Proposed Solutions

  1. Change shebang from #!/bin/sh to #!/bin/bash

OR

  1. Replace bash-specific syntax with POSIX-compliant case statement:
case "${data_dir}" in
     /*)
       ;;
     *)
       data_dir="${PARENT}/${data_dir}"
       ;;
esac

Impact

The issue does not prevent service operation but generates unnecessary warnings during startup.