|
|
|
@ -3,67 +3,8 @@ |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
function get_target { |
|
|
|
|
local type=$1 |
|
|
|
|
local target=$2 |
|
|
|
|
|
|
|
|
|
# check that the target exists |
|
|
|
|
if [ "$type" == "FILE" ]; then |
|
|
|
|
test -f "$target" || return |
|
|
|
|
elif [ "$type" == "DIR" ]; then |
|
|
|
|
test -d "$target" || return |
|
|
|
|
elif [ "$type" == "FILE-OR-DIR" ]; then |
|
|
|
|
ls "$target" >/dev/null 2>&1 || return |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# convert the target to a full path |
|
|
|
|
# FUDGE! I couldn't get the "docker run" command to work with spaces in the volume targets (although printing |
|
|
|
|
# the command out, then copy-and-pasting it into the terminal worked fine) (and no, using ${var@Q} didn't help). |
|
|
|
|
# So, the next best thing is to allow users to create symlinks to the targets :-/ |
|
|
|
|
echo $(realpath --no-symlinks "$target" ) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
function print_help { |
|
|
|
|
echo "`basename "$0"` {options}" |
|
|
|
|
cat <<EOM |
|
|
|
|
Build and launch the "vasl-templates" container. |
|
|
|
|
|
|
|
|
|
-p --port Web server port number. |
|
|
|
|
--vassal VASSAL installation directory. |
|
|
|
|
-v --vasl Path to the VASL module file (.vmod). |
|
|
|
|
-e --vasl-extensions Path to the VASL extensions directory. |
|
|
|
|
--boards Path to the VASL boards. |
|
|
|
|
--chapter-h Path to the Chapter H notes directory. |
|
|
|
|
--user-files Path to the user files directory. |
|
|
|
|
-k --template-pack Path to a user-defined template pack. |
|
|
|
|
|
|
|
|
|
-t --tag Docker image tag. |
|
|
|
|
--name Docker container name. |
|
|
|
|
-d --detach Detach from the container and let it run in the background. |
|
|
|
|
--no-build Launch the container as-is (i.e. without rebuilding the image first). |
|
|
|
|
--build-network Docker network to use when building the image. |
|
|
|
|
--run-network Docker network to use when running the container. |
|
|
|
|
|
|
|
|
|
Options for the test suite: |
|
|
|
|
--control-tests-port Remote test control port number. |
|
|
|
|
--test-data-vassal Directory containing VASSAL releases. |
|
|
|
|
--test-data-vasl-mods Directory containing VASL modules. |
|
|
|
|
|
|
|
|
|
NOTE: If the port the webapp server is listening on *inside* the container is different |
|
|
|
|
to the port exposed *outside* the container, webdriver image generation (e.g. Shift-Click |
|
|
|
|
on a snippet button, or Chapter H content as images) may not work properly. This is because |
|
|
|
|
a web browser is launched internally with snippet HTML and a screenshot taken of it, but |
|
|
|
|
the HTML will contain links to the webapp server that work from outside the container, |
|
|
|
|
but if those links don't resolve from inside the container, you will get broken images. |
|
|
|
|
In this case, you will need to make such links resolve from inside the container e.g. by |
|
|
|
|
port-forwarding, or via DNS. |
|
|
|
|
EOM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
function main |
|
|
|
|
{ |
|
|
|
|
# initialize |
|
|
|
|
cd `dirname "$0"` |
|
|
|
|
PORT=5010 |
|
|
|
@ -281,3 +222,69 @@ docker run \ |
|
|
|
|
2>&1 \ |
|
|
|
|
| sed -e 's/^/ /' |
|
|
|
|
exit ${PIPESTATUS[0]} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
function get_target { |
|
|
|
|
local type=$1 |
|
|
|
|
local target=$2 |
|
|
|
|
|
|
|
|
|
# check that the target exists |
|
|
|
|
if [ "$type" == "FILE" ]; then |
|
|
|
|
test -f "$target" || return |
|
|
|
|
elif [ "$type" == "DIR" ]; then |
|
|
|
|
test -d "$target" || return |
|
|
|
|
elif [ "$type" == "FILE-OR-DIR" ]; then |
|
|
|
|
ls "$target" >/dev/null 2>&1 || return |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# convert the target to a full path |
|
|
|
|
# FUDGE! I couldn't get the "docker run" command to work with spaces in the volume targets (although |
|
|
|
|
# copying the generated command into the terminal worked fine) (and no, using ${var@Q} didn't help). |
|
|
|
|
# So, the next best thing is to allow users to create symlinks to the targets :-/ |
|
|
|
|
echo $( realpath --no-symlinks "$target" ) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
function print_help { |
|
|
|
|
echo "`basename "$0"` {options}" |
|
|
|
|
cat <<EOM |
|
|
|
|
Build and launch the "vasl-templates" container. |
|
|
|
|
|
|
|
|
|
-p --port Web server port number. |
|
|
|
|
--vassal VASSAL installation directory. |
|
|
|
|
-v --vasl Path to the VASL module file (.vmod). |
|
|
|
|
-e --vasl-extensions Path to the VASL extensions directory. |
|
|
|
|
--boards Path to the VASL boards. |
|
|
|
|
--chapter-h Path to the Chapter H notes directory. |
|
|
|
|
--user-files Path to the user files directory. |
|
|
|
|
-k --template-pack Path to a user-defined template pack. |
|
|
|
|
|
|
|
|
|
-t --tag Docker image tag. |
|
|
|
|
--name Docker container name. |
|
|
|
|
-d --detach Detach from the container and let it run in the background. |
|
|
|
|
--no-build Launch the container as-is (i.e. without rebuilding the image first). |
|
|
|
|
--build-network Docker network to use when building the image. |
|
|
|
|
--run-network Docker network to use when running the container. |
|
|
|
|
|
|
|
|
|
Options for the test suite: |
|
|
|
|
--control-tests-port Remote test control port number. |
|
|
|
|
--test-data-vassal Directory containing VASSAL releases. |
|
|
|
|
--test-data-vasl-mods Directory containing VASL modules. |
|
|
|
|
|
|
|
|
|
NOTE: If the port the webapp server is listening on *inside* the container is different |
|
|
|
|
to the port exposed *outside* the container, webdriver image generation (e.g. Shift-Click |
|
|
|
|
on a snippet button, or Chapter H content as images) may not work properly. This is because |
|
|
|
|
a web browser is launched internally with snippet HTML and a screenshot taken of it, but |
|
|
|
|
the HTML will contain links to the webapp server that work from outside the container, |
|
|
|
|
but if those links don't resolve from inside the container, you will get broken images. |
|
|
|
|
In this case, you will need to make such links resolve from inside the container e.g. by |
|
|
|
|
port-forwarding, or via DNS. |
|
|
|
|
EOM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
main "$@" |
|
|
|
|