Skip to content

Commit

Permalink
Set up environment for API key usage
Browse files Browse the repository at this point in the history
- Added installer script to automate the setup process
- Script checks for root/sudo access and operating system to install required packages
- Prompts user for API key and adds it to the Docker Compose file
- Clones Git repo and runs Docker Compose to start the setup

[installer.sh]
- Check if user has root/sudo access
- Check user's operating system and install required packages
- Clone Git repo and run Docker Compose
- Prompt user for API key
- Replace API key variable in Docker Compose file
- Start Docker Compose
  • Loading branch information
Shubham Verlekar committed Feb 19, 2023
1 parent 7c6f8c3 commit 04a68f0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Check if user has root/sudo access
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be run as root or with sudo."
exit 1
fi

# Check user's operating system
os=$(uname -s)
case $os in
Linux)
# Install required packages using package manager
if command -v apt-get &> /dev/null; then
echo "Installing packages using apt-get..."
apt-get update
apt-get install -y git docker.io docker-compose
echo "Packages installed successfully."
elif command -v yum &> /dev/null; then
echo "Installing packages using yum..."
yum update
yum install -y git docker docker-compose
echo "Packages installed successfully."
else
echo "Unsupported package manager."
exit 1
fi
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac

# Clone Git repo and run Docker Compose
echo "Cloning Git repo..."
git clone https://github.com/example/repo.git
cd repo

# Prompt user for API key
read -p "Enter your OpenAI API key: " api_key

# Replace API key variable in Docker Compose file
sed -i "s/OPENAI_API_KEY:.*/OPENAI_API_KEY: \"$api_key\"/g" docker-compose.yml

# Start Docker Compose
echo "Starting Docker containers..."
docker-compose up -d
echo "Docker containers started successfully."

0 comments on commit 04a68f0

Please sign in to comment.