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 #reponame="[${reponame}]"
31 #echo "DBUG: reponame=${reponame}"
33 # example line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
34 # example url: https://docs.onap.org/projects/onap-dmaap-messagerouter-messageservice/en/frankfurt/release-notes/release-notes.html
36 # extract repo name which comes in square bracktes ([...]) and convert slash (/) to minus (-)
37 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
38 # output: dmaap-messagerouter-messageservice
39 url_repo=$(echo ${line} | sed -r 's/].+$//' | sed -r 's/\[//' | sed -r 's/\//-/g')
41 # extract rst filename and its path; replace .rst ending with .html
42 # warning: path does not always contain "docs"!
43 # line: [dmaap/messagerouter/messageservice]/docs/release-notes/release-notes.rst
44 # output: release-notes/release-notes.html
45 url_file=$(echo ${line} | sed -r 's/^.+\]//' | sed -r 's/^.*\/docs\///' | sed -r 's/\.rst$/\.html/' )
47 #echo "DBUG: line = ${line}"
48 #echo "DBUG: url_file = ${url_file}"
49 #echo "DBUG: url_repo = ${url_repo}"
50 #echo "DBUG: reponame = ${reponame}"
53 if [[ ${reponame} == "doc" ]]; then
54 # build the full url for the doc project
55 url_start="https://docs.onap.org"
56 url="${url_start}/${url_lang}/${url_branch}/${url_file}"
58 # build the full url for the other projects
59 url_start="https://docs.onap.org/projects/onap"
60 url="${url_start}-${url_repo}/${url_lang}/${url_branch}/${url_file}"
63 #echo "DBUG: url = $url"
65 # check with curl if html page is accessible (no content check!)
66 # to prevent (server side) cached results a unique element is added to the request
67 curl --head --silent --fail "${url}?${unique}" >/dev/null
70 # "0" and "22" are expected as a curl result
71 if [ "${curl_result}" = "0" ]; then
72 curl_result="accessible"
73 elif [ "${curl_result}" = "22" ]; then
74 curl_result="does not exist"
77 #echo -e "DBUG: ${line}"
78 #echo -e "DBUG: ${curl_result} ${url}"
81 echo "${line},${url},${curl_result}"