-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (88 loc) · 2.3 KB
/
install.sh
File metadata and controls
executable file
·105 lines (88 loc) · 2.3 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
#!/bin/bash
# these are the executables to install somewhere in the user PATH
toinstall=(
"ollama-cli"
)
# Predefined list of 'standard' directories which may be in a user PATH
# If uv is installed, ~/.local/bin should be there anyway
directories=(
"$HOME/.local/bin"
"$HOME/bin"
"$HOME/scripts"
"$HOME/Public/bin"
)
# ---------------------------------------------------------------
# No user servicable part below this line
# ---------------------------------------------------------------
# Function to check if a directory is in the PATH
check_directory_in_path() {
local dir=$1
for path_dir in "${path_dirs[@]}"; do
if [[ "$dir" == "$path_dir" ]]; then
return 0
fi
done
return 1
}
# Function to install via softlink an executable into a directory
install_to_dir() {
local from=$1
local to=$2
local bname=$3
echo -n "Installing $bname ... "
if ln -sf "$from" "$to"; then
echo "done."
else
echo "failed? Aborting!"
exit 1
fi
return
}
# Check 'uv'
if command -v uv &> /dev/null; then
echo "'uv' is installed, perfect."
echo "Running 'uv' to prepare your environment"
else
echo "'uv' is not installed, or not in your PATH."
echo "Please consult https://docs.astral.sh/uv/getting-started/installation/"
echo "Cannot install ollama-cli, exiting"
exit
fi
uv sync --no-group dev
echo
echo
for binname in "${toinstall[@]}"; do
if [ ! -e "$binname" ] || [ ! -x "$binname" ]; then
echo "Oooops??? Somehow '$binname' either does not exist or is not executable."
echo "Something went wrong with 'uv sync', exiting"
exit 1
fi
done
# Get the directories in PATH
IFS=':' read -r -a path_dirs <<< "$PATH"
# Check each directory if exist
for dir in "${directories[@]}"; do
if check_directory_in_path "$dir"; then
IPATH=$dir
break
fi
done
if [[ ! -n "$IPATH" ]]; then
echo "No directory found to install to. Looked in:"
for dir in "${directories[@]}"; do
echo "$dir"
done
echo
echo "I suggest you create ./local/bin and take it up permanently into your PATH,"
echo "then rerun this script."
exit 1
fi
# where are we?
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
for binname in "${toinstall[@]}"; do
install_to_dir "$SCRIPTPATH/.venv/bin/$toinstall" "$IPATH/$binname" "$binname"
done
echo
echo
echo "All done."