install/.helpers/gen_empty_sections.sh
2019-06-25 23:03:46 +03:00

26 lines
582 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# 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 "$PWD/$x.sh" ] && continue
# generate empty section file
cat>"$PWD/$x.sh" << EOB
# $x
[ -z "\${A_DEFAULT_SETTINGS_${y}}" ] \\
&& A_DEFAULT_SETTINGS_${y}=\$(cat << EOF
[$x]
EOF
)
EOB
done