/
a.ivakhnenko
/
gitlab-ce
Обзор
Документация
Войти
/
a.ivakhnenko
/
gitlab-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
gitlab-base/scripts/set-config
41 строка
1 KB
IvahAlexander
commit
26 ноя 2024, 07:39
26 ноя 2024, 07:39
a057ac9
Код
Авторство
О чём код?
#!/bin/bash set -eo pipefail TEMPLATE_DIRECTORY="$1" CONFIG_DIRECTORY="${2:-$1}" if [ -z "$TEMPLATE_DIRECTORY" ]; then echo 'usage: set-config <template_directory> [<config_directory>]' exit 1 fi shopt -s nullglob # Don't enter empty for loops if command -v erb &> /dev/null; then echo "Begin parsing .erb templates from $TEMPLATE_DIRECTORY" for template in ${TEMPLATE_DIRECTORY}/*.erb; do output_file="${CONFIG_DIRECTORY}/$(basename $template '.erb')" echo "Writing $output_file" erb -U -r yaml -r json -r fileutils "$template" > "$output_file" done fi if command -v gomplate &> /dev/null; then echo "Begin parsing .tpl templates from $TEMPLATE_DIRECTORY" for template in ${TEMPLATE_DIRECTORY}/*.tpl; do output_file="${CONFIG_DIRECTORY}/$(basename $template '.tpl')" echo "Writing $output_file" gomplate --left-delim '{%' --right-delim '%}' --file "${template}" --out "${output_file}" done fi if [ "$CONFIG_DIRECTORY" != "$TEMPLATE_DIRECTORY" ]; then echo "Copying other config files found in $TEMPLATE_DIRECTORY to $CONFIG_DIRECTORY" for configfile in ${TEMPLATE_DIRECTORY}/*.{yml,yaml,toml,rb,json}; do echo "Copying $(basename $configfile) into ${CONFIG_DIRECTORY}" cp "$configfile" "$CONFIG_DIRECTORY/" done fi shopt -u nullglob