-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_ollama.sh
More file actions
executable file
·111 lines (90 loc) · 2.82 KB
/
install_ollama.sh
File metadata and controls
executable file
·111 lines (90 loc) · 2.82 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Install Ollama and ensure LLaVA model is available
set -e
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install Ollama on Debian/Ubuntu
install_ollama_deb() {
echo "Installing Ollama on Debian/Ubuntu..."
curl -fsSL https://ollama.com/install.sh | sh
# Add current user to ollama group
sudo usermod -aG ollama $USER
# Start and enable the service
sudo systemctl enable ollama
sudo systemctl start ollama
# Wait for the service to start
sleep 5
}
# Function to install Ollama on Fedora
install_ollama_fedora() {
echo "Installing Ollama on Fedora..."
# Install required dependencies
sudo dnf -y install lzma libstdc++
# Download and install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Add current user to ollama group
sudo usermod -aG ollama $USER
# Start and enable the service
sudo systemctl enable ollama
sudo systemctl start ollama
# Wait for the service to start
sleep 5
}
# Function to ensure LLaVA model is available
ensure_llava_model() {
echo "Checking for LLaVA model..."
# Check if ollama command is available
if ! command_exists ollama; then
echo "Error: Ollama is not installed or not in PATH"
exit 1
fi
# Check if LLaVA model is already installed
if ollama list | grep -q "llava"; then
echo "LLaVA model is already installed."
else
echo "Pulling LLaVA model... (this may take a while)"
ollama pull llava:7b
fi
# Verify the model is working
echo -e "\nVerifying LLaVA model..."
ollama run llava:7b --version
}
# Main script
main() {
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo "Error: This script should not be run as root"
exit 1
fi
# Detect Linux distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
case $ID in
debian|ubuntu|linuxmint)
if ! command_exists ollama; then
install_ollama_deb
fi
;;
fedora|rhel|centos)
if ! command_exists ollama; then
install_ollama_fedora
fi
;;
*)
echo "Unsupported distribution: $ID"
echo "Please install Ollama manually from https://ollama.com"
exit 1
;;
esac
# Ensure LLaVA model is available
ensure_llava_model
echo -e "\nOllama and LLaVA model are ready to use!"
echo "You may need to log out and log back in for group changes to take effect."
else
echo "Error: Could not detect Linux distribution"
exit 1
fi
}
main "$@"