-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_env.sh
executable file
·51 lines (43 loc) · 1.57 KB
/
update_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
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Function to display a spinner while waiting
show_spinner() {
local pid=$1
local delay=0.2
local spin_chars="/-\\|"
# Show the spinner while the process with the given PID is running
while ps -p "$pid" >/dev/null 2>&1; do
for i in $(seq 0 3); do
echo -ne "\r${spin_chars:i:1} Fetching..."
sleep $delay
done
done
echo -ne "\r \r" # Clear the spinner
}
# Inform the user that the script is starting
echo "🚀 Starting to fetch credentials from 1Password..."
# Fetch the ANTHROPIC_API_KEY
echo "🔑 Fetching ANTHROPIC_API_KEY..."
{
ANTHROPIC_API_KEY=$(op read "op://Employee/Claude/credential") # Fetch credential
} & # Run in background
show_spinner $! # Show spinner while fetching
echo "✅ ANTHROPIC_API_KEY fetched successfully."
# Fetch the TAVILY_API_KEY with progress indication
echo "🔑 Fetching TAVILY_API_KEY..."
{
TAVILY_API_KEY=$(op read "op://Employee/Tavily/credential") # Fetch credential
} &
show_spinner $!
echo "✅ TAVILY_API_KEY fetched successfully."
# Inform the user that the script is updating the .env file
echo "📝 Updating .env file..."
# Update the credentials in the .env file without a progress bar
{
sed -i '' '/^ANTHROPIC_API_KEY=/d' .env
echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >>.env
sed -i '' '/^TAVILY_API_KEY=/d' .env
echo "TAVILY_API_KEY=$TAVILY_API_KEY" >>.env
}
echo "✅ Credentials added to .env."
# Inform the user that the process is complete
echo "🎉 All done! .env file has been updated successfully."