diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile.am | 42 | ||||
-rwxr-xr-x | daemon/config/README.md | 4 | ||||
-rw-r--r-- | docker/Dockerfile | 2 | ||||
-rw-r--r-- | docs/Add-more-charts-to-netdata.md (renamed from doc/Add-more-charts-to-netdata.md) | 0 | ||||
-rw-r--r-- | docs/Demo-Sites.md (renamed from doc/Demo-Sites.md) | 0 | ||||
-rw-r--r-- | docs/Donations-netdata-has-received.md (renamed from doc/Donations-netdata-has-received.md) | 0 | ||||
-rw-r--r-- | docs/GettingStarted.md (renamed from doc/GettingStarted.md) | 0 | ||||
-rw-r--r-- | docs/Netdata-Security-and-Disclosure-Information.md (renamed from doc/Netdata-Security-and-Disclosure-Information.md) | 0 | ||||
-rw-r--r-- | docs/Performance.md (renamed from doc/Performance.md) | 0 | ||||
-rw-r--r-- | docs/Running-behind-apache.md (renamed from doc/Running-behind-apache.md) | 0 | ||||
-rw-r--r-- | docs/Running-behind-caddy.md (renamed from doc/Running-behind-caddy.md) | 0 | ||||
-rw-r--r-- | docs/Running-behind-lighttpd.md (renamed from doc/Running-behind-lighttpd.md) | 0 | ||||
-rw-r--r-- | docs/Running-behind-nginx.md (renamed from doc/Running-behind-nginx.md) | 0 | ||||
-rw-r--r-- | docs/Third-Party-Plugins.md (renamed from doc/Third-Party-Plugins.md) | 0 | ||||
-rw-r--r-- | docs/Why-Netdata.md (renamed from doc/Why-Netdata.md) | 0 | ||||
-rw-r--r-- | docs/a-github-star-is-important.md (renamed from doc/a-github-star-is-important.md) | 0 | ||||
-rwxr-xr-x | docs/generator/buildhtml.sh | 60 | ||||
-rwxr-xr-x | docs/generator/buildyaml.sh (renamed from htmldoc/buildyaml.sh) | 100 | ||||
-rwxr-xr-x | docs/generator/checklinks.sh (renamed from htmldoc/checklinks.sh) | 103 | ||||
-rw-r--r-- | docs/generator/requirements.txt (renamed from htmldoc/requirements.txt) | 0 | ||||
-rw-r--r-- | docs/generator/runtime.txt (renamed from htmldoc/runtime.txt) | 0 | ||||
-rw-r--r-- | docs/generator/themes/material/partials/footer.html (renamed from htmldoc/themes/material/partials/footer.html) | 0 | ||||
-rw-r--r-- | docs/high-performance-netdata.md (renamed from doc/high-performance-netdata.md) | 0 | ||||
-rw-r--r-- | docs/netdata-for-IoT.md (renamed from doc/netdata-for-IoT.md) | 0 | ||||
-rw-r--r-- | docs/netdata-security.md (renamed from doc/netdata-security.md) | 0 | ||||
-rwxr-xr-x | htmldoc/buildhtml.sh | 55 | ||||
-rw-r--r-- | installer/README.md | 6 | ||||
-rw-r--r-- | netlify.toml | 4 | ||||
-rw-r--r-- | registry/README.md | 2 | ||||
-rw-r--r-- | web/gui/demosites.html | 8 | ||||
-rw-r--r-- | web/gui/index.html | 2 | ||||
-rw-r--r-- | web/gui/main.js | 2 |
33 files changed, 199 insertions, 197 deletions
diff --git a/.gitignore b/.gitignore index c64d759547..f24583ac28 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,6 @@ sitespeed-result/ python.d/python-modules-installer.sh # documentation generated files -htmldoc/src -htmldoc/build -htmldoc/mkdocs.yml +docs/generator/src +docs/generator/build +docs/generator/mkdocs.yml diff --git a/Makefile.am b/Makefile.am index 82c98a4c13..09abf845ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,22 +62,22 @@ dist_noinst_DATA= \ netdata.cppcheck \ netdata.spec \ package.json \ - doc/Add-more-charts-to-netdata.md \ - doc/Demo-Sites.md \ - doc/Donations-netdata-has-received.md \ - doc/Netdata-Security-and-Disclosure-Information.md \ - doc/Performance.md \ - doc/Running-behind-apache.md \ - doc/Running-behind-caddy.md \ - doc/Running-behind-lighttpd.md \ - doc/Running-behind-nginx.md \ - doc/Third-Party-Plugins.md \ - doc/a-github-star-is-important.md \ - doc/high-performance-netdata.md \ - doc/netdata-for-IoT.md \ - doc/netdata-security.md \ - doc/Why-Netdata.md \ - htmldoc/themes/material/partials/footer.html \ + docs/Add-more-charts-to-netdata.md \ + docs/Demo-Sites.md \ + docs/Donations-netdata-has-received.md \ + docs/Netdata-Security-and-Disclosure-Information.md \ + docs/Performance.md \ + docs/Running-behind-apache.md \ + docs/Running-behind-caddy.md \ + docs/Running-behind-lighttpd.md \ + docs/Running-behind-nginx.md \ + docs/Third-Party-Plugins.md \ + docs/a-github-star-is-important.md \ + docs/high-performance-netdata.md \ + docs/netdata-for-IoT.md \ + docs/netdata-security.md \ + docs/Why-Netdata.md \ + docs/generator/themes/material/partials/footer.html \ installer/README.md \ installer/UNINSTALL.md \ installer/UPDATE.md \ @@ -92,11 +92,11 @@ dist_noinst_SCRIPTS= \ kickstart-static64.sh \ netdata-installer.sh \ installer/functions.sh \ - htmldoc/buildhtml.sh \ - htmldoc/buildyaml.sh \ - htmldoc/checklinks.sh \ - htmldoc/requirements.txt \ - htmldoc/runtime.txt \ + docs/generator/buildhtml.sh \ + docs/generator/buildyaml.sh \ + docs/generator/checklinks.sh \ + docs/generator/requirements.txt \ + docs/generator/runtime.txt \ $(NULL) # ----------------------------------------------------------------------------- diff --git a/daemon/config/README.md b/daemon/config/README.md index 1a64c45460..87f1450d12 100755 --- a/daemon/config/README.md +++ b/daemon/config/README.md @@ -36,7 +36,7 @@ debug log|`/var/log/netdata/debug.log`|The filename to save debug information. T error log|`/var/log/netdata/error.log`|The filename to save error messages for netdata daemon and all plugins (`stderr` is sent here for all netdata programs, including the plugins). You can also set it to `syslog` to send the errors to syslog, or `none` to disable this log. access log|`/var/log/netdata/access.log`|The filename to save the log of web clients accessing netdata charts. You can also set it to `syslog` to send the access log to syslog, or `none` to disable this log. memory mode|save|When set to `save` netdata will save its round robin database on exit and load it on startup. When set to `map` the cache files will be updated in real time (check `man mmap` - do not set this on systems with heavy load or slow disks - the disks will continuously sync the in-memory database of netdata). When set to `ram` the round robin database will be temporary and it will be lost when netdata exits. -update every|1|The frequency in seconds, for data collection. For more information see [Performance](../../doc/Performance.md#performance). +update every|1|The frequency in seconds, for data collection. For more information see [Performance](../../docs/Performance.md#performance). run as user|`netdata`|The user netdata will run as. web files owner|`netdata`|The user that owns the web static files. Netdata will refuse to serve a file that is not owned by this user, even if it has read access to that file. If the user given is not found, netdata will only serve files owned by user given in `run as user`. http port listen backlog|100|The port backlog. Check `man 2 listen`. @@ -107,7 +107,7 @@ External plugins will have only 2 options at `netdata.conf`: setting | default | info :------:|:-------:|:---- -update every|the value of `[global].update every` setting|The frequency in seconds the plugin should collect values. For more information check [Performance](../../doc/Performance.md#performance). +update every|the value of `[global].update every` setting|The frequency in seconds the plugin should collect values. For more information check [Performance](../../docs/Performance.md#performance). command options|*empty*|Additional command line options to pass to the plugin. External plugins that need additional configuration may support a dedicated file in `/etc/netdata`. Check their documentation. diff --git a/docker/Dockerfile b/docker/Dockerfile index 46a39e9ba5..2bad518ede 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -88,7 +88,7 @@ COPY --from=builder /app / RUN \ # Apply permissions as described in - # https://github.com/netdata/netdata/tree/master/doc/netdata-security.md#netdata-directories + # https://github.com/netdata/netdata/tree/master/docs/netdata-security.md#netdata-directories chown -R root:netdata /etc/netdata && \ chown -R netdata:netdata /var/cache/netdata /var/lib/netdata /usr/share/netdata && \ chown -R root:netdata /usr/lib/netdata && \ diff --git a/doc/Add-more-charts-to-netdata.md b/docs/Add-more-charts-to-netdata.md index 1512a25e78..1512a25e78 100644 --- a/doc/Add-more-charts-to-netdata.md +++ b/docs/Add-more-charts-to-netdata.md diff --git a/doc/Demo-Sites.md b/docs/Demo-Sites.md index e20db47fe8..e20db47fe8 100644 --- a/doc/Demo-Sites.md +++ b/docs/Demo-Sites.md diff --git a/doc/Donations-netdata-has-received.md b/docs/Donations-netdata-has-received.md index 9092fb7f4e..9092fb7f4e 100644 --- a/doc/Donations-netdata-has-received.md +++ b/docs/Donations-netdata-has-received.md diff --git a/doc/GettingStarted.md b/docs/GettingStarted.md index c16700d9de..c16700d9de 100644 --- a/doc/GettingStarted.md +++ b/docs/GettingStarted.md diff --git a/doc/Netdata-Security-and-Disclosure-Information.md b/docs/Netdata-Security-and-Disclosure-Information.md index 86adfeeb93..86adfeeb93 100644 --- a/doc/Netdata-Security-and-Disclosure-Information.md +++ b/docs/Netdata-Security-and-Disclosure-Information.md diff --git a/doc/Performance.md b/docs/Performance.md index c8cc1cc0db..c8cc1cc0db 100644 --- a/doc/Performance.md +++ b/docs/Performance.md diff --git a/doc/Running-behind-apache.md b/docs/Running-behind-apache.md index 775bcf2fe9..775bcf2fe9 100644 --- a/doc/Running-behind-apache.md +++ b/docs/Running-behind-apache.md diff --git a/doc/Running-behind-caddy.md b/docs/Running-behind-caddy.md index 135610282b..135610282b 100644 --- a/doc/Running-behind-caddy.md +++ b/docs/Running-behind-caddy.md diff --git a/doc/Running-behind-lighttpd.md b/docs/Running-behind-lighttpd.md index a195c8fa80..a195c8fa80 100644 --- a/doc/Running-behind-lighttpd.md +++ b/docs/Running-behind-lighttpd.md diff --git a/doc/Running-behind-nginx.md b/docs/Running-behind-nginx.md index 505bad81d6..505bad81d6 100644 --- a/doc/Running-behind-nginx.md +++ b/docs/Running-behind-nginx.md diff --git a/doc/Third-Party-Plugins.md b/docs/Third-Party-Plugins.md index 3e58bfb9ac..3e58bfb9ac 100644 --- a/doc/Third-Party-Plugins.md +++ b/docs/Third-Party-Plugins.md diff --git a/doc/Why-Netdata.md b/docs/Why-Netdata.md index 57ff722ec6..57ff722ec6 100644 --- a/doc/Why-Netdata.md +++ b/docs/Why-Netdata.md diff --git a/doc/a-github-star-is-important.md b/docs/a-github-star-is-important.md index c00fba300e..c00fba300e 100644 --- a/doc/a-github-star-is-important.md +++ b/docs/a-github-star-is-important.md diff --git a/docs/generator/buildhtml.sh b/docs/generator/buildhtml.sh new file mode 100755 index 0000000000..82196d66f0 --- /dev/null +++ b/docs/generator/buildhtml.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# buildhtml.sh + +# Builds the html static site, using mkdocs +# Assumes that the script is executed either from the htmldoc folder (by netlify), or from the root repo dir (as originally intended) +currentdir=$(pwd | awk -F '/' '{print $NF}') +echo "$currentdir" +if [ "$currentdir" = "generator" ]; then + cd ../.. +fi +GENERATOR_DIR="docs/generator" + +# Copy all netdata .md files to docs/generator/src. Exclude htmldoc itself and also the directory node_modules generatord by Netlify +echo "Copying files" +rm -rf ${GENERATOR_DIR}/src +find . -type d \( -path ./${GENERATOR_DIR} -o -path ./node_modules \) -prune -o -name "*.md" -print | cpio -pd ${GENERATOR_DIR}/src + +# Modify the first line of the main README.md, to enable proper static html generation +sed -i '0,/# netdata /s//# Introduction\n\n/' ${GENERATOR_DIR}/src/README.md + +# Remove specific files that don't belong in the documentation +declare -a EXCLUDE_LIST=( + "HISTORICAL_CHANGELOG.md" + "collectors/charts.d.plugin/mem_apps/README.md" + "collectors/charts.d.plugin/postfix/README.md" + "collectors/charts.d.plugin/tomcat/README.md" + "collectors/charts.d.plugin/sensors/README.md" + "collectors/charts.d.plugin/cpu_apps/README.md" + "collectors/charts.d.plugin/squid/README.md" + "collectors/charts.d.plugin/nginx/README.md" + "collectors/charts.d.plugin/hddtemp/README.md" + "collectors/charts.d.plugin/cpufreq/README.md" + "collectors/charts.d.plugin/mysql/README.md" + "collectors/charts.d.plugin/exim/README.md" + "collectors/charts.d.plugin/apache/README.md" + "collectors/charts.d.plugin/load_average/README.md" + "collectors/charts.d.plugin/phpfpm/README.md" +) +for f in "${EXCLUDE_LIST[@]}"; do + rm "${GENERATOR_DIR}/src/$f" +done + +echo "Creating mkdocs.yaml" + +# Generate mkdocs.yaml +${GENERATOR_DIR}/buildyaml.sh >${GENERATOR_DIR}/mkdocs.yml + +echo "Fixing links" + +# Fix links (recursively, all types, executing replacements) +${GENERATOR_DIR}/checklinks.sh -rax +if [ $? -eq 1 ]; then exit 1; fi + +echo "Calling mkdocs" + +# Build html docs +mkdocs build --config-file=${GENERATOR_DIR}/mkdocs.yml + +echo "Finished" diff --git a/htmldoc/buildyaml.sh b/docs/generator/buildyaml.sh index 039a40c191..14e019fabb 100755 --- a/htmldoc/buildyaml.sh +++ b/docs/generator/buildyaml.sh @@ -1,6 +1,7 @@ #!/bin/bash -cd htmldoc/src +GENERATOR_DIR="docs/generator" +cd ${GENERATOR_DIR}/src # create yaml nav subtree with all the files directly under a specific directory # arguments: @@ -11,37 +12,36 @@ cd htmldoc/src # maxdepth - how many levels of subdirectories do I include in the yaml in this section. 1 means just the top level and is the default if left empty # excludefirstlevel - Optional param. If passed, mindepth is set to 2, to exclude the READMEs in the first directory level -navpart () { - tabs=$1 - dir=$2 - file=$3 - section=$4 - maxdepth=$5 - excludefirstlevel=$6 - spc="" - - i=1 - while [ ${i} -lt ${tabs} ] ; do - spc=" $spc" - i=$[$i + 1] - done - - if [ -z "$file" ] ; then file='*' ; fi - if [[ ! -z "$section" ]] ; then echo "$spc- ${section}:" ; fi - if [ -z "$maxdepth" ] ; then maxdepth=1; fi - if [[ ! -z "$excludefirstlevel" ]] ; then mindepth=2 ; else mindepth=1; fi - - for f in $(find $dir -mindepth $mindepth -maxdepth $maxdepth -name "${file}.md" -printf '%h\0%d\0%p\n' | sort -t '\0' -n | awk -F '\0' '{print $3}'); do - # If I'm adding a section, I need the child links to be one level deeper than the requested level in "tabs" - if [ -z "$section" ] ; then - echo "$spc- '$f'" - else - echo "$spc - '$f'" - fi - done +navpart() { + tabs=$1 + dir=$2 + file=$3 + section=$4 + maxdepth=$5 + excludefirstlevel=$6 + spc="" + + i=1 + while [ ${i} -lt ${tabs} ]; do + spc=" $spc" + i=$((i + 1)) + done + + if [ -z "$file" ]; then file='*'; fi + if [[ -n $section ]]; then echo "$spc- ${section}:"; fi + if [ -z "$maxdepth" ]; then maxdepth=1; fi + if [[ -n $excludefirstlevel ]]; then mindepth=2; else mindepth=1; fi + + for f in $(find $dir -mindepth $mindepth -maxdepth $maxdepth -name "${file}.md" -printf '%h\0%d\0%p\n' | sort -t '\0' -n | awk -F '\0' '{print $3}'); do + # If I'm adding a section, I need the child links to be one level deeper than the requested level in "tabs" + if [ -z "$section" ]; then + echo "$spc- '$f'" + else + echo "$spc - '$f'" + fi + done } - echo -e 'site_name: NetData Documentation repo_url: https://github.com/netdata/netdata repo_name: GitHub @@ -51,6 +51,7 @@ copyright: NetData, 2018 docs_dir: src site_dir: build #use_directory_urls: false +strict: true theme: name: "material" custom_dir: themes/material @@ -100,11 +101,11 @@ nav:' navpart 1 . README "About" -echo -ne " - 'doc/Why-Netdata.md' - - 'doc/Demo-Sites.md' - - 'doc/netdata-security.md' - - 'doc/Donations-netdata-has-received.md' - - 'doc/a-github-star-is-important.md' +echo -ne " - 'docs/Why-Netdata.md' + - 'docs/Demo-Sites.md' + - 'docs/netdata-security.md' + - 'docs/Donations-netdata-has-received.md' + - 'docs/a-github-star-is-important.md' - REDISTRIBUTED.md - CHANGELOG.md " @@ -116,7 +117,7 @@ echo -ne "- Installation: - 'installer/UNINSTALL.md' " -echo -ne "- 'doc/GettingStarted.md' +echo -ne "- 'docs/GettingStarted.md' " echo -ne "- Running netdata: @@ -127,23 +128,22 @@ navpart 2 daemon/config navpart 2 web/server "" "Web server" navpart 3 web/server "" "" 2 excludefirstlevel echo -ne " - Running behind another web server: - - 'doc/Running-behind-nginx.md' - - 'doc/Running-behind-apache.md' - - 'doc/Running-behind-lighttpd.md' - - 'doc/Running-behind-caddy.md' + - 'docs/Running-behind-nginx.md' + - 'docs/Running-behind-apache.md' + - 'docs/Running-behind-lighttpd.md' + - 'docs/Running-behind-caddy.md' " #navpart 2 system navpart 2 database navpart 2 registry -echo -ne " - 'doc/Performance.md' - - 'doc/netdata-for-IoT.md' - - 'doc/high-performance-netdata.md' +echo -ne " - 'docs/Performance.md' + - 'docs/netdata-for-IoT.md' + - 'docs/high-performance-netdata.md' " - navpart 1 collectors "" "Data collection" 1 -echo -ne " - 'doc/Add-more-charts-to-netdata.md' +echo -ne " - 'docs/Add-more-charts-to-netdata.md' - Internal plugins: " navpart 3 collectors/proc.plugin @@ -165,7 +165,7 @@ navpart 3 collectors/apps.plugin navpart 3 collectors/fping.plugin navpart 3 collectors/freeipmi.plugin -echo -ne " - 'doc/Third-Party-Plugins.md' +echo -ne " - 'docs/Third-Party-Plugins.md' " navpart 1 health README "Alarms and notifications" @@ -189,7 +189,7 @@ navpart 2 web/api/queries "" "Queries" 2 echo -ne "- Hacking netdata: - CONTRIBUTING.md - CODE_OF_CONDUCT.md - - 'doc/Netdata-Security-and-Disclosure-Information.md' + - 'docs/Netdata-Security-and-Disclosure-Information.md' - CONTRIBUTORS.md " navpart 2 makeself "" "" 4 @@ -198,9 +198,3 @@ navpart 2 libnetdata "" "libnetdata" 4 navpart 2 contrib navpart 2 tests navpart 2 diagrams/data_structures - - - - - - diff --git a/htmldoc/checklinks.sh b/docs/generator/checklinks.sh index aa9c7262fc..628c6aee5c 100755 --- a/htmldoc/checklinks.sh +++ b/docs/generator/checklinks.sh @@ -1,15 +1,18 @@ #!/bin/bash +# shellcheck disable=SC2181 # Doc link checker # Validates and tries to fix all links that will cause issues either in the repo, or in the html site +GENERATOR_DIR="docs/generator" + dbg () { - if [ $VERBOSE -eq 1 ] ; then printf "%s\n" "${1}" ; fi + if [ "$VERBOSE" -eq 1 ] ; then printf "%s\\n" "${1}" ; fi } printhelp () { - echo "Usage: htmldoc/checklinks.sh [-r OR -f <fname>] [OPTIONS] - -r Recursively check all mds in all child directories, except htmldoc and node_modules (which is generated by netlify) + echo "Usage: docs/generator/checklinks.sh [-r OR -f <fname>] [OPTIONS] + -r Recursively check all mds in all child directories, except docs/generator and node_modules (which is generatord by netlify) -f Just check the passed md file General Options: -x Execute commands. By default the script runs in test mode with no files changed by the script (results and fixes are just shown). Use -x to have it apply the changes. @@ -19,13 +22,13 @@ printhelp () { -a Check all link types -w Check wiki links (and just warn if you see one) -b Check absolute links to the netdata repo (and change them to relative). Only checks links to https://github.com/netdata/netdata/????/master* - -l Check relative links to the netdata repo (and replace them with links that the html static site can live with, under htmldoc/src only) + -l Check relative links to the netdata repo (and replace them with links that the html static site can live with, under docs/generator/src only) -e Check external links, outside the wiki or the repo (useless without adding the -u option, to verify that they're not broken) " } fix () { - if [ $EXECUTE -eq 0 ] ; then + if [ "$EXECUTE" -eq 0 ] ; then echo "-- SHOULD EXECUTE: $1" else dbg "-- EXECUTING: $1" @@ -37,7 +40,7 @@ ck_netdata_absolute () { f=$1 alnk=$2 lnkinfile=$3 - testURL $alnk + testURL "$alnk" if [[ $f =~ ^(.*)/([^/]*)$ ]] ; then fpath="${BASH_REMATCH[1]}" @@ -45,7 +48,7 @@ ck_netdata_absolute () { fi if [ $? -eq 0 ] ; then - rlnk=$(echo $alnk | sed 's/https:\/\/github.com\/netdata\/netdata\/....\/master\///g') + rlnk=$(echo "$alnk" | sed 's/https:\/\/github.com\/netdata\/netdata\/....\/master\///g') case $rlnk in \#* ) dbg "-- (#somelink)" ;; */ ) dbg "-- # (path/)" ;; @@ -80,13 +83,13 @@ ck_netdata_absolute () { rest="${BASH_REMATCH[2]}" dbg "-- Target file is at $abspath" fi - relativelink=$(realpath --relative-to=$fpath $abspath) + relativelink=$(realpath --relative-to="$fpath" "$abspath") if [ $? -eq 0 ] ; then - srch=$(echo $lnkinfile | sed 's/\//\\\//g') - if [ $relativelink = "." ] ; then - rplc=$(echo $rest | sed 's/\//\\\//g') + srch=$(echo "$lnkinfile" | sed 's/\//\\\//g') + if [ "$relativelink" = "." ] ; then + rplc=$(echo "$rest" | sed 's/\//\\\//g') else - rplc=$(echo $relativelink/$rest | sed 's/\//\\\//g') + rplc=$(echo "$relativelink/$rest" | sed 's/\//\\\//g') fi fix "sed -i 's/($srch)/($rplc)/g' $f" else @@ -100,9 +103,9 @@ ck_netdata_absolute () { } testURL () { - if [ $TESTURLS -eq 0 ] ; then return 0 ; fi + if [ "$TESTURLS" -eq 0 ] ; then return 0 ; fi dbg "-- Testing URL $1" - curl -sS $1 > /dev/null + curl -sS "$1" > /dev/null if [ $? -gt 0 ] ; then return 1 fi @@ -116,7 +119,7 @@ testinternal () { ilnk=${3} header=${ilnk//-/} dbg "-- Searching for \"$header\" in $ifile" - tr -d ',_.:? `'< $ifile | sed 's/-//g' | grep -i "^\#*$header\$" >/dev/null + tr -d ',_.:? `'< "$ifile" | sed 's/-//g' | grep -i "^\\#*$header\$" >/dev/null if [ $? -eq 0 ] ; then dbg "-- $ilnk found in $ifile" return 0 @@ -171,34 +174,34 @@ ck_netdata_relative () { case "$rlnk" in \#* ) dbg "-- # (#somelink)" - testinternal $f $f $rlnk + testinternal "$f" "$f" "$rlnk" ;; */ ) dbg "-- # (path/)" TRGT="$fpath/${rlnk}README.md" - testf $f $TRGT + testf "$f" "$TRGT" if [ $? -eq 0 ] ; then - if [ $fname != "README.md" ] ; then s="../$rlnk"; fi + if [ "$fname" != "README.md" ] ; then s="../$rlnk"; fi fi ;; - */#* ) + */\#* ) dbg "-- # (path/#somelink)" if [[ $rlnk =~ ^(.*)/#(.*)$ ]] ; then TRGT="$fpath/${BASH_REMATCH[1]}/README.md" LNK="#${BASH_REMATCH[2]}" dbg "-- Look for $LNK in $TRGT" - testf $f $TRGT + testf "$f" "$TRGT" if [ $? -eq 0 ] ; then - testinternal $f $TRGT $LNK + testinternal "$f" "$TRGT" "$LNK" if [ $? -eq 0 ] ; then - if [ $fname != "README.md" ] ; then s="../$rlnk"; fi + if [ "$fname" != "README.md" ] ; then s="../$rlnk"; fi fi fi fi ;; *.md ) dbg "-- # (path/filename.md) -> htmldoc (path/filename/)" - testf $f "$fpath/$rlnk" + testf "$f" "$fpath/$rlnk" if [ $? -eq 0 ] ; then if [[ $rlnk =~ ^(.*)/(.*).md$ ]] ; then if [ "${BASH_REMATCH[2]}" = "README" ] ; then @@ -206,18 +209,18 @@ ck_netdata_relative () { else s="../${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/" fi - if [ $fname != "README.md" ] ; then s="../$s"; fi + if [ "$fname" != "README.md" ] ; then s="../$s"; fi fi fi ;; - *.md#* ) + *.md\#* ) dbg "-- # (path/filename.md#somelink) -> htmldoc (path/filename/#somelink)" if [[ $rlnk =~ ^(.*)#(.*)$ ]] ; then TRGT="$fpath/${BASH_REMATCH[1]}" LNK="#${BASH_REMATCH[2]}" - testf $f $TRGT + testf "$f" "$TRGT" if [ $? -eq 0 ] ; then - testinternal $f $TRGT $LNK + testinternal "$f" "$TRGT" "$LNK" if [ $? -eq 0 ] ; then if [[ $lnk =~ ^(.*)/(.*).md#(.*)$ ]] ; then if [ "${BASH_REMATCH[2]}" = "README" ] ; then @@ -225,24 +228,24 @@ ck_netdata_relative () { else s="../${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/#${BASH_REMATCH[3]}" fi - if [ $fname != "README.md" ] ; then s="../$s"; fi + if [ "$fname" != "README.md" ] ; then s="../$s"; fi fi fi fi fi ;; - *#* ) + *\#* ) dbg "-- # (path#somelink) -> (path/#somelink)" if [[ $rlnk =~ ^(.*)#(.*)$ ]] ; then TRGT="$fpath/${BASH_REMATCH[1]}/README.md" LNK="#${BASH_REMATCH[2]}" - testf $f $TRGT + testf "$f" "$TRGT" if [ $? -eq 0 ] ; then - testinternal $f $TRGT $LNK + testinternal "$f" "$TRGT" "$LNK" if [ $? -eq 0 ] ; then if [[ $rlnk =~ ^(.*)#(.*)$ ]] ; then s="${BASH_REMATCH[1]}/#${BASH_REMATCH[2]}" - if [ $fname != "README.md" ] ; then s="../$s"; fi + if [ "$fname" != "README.md" ] ; then s="../$s"; fi fi fi fi @@ -251,7 +254,7 @@ ck_netdata_relative () { * ) if [ -f "$fpath/$rlnk" ] ; then dbg "-- # (path/someotherfile) $rlnk" - if [ $fpath = "." ] ; then + if [ "$fpath" = "." ] ; then s="https://github.com/netdata/netdata/tree/master/$rlnk" else s="https://github.com/netdata/netdata/tree/master/$fpath/$rlnk" @@ -259,10 +262,10 @@ ck_netdata_relative () { else if [ -d "$fpath/$rlnk" ] ; then dbg "-- # (path) -> htmldoc (path/)" - testf $f "$fpath/$rlnk/README.md" + testf "$f" "$fpath/$rlnk/README.md" if [ $? -eq 0 ] ; then s="$rlnk/" - if [ $fname != "README.md" ] ; then s="../$s"; fi + if [ "$fname" != "README.md" ] ; then s="../$s"; fi fi else echo "-- ERROR: $f - $rlnk is neither a file or a directory. Giving up!" @@ -273,9 +276,9 @@ ck_netdata_relative () { esac if [[ ! -z $s ]] ; then - srch=$(echo $rlnk | sed 's/\//\\\//g') - rplc=$(echo $s | sed 's/\//\\\//g') - fix "sed -i 's/($srch)/($rplc)/g' htmldoc/src/$f" + srch=$(echo "$rlnk" | sed 's/\//\\\//g') + rplc=$(echo "$s" | sed 's/\//\\\//g') + fix "sed -i 's/($srch)/($rplc)/g' $GENERATOR_DIR/src/$f" fi } @@ -283,26 +286,26 @@ ck_netdata_relative () { checklinks () { f=$1 dbg "Checking $f" - while read l ; do + while read -r l ; do for word in $l ; do if [[ $word =~ .*\]\(([^\(\) ]*)\).* ]] ; then lnk="${BASH_REMATCH[1]}" - if [ -z $lnk ] ; then continue ; fi + if [ -z "$lnk" ] ; then continue ; fi dbg "-$lnk" case "$lnk" in mailto:* ) dbg "-- Mailto link, ignoring" ;; https://github.com/netdata/netdata/wiki* ) dbg "-- Wiki Link $lnk" - if [ $CHKWIKI -eq 1 ] ; then echo "-- WARNING: $f - $lnk points to the wiki. Please replace it manually" ; fi + if [ "$CHKWIKI" -eq 1 ] ; then echo "-- WARNING: $f - $lnk points to the wiki. Please replace it manually" ; fi ;; https://github.com/netdata/netdata/????/master* ) dbg "-- Absolute link $lnk" - if [ $CHKABSOLUTE -eq 1 ] ; then ck_netdata_absolute $f $lnk $lnk ; fi + if [ "$CHKABSOLUTE" -eq 1 ] ; then ck_netdata_absolute "$f" "$lnk" "$lnk" ; fi ;; http* ) dbg "-- External link $lnk" - if [ $CHKEXTERNAL -eq 1 ] ; then - testURL $lnk + if [ "$CHKEXTERNAL" -eq 1 ] ; then + testURL "$lnk" if [ $? -eq 1 ] ; then echo "-- ERROR: $f - $lnk is a broken link" EXITCODE=1 @@ -311,12 +314,12 @@ checklinks () { ;; * ) dbg "-- Relative link $lnk" - if [ $CHKRELATIVE -eq 1 ] ; then ck_netdata_relative $f $lnk ; fi + if [ "$CHKRELATIVE" -eq 1 ] ; then ck_netdata_relative "$f" "$lnk" ; fi ;; esac fi done - done < $f + done < "$f" } TESTURLS=0 @@ -372,20 +375,20 @@ done EXITCODE=0 |