-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add setup script for Ollama installation and update README inst…
…ructions
- Loading branch information
Showing
2 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
# Function to detect OS | ||
get_os() { | ||
case "$(uname -s)" in | ||
Linux*) echo "linux" ;; | ||
Darwin*) echo "macos" ;; | ||
*) echo "unsupported" ;; | ||
esac | ||
} | ||
|
||
# Check if Ollama is already installed | ||
if command_exists ollama; then | ||
echo "Ollama is already installed." | ||
else | ||
echo "Ollama not found. Installing..." | ||
|
||
OS=$(get_os) | ||
case $OS in | ||
"linux") | ||
curl -fsSL https://ollama.com/install.sh | sh | ||
;; | ||
"macos") | ||
brew install ollama | ||
;; | ||
*) | ||
echo "Error: Unsupported operating system" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Check if installation was successful | ||
if ! command_exists ollama; then | ||
echo "Error: Ollama installation failed" | ||
exit 1 | ||
fi | ||
echo "Ollama installed successfully!" | ||
fi | ||
|
||
# Start Ollama service if it's not running | ||
if ! pgrep -x "ollama" >/dev/null; then | ||
echo "Starting Ollama service..." | ||
ollama serve & | ||
sleep 5 # Give some time for the service to start | ||
fi | ||
|
||
# Pull the llama3.1:latest model | ||
echo "Pulling llama3.1:latest model..." | ||
if ollama pull llama3.1:latest; then | ||
echo "Model llama3.1:latest pulled successfully!" | ||
else | ||
echo "Error: Failed to pull llama3.1:latest model" | ||
exit 1 | ||
fi | ||
|
||
echo "Setup completed successfully!" |