Binary Fork Template

Some programs that need to be run are compiled binaries. Unfortunately, this is not straightforward, because we need to use a shared file system to provide executable utilities for both Solaris and Linux systems. Because of this, we need another intermediate symlinked script between ISGScriptStartTemplate and the binary itself to ensure the correct executable is selected.

A precondition for this script is that setup has already been run properly, likely via start_template. This simplifies the operation of binary_fork_template as it can assume it already has a sensible path.

There is a helper program that tries to report a helpful error message if the binary cannot be executed. This could happen, for example, if the user had permission to execute binary_fork_template (which all users do out of necessity), but the binaries are restricted to course accounts.

execute () {
   if [ ! -x "$(new-which "$1")" ]; then
      echo "Error: Cannot execute the binary for $progname ($1)" >&2
      exit -1
   fi
   exec "$@"
}

Then, all the program has to do otherwise is determine what architecture it is running on. To do this, it can make use of uname.

readonly progname="$(basename "$0" _impl)"

if [ "$(uname -s)" = "SunOS" ]; then
   execute "${progname}_solaris" "$@"
else
   execute "${progname}_linux" "$@"
fi

Because we know setup has already been run, the only requirement is that the _solaris and _linux executables exist somewhere in the subdirectories of ~isg/bin.

Topic revision: r1 - 2010-10-18 - TerryVaskor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback