GP-2301: Each launch script can now specify if they require a JDK or JRE

to run.  Allows svrAdmin to run with just a JRE, like the GhidraServer.
This commit is contained in:
Ryan Kurtz
2022-08-11 05:27:06 -04:00
parent aad60ecdd3
commit 4491a0fd6e
18 changed files with 57 additions and 45 deletions
@@ -33,4 +33,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch HeadlessAnalyzer.
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra-Headless "${MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"
@@ -28,4 +28,4 @@ fi
APP_VMARGS="-DGhidraJarBuilder.Name=$(basename "${SCRIPT_FILE}")"
# Launch jar builder
"${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra "${MAXMEM}" "${APP_VMARGS}" ghidra.util.GhidraJarBuilder -main ghidra.JarRun "$@"
"${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${MAXMEM}" "${APP_VMARGS}" ghidra.util.GhidraJarBuilder -main ghidra.JarRun "$@"
@@ -16,4 +16,4 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo
SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Filesystem Conversion
"${SCRIPT_DIR}"/launch.sh fg ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@"
"${SCRIPT_DIR}"/launch.sh fg jdk ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@"
@@ -24,4 +24,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra in debug mode
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"
+21 -12
View File
@@ -19,24 +19,26 @@ umask 027
function showUsage() {
echo "Usage: $0 <mode> <name> <max-memory> \"<vmarg-list>\" <app-classname> <app-args>... "
echo "Usage: $0 <mode> <java-type> <name> <max-memory> \"<vmarg-list>\" <app-classname> <app-args>... "
echo " <mode>: fg run as foreground process in current shell"
echo " bg run as background process in new shell"
echo " debug run as foreground process in current shell in debug mode (suspend=n)"
echo " debug-suspend run as foreground process in current shell in debug mode (suspend=y)"
echo " NOTE: for all debug modes environment variable DEBUG_ADDRESS may be set to "
echo " override default debug address of 127.0.0.1:18001"
echo " <java-type>: jdk requires JDK to run"
echo " jre JRE is sufficient to run (JDK works too)"
echo " <name>: application name used for naming console window"
echo " <max-memory>: maximum memory heap size in MB (e.g., 768M or 2G). Use empty \"\" if default"
echo " should be used. This will generally be upto 1/4 of the physical memory available"
echo " to the OS."
echo " should be used. This will generally be upto 1/4 of the physical memory available"
echo " to the OS."
echo " <vmarg-list>: pass-thru args (e.g., \"-Xmx512M -Dmyvar=1 -DanotherVar=2\") - use"
echo " empty \"\" if vmargs not needed"
echo " empty \"\" if vmargs not needed"
echo " <app-classname>: application classname (e.g., ghidra.GhidraRun )"
echo " <app-args>...: arguments to be passed to the application"
echo " "
echo " Example:"
echo " $0 debug Ghidra 768M \"\" ghidra.GhidraRun"
echo " \"$0\" debug jdk Ghidra 4G \"\" ghidra.GhidraRun"
exit 1
}
@@ -56,17 +58,24 @@ do
MODE=$AA
;;
2)
APPNAME=$AA
if [ "$AA" = "jre" ]; then
JAVA_TYPE_ARG="-java_home"
else
JAVA_TYPE_ARG="-jdk_home"
fi
;;
3)
MAXMEM=$AA
APPNAME=$AA
;;
4)
MAXMEM=$AA
;;
5)
if [ "$AA" != "" ]; then
VMARG_LIST=$AA
fi
;;
5)
6)
CLASSNAME=$AA
;;
*)
@@ -80,7 +89,7 @@ do
done
# Verify that required number of args were provided
if [[ ${INDEX} -lt 5 ]]; then
if [[ ${INDEX} -lt 6 ]]; then
echo "Incorrect launch usage - missing argument(s)"
showUsage
exit 1
@@ -122,13 +131,13 @@ if ! [ -x "$(command -v java)" ] ; then
fi
# Get the JDK that will be used to launch Ghidra
JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -save)"
JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)"
if [ ! $? -eq 0 ]; then
# No JDK has been setup yet. Let the user choose one.
java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -ask
java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -ask
# Now that the user chose one, try again to get the JDK that will be used to launch Ghidra
JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -save)"
JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)"
if [ ! $? -eq 0 ]; then
echo
echo "Failed to find a supported JDK. Please refer to the Ghidra Installation Guide's Troubleshooting section."
@@ -33,4 +33,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra Python
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" "Ghidra-Python" "${MAXMEM}" "${VMARG_LIST}" ghidra.python.PythonRun "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Python" "${MAXMEM}" "${VMARG_LIST}" ghidra.python.PythonRun "$@"
+1 -1
View File
@@ -15,4 +15,4 @@
SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
SCRIPT_DIR="${SCRIPT_FILE%/*}"
"${SCRIPT_DIR}"/launch.sh fg Sleigh "$MAXMEM" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"
"${SCRIPT_DIR}"/launch.sh fg jdk Sleigh "$MAXMEM" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"