sp-containers/files/common/scripts/run.sh

24 lines
574 B
Bash
Raw Permalink Normal View History

2023-06-05 15:24:42 +02:00
#!/bin/bash
set -eo pipefail
main() {
echo "Generating filesystem templates..."
generate_templates
exec $@
}
generate_templates() {
# Find *.gotmpl files and generate associated configuration files
local template_files=$(find / -type f -name '*.gotmpl')
for tmpl in $template_files; do
local dest_file=${tmpl%".gotmpl"}
echo "Generating file '$dest_file'..."
gomplate -f "$tmpl" > "$dest_file"
chmod $(stat -c '%a' "$tmpl") "$dest_file"
chown $(stat -c '%u:%g' "$tmpl") "$dest_file"
done
}
main $@