-
Notifications
You must be signed in to change notification settings - Fork 22
/
options.sh
executable file
·53 lines (44 loc) · 1.35 KB
/
options.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
#!/bin/bash
# Check if STACK_NAME environment variable is set
if [ -z "$STACK_NAME" ]; then
# Array to hold selected options
choices=()
# Options array
options=("PreRequisiteStack" "WAFStack" "ShieldAdvancedStack" "AutoUpdatedManagedIpSets")
# Calculate the height (number of options + 5)
height=$(( ${#options[@]} + 5 ))
# Function to display menu and capture selections using fzf
display_menu() {
npx cfonts "AWS FIREWALL FACTORY" \
--font block \
--align center \
--colors "#00ecbd" \
--background "transparent" \
--letter-spacing 0 \
--line-height 0 \
--space true \
--max-length 13 \
--env "node" \
--width "80%"
echo "© by globaldatanet"
selections=$(printf "%s\n" "${options[@]}" | fzf --multi --prompt="Select which stack you want to deploy: " --height=${height} --bind 'space:toggle' --no-info)
# Add selections to choices array
for choice in $selections; do
choices+=("$choice")
done
}
# Function to process selections
process_choices() {
echo "You selected:"
for choice in "${choices[@]}"; do
echo "- $choice"
export "STACK_NAME=$choice"
echo "Environment variable STACK_NAME set to $STACK_NAME"
done
}
# Main script
display_menu
process_choices
else
echo "STACK_NAME environment variable is already set to '$STACK_NAME'"
fi