Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre_exec_hooks #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .docker_scripts/docker_commands.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ source $ROOT_DIR/.docker_scripts/file_handling.bash
#storage variable for the return value of the docker exec command
DOCKER_EXEC_RETURN_VALUE=1

run_pre_exec_hooks(){
PRE_EXEC_HOOKS_DIR="$ROOT_DIR/image_setup/02_devel_image/pre_exec_hooks"
if [ -d $PRE_EXEC_HOOKS_DIR ]; then
for script in $(find $PRE_EXEC_HOOKS_DIR -regextype sed -regex "^.*/[0-9]\{2\}[-a-zA-Z0-9._]*.bash$" | sort); do
$PRINT_WARNING "Executing: $(basename $script) in $PRE_EXEC_HOOKS_DIR"
bash $script
done
fi
}

check_run_args_changed(){
CURRENT_RUN_ARGS=$(echo $DOCKER_RUN_ARGS $DOCKER_XSERVER_ARGS | md5sum | cut -b 1-32)
OLD_RUN_ARGS=$(read_value_from_config_file RUN_ARGS_${EXECMODE})
Expand Down
3 changes: 3 additions & 0 deletions .docker_scripts/exec.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

CMD_STRING=""

### RUNNING SCRIPTS LOCATED IN image_setup/02_devel_image/pre_exec_hooks ON HOST
run_pre_exec_hooks

### EVALUATE ARGUMENTS AND SET EXECMODE
EXECMODE=$1
if [[ " ${EXECMODES[*]} " =~ " $EXECMODE " ]]; then
Expand Down
4 changes: 4 additions & 0 deletions image_setup/02_devel_image/pre_exec_hooks/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### INFO
In order to execute scripts on the host before generating or starting a container, for instance for creating udev rules, you may place bash scripts in this folder
The scripts need a double digit numbered prefix and a .bash file ending (e.g. 01_hello_world.bash)
Scripts will be executed in order!