2 #set -x # uncomment for bash script debugging
4 # branch, e.g. "master" or "guilin"
6 # logfile produced by checkdocs that contains the list of links
10 # NOTE: works NOT with elalto release and below because of the submodule structure used for documentation
13 url_start="https://docs.onap.org/projects/onap"
18 # "master" docs are available as "latest" in read-the-docs
19 if [ "${url_branch}" = "master" ]; then
23 #readarray -t array < ./${branch}_releasenotes.log;
24 readarray -t array < ${file_to_process};
25 for line in "${array[@]}"
28 # example line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
29 # example url: https://docs.onap.org/projects/onap-dmaap-messagerouter-messageservice/en/frankfurt/release-notes/release-notes.html
31 # extract repo name which comes in square bracktes ([...]) and convert slash (/) to minus (-)
32 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
33 # output: dmaap-messagerouter-messageservice
34 url_repo=$(echo ${line} | sed -r 's/].+$//' | sed -r 's/\[//' | sed -r 's/\//-/g')
36 # extract rst filename and its path; replace .rst ending with .html
37 # warning: path does not always contain "docs"!
38 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
39 # output: release-notes/release-notes.html
40 url_file=$(echo ${line} | sed -r 's/^.+\]//' | sed -r 's/^.*docs\///' | sed -r 's/\.rst$/\.html/' )
43 url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}"
45 # check with curl if html page is accessible (no content check!)
46 # to prevent (server side) cached results a unique element is added to the request
47 curl --head --silent --fail "${url}?${unique}" >/dev/null
50 # "0" and "22" are expected as a curl result
51 if [ "${curl_result}" = "0" ]; then
52 curl_result="accessible"
53 elif [ "${curl_result}" = "22" ]; then
54 curl_result="NOT ACCESSIBLE"
57 #echo -e "DBUG: ${line}"
58 #echo -e "DBUG: ${curl_result} ${url}"
61 echo "${line},${url},${curl_result}"