diff options
author | Thomas Kulik <thomas.kulik@telekom.de> | 2020-11-16 10:43:15 +0100 |
---|---|---|
committer | Thomas Kulik <thomas.kulik@telekom.de> | 2020-11-16 10:57:34 +0100 |
commit | baa0710a9e97c0d7fa4b12ca26ff31322c6d9850 (patch) | |
tree | bcf04d1a04cfc17443b91ed405fa20232b36372c /tools/checkrtd.sh | |
parent | b5454a9e607a98b0bb179b900452dfa1f7d8bf8d (diff) |
Issue-ID: DOC-686
checkrtd.sh and checkdocs.sh added
Signed-off-by: Thomas Kulik <thomas.kulik@telekom.de>
Change-Id: I3e9cd5a2de390d54823af925b7829a39e3f2dae4
Diffstat (limited to 'tools/checkrtd.sh')
-rwxr-xr-x | tools/checkrtd.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/checkrtd.sh b/tools/checkrtd.sh new file mode 100755 index 000000000..1b60a7684 --- /dev/null +++ b/tools/checkrtd.sh @@ -0,0 +1,60 @@ +#!/bin/bash +#set -x # uncomment for bash script debugging + +branch=$1 +file_to_process=$2 + +# +# NOTE: works NOT with elalto release and below because of the submodule structure used for documentation +# + + url_start="https://docs.onap.org/projects/onap" + url_lang="en" +url_branch=${branch} + +# "master" docs are available as "latest" in read-the-docs +if [ "${url_branch}" = "master" ]; then + url_branch="latest" +fi + +#readarray -t array < ./${branch}_releasenotes.log; +readarray -t array < ${file_to_process}; +for line in "${array[@]}" +do + + # example line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst + # example url: https://docs.onap.org/projects/onap-dmaap-messagerouter-messageservice/en/frankfurt/release-notes/release-notes.html + + # extract repo name which comes in square bracktes ([...]) and convert slash (/) to minus (-) + # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst + # output: dmaap-messagerouter-messageservice + url_repo=$(echo ${line} | sed -r 's/].+$//' | sed -r 's/\[//' | sed -r 's/\//-/g') + + # extract rst filename and its path; replace .rst ending with .html + # warning: path does not always contain "docs"! + # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst + # output: release-notes/release-notes.html + url_file=$(echo ${line} | sed -r 's/^.+\]//' | sed -r 's/^.*docs\///' | sed -r 's/\.rst$/\.html/' ) + + # build the full url + url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}" + + # check with curl if html page is accessible (no content check!) + curl --head --silent --fail "${url}" >/dev/null + curl_result=$? + + # "0" and "22" are expected as a curl result + if [ "${curl_result}" = "0" ]; then + curl_result="ok " + elif [ "${curl_result}" = "22" ]; then + curl_result="ERROR" + fi + + echo -e "DBUG: ${line}" + echo -e "DBUG: ${curl_result} ${url}" + echo " " + + ((i++)) +done +unset array +unset i |