feat: Move module run logic into its own script (#168)
This will help make the Containerfile just a little bit easier to read (ignoring all the mounts lol). This would also allow us to add logic later to support modules that run executables other than `*.sh`.
This commit is contained in:
parent
3898202bc3
commit
0c7033ccd2
5 changed files with 44 additions and 13 deletions
32
scripts/run_module.sh
Normal file
32
scripts/run_module.sh
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Function to print a centered text banner within a specified width
|
||||
print_banner() {
|
||||
local term_width=120
|
||||
|
||||
local text=" ${1} " # Text to print
|
||||
local padding="$(printf '%0.1s' '='{1..600})"
|
||||
local padlen=0
|
||||
|
||||
if (( ${#text} < term_width )); then
|
||||
padlen=$(( (term_width - ${#text}) / 2 ))
|
||||
fi
|
||||
|
||||
printf '%*.*s%s%*.*s\n' 0 "$padlen" "$padding" "$text" 0 "$padlen" "$padding"
|
||||
}
|
||||
|
||||
title_case() {
|
||||
echo $(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}
|
||||
}
|
||||
|
||||
module=$1
|
||||
params=$2
|
||||
script_path="/tmp/modules/${module}/${module}.sh"
|
||||
|
||||
print_banner "Start $(title_case ${module}) Module"
|
||||
chmod +x ${script_path}
|
||||
${script_path} ${params}
|
||||
print_banner "End $(title_case ${module}) Module"
|
||||
ostree container commit
|
||||
Loading…
Add table
Add a link
Reference in a new issue