-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·124 lines (101 loc) · 3.67 KB
/
install.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env sh
# Utility functions
vergte() {
printf '%s\n%s' "$2" "$1" | sort -C -V
}
read_input() {
read -r -p "$1" response
# Set default response to "Y", why not
response=${response:-Y}
printf "%s" "$response"
}
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Initial checks before takeoff
# Check for a supported Ollama version
if ! command_exists ollama; then
printf "\n >>> Ollama not found. Please (re)install it from 'https://ollama.com/download'\n"
exit 1
fi
OLLAMA_VER=$(ollama --version | grep -oE '[0-9]+(\.[0-9]+)+')
if ! vergte "$OLLAMA_VER" "0.1.30"; then
printf "\n >>> Ollama version too old. Please update to 0.1.30 or higher.\n"
exit 1
fi
# figure out pyenv
if ! command_exists pyenv; then
printf "\n >>> Pyenv not found.\n"
response=$(read_input " >>> Would you like to install pyenv? [Y/n]: ")
response=${response:-Y}
case "$response" in
[yY][eE][sS]|[yY])
printf ">>> Installing pyenv...\n"
curl https://pyenv.run | bash
;;
*)
printf "\n >>> Installation is stopped. Exiting...\n"
exit 1
;;
esac
else
printf "\n >>> Pyenv is already installed.\n"
fi
# 3. Update shell configuration for pyenv, if needed. Don't ask me why.
if [ "$response" = "Y" ] || [ "$response" = "y" ]; then
PATH_MODIFICATION='export PATH="$HOME/.pyenv/bin:$PATH"'
if ! printf $PATH | grep -q "$HOME/.pyenv/bin"; then
if [ -n "$FISH_VERSION" ]; then
printf "set -gx PATH $HOME/.pyenv/bin \$PATH\n" >> ~/.config/fish/config.fish
else
printf "$PATH_MODIFICATION\n" >> ~/$([ -n "$ZSH_VERSION" ] && echo ".zshrc" || echo ".bashrc")
fi
fi
if [ -z "$FISH_VERSION" ]; then
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
fi
printf ">>> pyenv installed successfully.\n"
printf ">>> Please restart your shell session or source your shell configuration file for the changes to take effect.\n"
fi
# Install and setup Python version, without animal control support
if ! pyenv versions | grep -q '3.12'; then
pyenv install 3.12
fi
pyenv local 3.12
if ! pyenv version | grep -q '3.12'; then
printf "\n >>> Python 3.12 not found. Please install it manually with pyenv install 3.12 \n"
exit 1
fi
# Install Python dependencies from the deepest circle of hell, just ask Dante Alighieri
pip install -r requirements.txt
# .env file setup for the VaultChat centre of the universe
if [ ! -f ".env" ]; then
printf " >>> The .env file does not exist."
response=$(read_input " >>> Would you like to create it from .env.example? [Y/n]:")
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
cp .env.example .env
printf "\n >>> Please adjust the variables in .env file to your needs.\n"
else
printf "Skipping .env file creation.\n"
fi
fi
# Setup private documents directory, Mr. Lawyer
printf "\n Private Documents Location:\n"
grep SOURCE_DIRECTORY .env
read_input ">>> Enter a new path for private documents (leave blank to use default): " response
if [ -n "$response" ]; then
printf "\n >>> Setting Private Documents Location: $response \n"
sed "s|SOURCE_DIRECTORY=.*|SOURCE_DIRECTORY=$response|" .env > .env.tmp && mv .env.tmp .env
else
printf "\n Using default Private Documents Location.\n"
fi
# Make them run
chmod +x docs_loader.py vaultChat.py
# Final instructions for smart and good looking customers
printf "\n >>> Installation was successful!\n"
printf "\n >>> Run './docs_loader.py' to prepare your private data.\n"
printf "\n >>> Important! Run './docs_loader.py' again every time you change documents in your directory.\n"
printf "\n >>> Run './vaultChat.py' to start the application after your private data store creation or update.\n"
# That's all, folks
exit 0