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
14 # important! only doc project needs a different url base
19 # "master" branch documentation is available as "latest" in RTD
20 if [[ ${url_branch} == "master" ]]; then
24 #readarray -t array < ./${branch}_releasenotes.log;
25 readarray -t array < ${file_to_process};
26 for line in "${array[@]}"
29 reponame=$(echo ${line} | cut -d "[" -f2 | cut -d "]" -f1)
30 #echo "DBUG: reponame=${reponame}"
32 # example line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
33 # example url: https://docs.onap.org/projects/onap-dmaap-messagerouter-messageservice/en/frankfurt/release-notes/release-notes.html
35 # extract repo name which comes in square bracktes ([...]) and convert slash (/) to minus (-)
36 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
37 # output: dmaap-messagerouter-messageservice
38 url_repo=$(echo ${line} | sed -r 's/].+$//' | sed -r 's/\[//' | sed -r 's/\//-/g')
40 # extract rst filename and its path; replace .rst ending with .html
41 # warning: path does not always contain "docs"!
42 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
43 # output: release-notes/release-notes.html
44 url_file=$(echo ${line} | sed -r 's/^.+\]//' | sed -r 's/^.*docs\///' | sed -r 's/\.rst$/\.html/' )
47 if [[ ${reponame} == "doc" ]]; then
48 # build the full url for the doc project
49 url_start="https://docs.onap.org"
50 url="${url_start}/${url_lang}/${url_branch}/${url_file}"
52 # build the full url for the other projects
53 url_start="https://docs.onap.org/projects/onap"
54 url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}"
56 #echo "DBUG: url=$url"
58 # check with curl if html page is accessible (no content check!)
59 # to prevent (server side) cached results a unique element is added to the request
60 curl --head --silent --fail "${url}?${unique}" >/dev/null
63 # "0" and "22" are expected as a curl result
64 if [ "${curl_result}" = "0" ]; then
65 curl_result="accessible"
66 elif [ "${curl_result}" = "22" ]; then
67 curl_result="does not exist"
70 #echo -e "DBUG: ${line}"
71 #echo -e "DBUG: ${curl_result} ${url}"
74 echo "${line},${url},${curl_result}"