#!/usr/bin/env bash # Be very strict set -e set -u set -o pipefail # Get absolute directory of this script CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" ### ### Show Usage ### print_usage() { echo "Usage: gen-readme.sh" echo " gen-readme.sh 5.2" echo " gen-readme.sh 5.3" echo " gen-readme.sh 5.4" echo " gen-readme.sh 5.5" echo " gen-readme.sh 5.6" echo " gen-readme.sh 7.0" echo " gen-readme.sh 7.1" echo " gen-readme.sh 7.2" echo " gen-readme.sh 7.3" echo " gen-readme.sh 7.4" } ### ### Extract PHP modules in alphabetical order and comma separated in one line ### get_modules() { tag="${1}" # Retrieve all modules PHP_MODULES="$( docker run -it --entrypoint=php devilbox/php-fpm:${tag} -m )" # Process module string into correct format for README.md PHP_MODULES="$( echo "${PHP_MODULES}" | sed 's/^\[.*//g' )" # Remove PHP Modules headlines PHP_MODULES="$( echo "${PHP_MODULES}" | sort -fu )" # Unique PHP_MODULES="$( echo "${PHP_MODULES}" | sed '/^\s*$/d' )" # Remove empty lines PHP_MODULES="$( echo "${PHP_MODULES}" | tr '\r\n' ',' )" # Newlines to commas PHP_MODULES="$( echo "${PHP_MODULES}" | sed 's/,,/,/g' )" # Remove PHP Modules headlines PHP_MODULES="$( echo "${PHP_MODULES}" | sed 's/,$//g' )" # Remove trailing comma PHP_MODULES="$( echo "${PHP_MODULES}" | sed 's/,/, /g' )" # Add space to comma echo "${PHP_MODULES}" } ### ### Replace modules in Readme for specified PHP version ### update_readme() { v="${1}" # Those sections must exist in README.md, otherwise this script will exit with errors sed -i'' "s|