commit
7983f09386
3 changed files with 15 additions and 6 deletions
|
|
@ -1,6 +1,8 @@
|
|||
# `script`
|
||||
|
||||
The `script` module can be used to run arbitrary scripts at image build time that take no or minimal external configuration (in the form of command line arguments).
|
||||
The `script` module can be used to run arbitrary bash snippets and scripts at image build time. This is intended for running commands that need no YAML configuration.
|
||||
|
||||
The snippets, which are run in a bash subshell, are declared under `snippets:`.
|
||||
The scripts, which are run from the `config/scripts` directory, are declared under `scripts:`.
|
||||
|
||||
## Creating a Script
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
name: script
|
||||
shortdesc: The script module can be used to run arbitrary scripts at image build time.
|
||||
shortdesc: The script module can be used to run arbitrary bash snippets and scripts at image build time.
|
||||
readme: https://raw.githubusercontent.com/blue-build/modules/main/modules/script/README.md
|
||||
example: |
|
||||
type: script
|
||||
snippets:
|
||||
- "curl https://example.com/examplebinary > /usr/bin/examplebinary" # example: download binary
|
||||
- "ln -sf /usr/bin/ld.bfd /etc/alternatives/ld && ln -sf /etc/alternatives/ld /usr/bin/ld" # example: ld alternatives symlink workaround
|
||||
scripts:
|
||||
- myscript.sh # will run config/scripts/myscript.sh
|
||||
- myscript.sh # example: run config/scripts/myscript.sh
|
||||
|
|
|
|||
|
|
@ -4,13 +4,17 @@
|
|||
set -euo pipefail
|
||||
|
||||
get_yaml_array SCRIPTS '.scripts[]' "$1"
|
||||
get_yaml_array SNIPPETS '.snippets[]' "$1"
|
||||
|
||||
cd "$CONFIG_DIRECTORY/scripts"
|
||||
|
||||
# Make every script executable
|
||||
find "$PWD" -type f -exec chmod +x {} \;
|
||||
|
||||
for SCRIPT in "${SCRIPTS[@]}"; do
|
||||
echo "Running script $SCRIPT"
|
||||
eval "$PWD/$SCRIPT"
|
||||
"$PWD/$SCRIPT"
|
||||
done
|
||||
|
||||
for SNIPPET in "${SNIPPETS[@]}"; do
|
||||
echo "Running snippet $SNIPPET"
|
||||
bash -c "$SNIPPET"
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue