-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall.sh
72 lines (62 loc) · 1.71 KB
/
all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/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 -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
}
show_help() {
echo "Usage: $0 [options] [scripts]"
echo
echo "Options:"
echo " --help Show this help message and exit"
echo
echo "Scripts:"
echo " custom Install custom sample data (apache, nginx, kubernetes, etc)"
echo " o11y Install o11y sample data"
echo " sample Install Kibana sample data"
echo " searchkit Install searchkit sample data"
echo " security Install security sample data"
echo " makelogs Install makelogs sample data"
echo " search Data useful for testing search"
echo
echo "If no scripts are specified, all scripts will be executed."
}
# Show available scripts when --help is given
# Check for --help option
if [ "$1" = "--help" ]; then
show_help
exit 0
fi
# available scripts
scripts="custom o11y sample searchkit 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
log "Finished execution"