WxBox/populate_static.sh
2024-04-05 18:51:21 +03:00

27 lines
589 B
Bash
Executable File

#!/bin/bash
LANG=C
# Define the file path
tmpl_file="./src/http_static.cpp.tmpl";
out_file="./src/http_static.cpp";
static_dir="./src/static/";
echo pwd;
echo whoami;
# Define the body variable with multiline content
body=$(cat "$tmpl_file")
# Iterate over the array
while IFS= read -r tmpl_import; do
echo "Found expression: $tmpl_import"
tmpl_filename="${tmpl_import:1:-1}"
template=$(cat "${static_dir}${tmpl_filename}")
body="${body//"$tmpl_import"/"$template"}"
# Print or save the output
done < <(grep -o "%[^%]*%" <<< "$body")
echo "$body" > "$out_file"
b