-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup_codespace.sh
executable file
·54 lines (43 loc) · 1.08 KB
/
setup_codespace.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
#!/bin/bash
# Download the jfrog cli
curl -fL https://install-cli.jfrog.io | sh
#!/bin/bash
# Define the configuration file name
config_file=".config"
# Define questions and corresponding default variables
questions=(
"What is your mothership name (https://<your_mothership_name>.jfrog.io/)?"
"What is your username?"
"What is your pasword?"
)
variables=(
"server_name"
"username"
"password"
)
default_values=(
"Not Set"
"Not Set"
"Not Set"
)
# Function to ask a question and store answer
function ask_question() {
local question="$1"
local variable="$2"
local default_value="$3"
echo -n "$question: "
read answer
# If answer is empty, use default value
if [[ -z "$answer" ]]; then
answer="$default_value"
fi
# Save answer in the configuration file
echo "$variable=$answer" >> "$config_file"
}
# Loop through questions and ask the user
for (( i=0; i<${#questions[@]}; i++ )); do
ask_question "${questions[$i]}" "${variables[$i]}" "${default_values[$i]}"
done
echo "**Configuration file updated: $config_file**"
echo "$config_file"
source $config_file