feat(init): first commit
This commit is contained in:
34
files/common/scripts/install-dependencies.sh
Normal file
34
files/common/scripts/install-dependencies.sh
Normal 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
|
24
files/common/scripts/run.sh
Normal file
24
files/common/scripts/run.sh
Normal 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 $@
|
Reference in New Issue
Block a user