install/.helpers/gen_empty_sections.sh
2019-08-06 20:40:48 +03:00

31 lines
662 B
Bash
Executable File

#!/usr/bin/env bash
set -e
defaultsdir="$(cd "$(dirname "$0")" && pwd)/../.defaults"
# get sections
sections=$(
curl -L https://raw.githubusercontent.com/go-gitea/gitea/master/custom/conf/app.ini.sample 2>/dev/null \
| grep '^\[.*\]' | tr '\n' ' '|tr -d '[' | tr -d ']'
)
for x in $sections; do
# to upper and remove dot
y=$(echo -n "$x" | tr '[:lower:]' '[:upper:]' | tr '.' '_' | tr '-' '_' )
# skip existing files
[ -f "$defaultsdir/$x.sh" ] && continue
# generate empty section file
cat>"$defaultsdir/$x.sh" << EOB
# $x
[ -z "\${A_DEFAULT_SETTINGS_${y}}" ] \\
&& A_DEFAULT_SETTINGS_${y}=\$(cat << EOF
[$x]
EOF
)
EOB
done