Skip to content

Commit

Permalink
Improve all.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Sep 23, 2024
1 parent 346a074 commit cf552db
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions all.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
#!/bin/sh


log() {
# Echo the timestamp followed by the original message
echo "[$(date "+%Y-%m-%dT%H:%M:%S%z")][all] - $1"
}
# Function to execute the script
execute_script() {
script_path="https://elastic.github.io/kibana-demo-data/scripts/$1.sh"
curl "$script_path" | sh &
curl -fsSL "$script_path" | sh
}

# Function to search for a string in the array of arguments
search_string_in_args() {
search=$1
shift
for arg in "$@"; do
if [ "$arg" = "$search" ]; then
return 0
fi
done
return 1
}

# available scripts
scripts="custom o11y sample security makelogs"

if [ $# -eq 0 ]; then
# execute all scripts
log "Executing all scripts"
for script in $scripts; do
execute_script "$script"
done
else
# execute scripts based on arguments
for script in $scripts; do

if search_string_in_args "$script" "$@"; then
log "Executing $script"
execute_script "$script"
fi
done
fi

wait
log "Finished execution"

0 comments on commit cf552db

Please sign in to comment.