generateToolsREADME.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # start script from it's folder
  3. cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null || exit
  4. # Standard file locations
  5. homedir='../../'
  6. . ../env.sh
  7. ## Generate Tools Table
  8. unset table
  9. nTools=$( jq '.tools | length' "$appinfo")
  10. for tool in $(seq 0 $(( nTools - 1 ))); do
  11. info=$( jq ".tools | sort_by(.File) | .[$tool]" "$appinfo" )
  12. # Get Tool Path
  13. FILE=$( echo "$info" | jq '.File' | tr -d '"' )
  14. FILE="[$FILE]($Scripts$FILE)"
  15. # Get Tool Description
  16. DESC=$( echo "$info" | jq '.Description' | tr -d '"' )
  17. # Get Tool Type
  18. TYPE=$( echo "$info" | jq '.Type' | tr -d '"' )
  19. [ "$TYPE" == "null" ] && TYPE="Install"
  20. # Get Tool runner
  21. EXEC=$( echo "$info" | jq '.Exec' | tr -d '"' )
  22. [ "$EXEC" == "null" ] && EXEC="bash"
  23. # Get Tool wget link
  24. WGET=$( echo "$info" | jq '.wget' | tr -d '"' )
  25. if [ "$WGET" != "null" ]; then
  26. WGET="wget -qO- $WGET \| $EXEC"
  27. else
  28. unset WGET
  29. fi
  30. # Get Tool Installation Doc
  31. Doc=$( echo "$info" | jq '.Doc' | tr -d '"' )
  32. if [ "$Doc" != "null" ]; then
  33. DocLink="[Documentation]($Docs$Doc)"
  34. else
  35. unset DocLink
  36. fi
  37. line="|$FILE|$DocLink|$TYPE|$DESC|$WGET|"
  38. if [ "$tool" == "0" ] ; then
  39. table=$line
  40. else
  41. table=$( echo -e "$table\n$line")
  42. fi
  43. done
  44. cp -f "$TOOLSREADME_TEMPLATE" "$TOOLSREADME"
  45. echo -e "$table" >> "$TOOLSREADME"