|
|
|
|
@ -133,6 +133,21 @@ readonly WEBSITE_MOUNTS="${WEBSITE_MOUNTS:-}" |
|
|
|
|
|
|
|
|
|
PODMAN="$(if command -v podman >/dev/null 2>&1; then echo podman; else echo docker; fi)" |
|
|
|
|
|
|
|
|
|
if ! command -v curl >/dev/null 2>&1; then |
|
|
|
|
if ! command -v wget >/dev/null 2>&1; then |
|
|
|
|
errr 'either `curl` or `wget` must be installed for this script to work.' |
|
|
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
if ! command -v "${PODMAN}" >/dev/null 2>&1; then |
|
|
|
|
errr 'either `podman` or `docker` must be installed for this script to work.' |
|
|
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
about() { |
|
|
|
|
cat <<EOF |
|
|
|
|
Test documentation locally with multiple source repositories. |
|
|
|
|
@ -332,9 +347,10 @@ repo_path() { |
|
|
|
|
done |
|
|
|
|
unset IFS |
|
|
|
|
|
|
|
|
|
echo "ERRR: could not find project '${_repo}' in any of the paths in REPOS_PATH '${REPOS_PATH}'." >&2 |
|
|
|
|
echo "NOTE: you must have a checkout of the project '${_repo}' at '${REPOS_PATH##:*}/${_repo}'." >&2 |
|
|
|
|
echo "NOTE: if you have cloned the repository into a directory with a different name, consider changing it to ${_repo}." >&2 |
|
|
|
|
errr "could not find project '${_repo}' in any of the paths in REPOS_PATH '${REPOS_PATH}'." |
|
|
|
|
note "you must have a checkout of the project '${_repo}' at '${REPOS_PATH##:*}/${_repo}'." |
|
|
|
|
note "if you have cloned the repository into a directory with a different name, consider changing it to ${_repo}." |
|
|
|
|
|
|
|
|
|
unset _repo |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
@ -420,6 +436,50 @@ POSIX_HERESTRING |
|
|
|
|
unset _project _version _repo _path |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await_build() { |
|
|
|
|
url="$1" |
|
|
|
|
req="$(if command -v curl >/dev/null 2>&1; then echo 'curl -s -o /dev/null'; else echo 'wget -q'; fi)" |
|
|
|
|
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
|
if ${req} "${url}"; then |
|
|
|
|
echo |
|
|
|
|
echo "View documentation locally:" |
|
|
|
|
for x in ${url_src_dst_vers}; do |
|
|
|
|
IFS='^' read -r url _ _ <<POSIX_HERESTRING |
|
|
|
|
$x |
|
|
|
|
POSIX_HERESTRING |
|
|
|
|
|
|
|
|
|
if [ -n "${url}" ]; then |
|
|
|
|
if [ "${_url}" != "arbitrary" ]; then |
|
|
|
|
echo " ${url}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
echo |
|
|
|
|
echo 'Press Ctrl+C to stop the server' |
|
|
|
|
else |
|
|
|
|
echo |
|
|
|
|
errr 'The build was interrupted or a build error occurred, check the previous logs for possible causes.' |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
unset url req |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
debg() { |
|
|
|
|
if [ -n "${DEBUG}" ]; then |
|
|
|
|
echo "DEBG: $1" >&2 |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
errr() { |
|
|
|
|
echo "ERRR: $1" >&2 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
note() { |
|
|
|
|
echo "NOTE: $1" >&2 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url_src_dst_vers="$(url_src_dst_vers "$@")" |
|
|
|
|
|
|
|
|
|
volumes="" |
|
|
|
|
@ -445,13 +505,14 @@ POSIX_HERESTRING |
|
|
|
|
|
|
|
|
|
if [ "${_url}" != "arbitrary" ]; then |
|
|
|
|
if [ ! -f "${_src}/_index.md" ]; then |
|
|
|
|
echo "ERRR: Index file '${_src}/_index.md' does not exist." >&2 |
|
|
|
|
echo "Is '${_src}' the correct source directory?" >&2 |
|
|
|
|
errr "Index file '${_src}/_index.md' does not exist." |
|
|
|
|
note "Is '${_src}' the correct source directory?" |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
echo "DEBG: Mounting '${_src}' at container path '${_dst}'" >&2 |
|
|
|
|
debg "DEBG: Mounting '${_src}' at container path '${_dst}'" |
|
|
|
|
|
|
|
|
|
if [ -z "${volumes}" ]; then |
|
|
|
|
volumes="--volume=${_src}:${_dst}" |
|
|
|
|
else |
|
|
|
|
@ -535,33 +596,38 @@ EOF |
|
|
|
|
volumes="${volumes} --volume=${tempfile}:/entrypoint" |
|
|
|
|
readonly volumes |
|
|
|
|
|
|
|
|
|
echo |
|
|
|
|
echo "Documentation will be served at the following URLs:" |
|
|
|
|
for x in ${url_src_dst_vers}; do |
|
|
|
|
IFS='^' read -r url _ _ <<POSIX_HERESTRING |
|
|
|
|
$x |
|
|
|
|
POSIX_HERESTRING |
|
|
|
|
|
|
|
|
|
if [ -n "${url}" ]; then |
|
|
|
|
if [ "${_url}" != "arbitrary" ]; then |
|
|
|
|
echo " ${url}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
echo |
|
|
|
|
"${PODMAN}" run \ |
|
|
|
|
--env "HUGO_REFLINKSERRORLEVEL=${HUGO_REFLINKSERRORLEVEL}" \ |
|
|
|
|
IFS='' read -r cmd <<EOF |
|
|
|
|
${PODMAN} run \ |
|
|
|
|
--env=HUGO_REFLINKSERRORLEVEL=${HUGO_REFLINKSERRORLEVEL} \ |
|
|
|
|
--init \ |
|
|
|
|
--interactive \ |
|
|
|
|
--name "${DOCS_CONTAINER}" \ |
|
|
|
|
--platform linux/amd64 \ |
|
|
|
|
--publish "${DOCS_HOST_PORT}:3002" \ |
|
|
|
|
--publish "3003:3003" \ |
|
|
|
|
--name=${DOCS_CONTAINER} \ |
|
|
|
|
--platform=linux/amd64 \ |
|
|
|
|
--publish=${DOCS_HOST_PORT}:3002 \ |
|
|
|
|
--publish=3003:3003 \ |
|
|
|
|
--rm \ |
|
|
|
|
--tty \ |
|
|
|
|
${volumes} \ |
|
|
|
|
"${DOCS_IMAGE}" \ |
|
|
|
|
${DOCS_IMAGE} \ |
|
|
|
|
/entrypoint |
|
|
|
|
EOF |
|
|
|
|
await_build http://localhost:3002 & |
|
|
|
|
|
|
|
|
|
if [ -n "${DEBUG}" ]; then |
|
|
|
|
${cmd} |
|
|
|
|
else |
|
|
|
|
${cmd} 2>&1| sed \ |
|
|
|
|
-e '/Web Server is available at http:\/\/localhost:3003\/ (bind address 0.0.0.0)/ d' \ |
|
|
|
|
-e '/^hugo server/ d' \ |
|
|
|
|
-e '/fatal: not a git repository (or any parent up to mount point \/)/ d' \ |
|
|
|
|
-e '/Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)./ d' \ |
|
|
|
|
-e "/Makefile:[0-9]*: warning: overriding recipe for target 'docs'/ d" \ |
|
|
|
|
-e "/docs.mk:[0-9]*: warning: ignoring old recipe for target 'docs'/ d" \ |
|
|
|
|
-e '/\/usr\/bin\/make -j 2 proxy hserver-docs HUGO_PORT=3003/ d' \ |
|
|
|
|
-e '/website-proxy/ d' \ |
|
|
|
|
-e '/rm -rf dist*/ d' \ |
|
|
|
|
-e '/Press Ctrl+C to stop/ d' \ |
|
|
|
|
-e '/make/ d' || echo |
|
|
|
|
fi |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
|