-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_env.sh
42 lines (35 loc) · 879 Bytes
/
set_env.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
#!/bin/bash
prompt_environment() {
echo "Please choose the environment:"
echo "1) production"
echo "2) testing"
echo "3) development"
read -p "Enter the number corresponding to your choice: " env_choice
case $env_choice in
1) ENV="production" ;;
2) ENV="testing" ;;
3) ENV="development" ;;
*) echo -e "\nInvalid choice. Please run the script again and choose a valid option.\n"
prompt_environment
;;
esac
}
confirm_choice() {
read -p $'\nYou have chosen '\''$ENV'\''. Are you sure? (y/n): ' confirm
if [[ $confirm != [yY] ]]; then
echo -e "\nOk, choose a different environment then.\n"
prompt_environment
confirm_choice
fi
}
set_environment() {
cp ".env.$ENV" .env
echo -e "\n.env file for $ENV environment is set."
}
run() {
prompt_environment
confirm_choice
set_environment
}
run
sleep 3