feat(init): first commit

This commit is contained in:
2023-06-05 15:24:42 +02:00
parent 1ee84e57a5
commit b13a5e892f
37 changed files with 926 additions and 2 deletions

View File

@ -0,0 +1,34 @@
#!/bin/bash
set -eo pipefail
main() {
if [ "${INSTALL_DEPENDENCIES}" == "0" ]; then
echo "Dependencies installation disabled. Doing nothing."
exit
fi
install_additional_packages
}
# Return 3 for unknown distribution
install_additional_packages() {
if [ -z "${ADDITIONAL_PACKAGES}" ]; then
return
fi
echo "Installing additional packages '${ADDITIONAL_PACKAGES}'..."
if [ -f "/etc/debian_version" ]; then
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y ${ADDITIONAL_PACKAGES}
elif [ -f "/etc/alpine-release" ]; then
apk update
apk add --no-cache ${ADDITIONAL_PACKAGES}
else
return 3
fi
}
main

View File

@ -0,0 +1,24 @@
#!/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 $@