#!/usr/bin/env bash # # This script generates the minimal environment variable doc # Move to top level directory REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')") cd "$(dirname "$REAL_PATH")/.." # Make sure sort produces the same output on all systems export LC_ALL=C DOC=docs/minimal-environment-vars.md DOCKERDIR="docker" # BASE and TYPE can be hard coded to centos and rdo since the required vars will always be the same BASE="centos" TYPE="rdo" function write_header { local header=$1 header=${header^} header=$(echo ${header} | sed -e 's/-app//') echo -e "\n# $header\n" >> "$DOC" } function write_env_var { local env_var=$1 if [ -z "$env_var" ]; then echo "" >> "$DOC" else env_var=${env_var%=*} echo " $env_var" >> "$DOC" fi } function find_vars { local img_location=$1 local all_vars='' local scripts=$(find ${img_location} -name *.sh | sort -t / -k 4) for script in $scripts; do local vars=$(awk '/^check_required_vars/,/([^\\] *$)/' $script) all_vars="$all_vars $(echo "$vars" | sed 's/check_required_vars//' | sed 's/\\//g')" done if [ -n "${all_vars// }" ]; then all_vars=$(echo "${all_vars[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') for v in $all_vars; do write_env_var $v done else echo " None" >> "$DOC" fi } cat > $DOC <