This is not a best practices guide, please look forward to: https://mywiki.wooledge.org/BashGuide
For example, using cd "$(dirname "$0")" to get the scripts location is not reliable, you could use a more sophisticated option such as: $(dirname $BASH_SOURCE)