Skip to content

Commit

Permalink
scripts/deploy.sh: implement docs_readme function
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Jul 9, 2023
1 parent bbac2ae commit e178a16
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,47 @@
# little helper for docker deployment to:
# - start development environment for IronOS ("shell" sub-command)
# - generate full set of builds ("build" sub-command)
# - probably doing some other routines (check source briefly before running undocumented commands!)

#set -x
#set -e

### helper functions

usage()
{
echo -e "\nUsage: ${0} [CMD]\n"
echo "CMD:"
echo "CMD (docker related):"
echo -e "\tshell - start docker container with shell inside to work on IronOS with all tools needed"
echo -e "\tbuild - compile builds of IronOS inside docker container for supported hardware"
echo -e "\tclean - delete created docker container (but not pre-downloaded data for it)\n"
echo "CMD (helper routines):"
echo -e "\tdocs_readme - generate README.md inside Documentation/ based on nav section from mkdocs.yml\n"
echo -e "STORAGE NOTICE: for \"shell\" and \"build\" commands extra files will be downloaded so make sure that you have ~5GB of free space.\n"
}

docs_readme()
{
# WARNING: ON RUN Documentaion/README.md WILL BE OVERWRITTEN WITHOUT ANY WARNINGS / CONFIRMATIONS !!!
yml="scripts/IronOS-mkdocs.yml"
md="Documentation/README.md"
# ^^^^ hardcoded paths relative to IronOS/ to make this func very trivial
echo > "${md}"
echo "<!-- THIS FILE IS AUTOGENERATED by \"scripts/deploy.sh docs_readme\" based on nav section in ${yml} config -->" >> "${md}"
echo "<!-- THIS FILE IS NOT SUPPOSED TO BE EDITED MANUALLY -->" >> "${md}"
echo >> "${md}"
echo "#### This is autogenerated README for brief navigation through github over official documentation for IronOS project" >> "${md}"
echo "#### This documentation is also available [here online](https://ralim.github.io/IronOS)" >> "${md}"
echo >> "${md}"
# it probably will become unexplainable in a few months but so far it works:
cat "${yml}" | sed '1,/^nav/d; /^ *$/,$d; s,- ,- [,; s,: ,](../Documentation/,; s,.md,.md),; s,:$,],; s,/Pinecil ,/Pinecil%20,; /^ - \[.*\]$/ s,\[,,; s,]$,,' >> "${md}"
echo ""
echo "${yml} is updated. Do not forget to commit & push changes:"
echo ""
echo " $ git commit ${md} -m \"${md}: update autogenerated file\" && git push"
echo ""
}

### main

docker_conf="Env.yml"
Expand All @@ -42,14 +69,26 @@ if [ -n "${docker_tool}" ] && [ -z "${docker_bin}" ]; then
docker_bin="${docker_tool} compose"
fi;

# give function argument a name

cmd="${1}"

# if only README.md for Documentation update is required then run it & exit

if [ "docs_readme" = "${cmd}" ]; then
${cmd}
exit "${?}"
fi;

# if docker is not presented in any way show warning & exit

if [ -z "${docker_bin}" ]; then
echo "ERROR: Can't find docker-compose nor docker tool. Please, install docker and try again."
exit 1
fi;

# construct command to run

cmd="${1}"
if [ -z "${cmd}" ] || [ "${cmd}" = "shell" ]; then
docker_cmd="run --rm builder"
elif [ "${cmd}" = "build" ]; then
Expand Down

0 comments on commit e178a16

Please sign in to comment.