-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·198 lines (169 loc) · 5.85 KB
/
install.sh
File metadata and controls
executable file
·198 lines (169 loc) · 5.85 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/bash
# Enable error handling
set -e
function install_provider() {
local provider=$1
local api_key_var_name=$2
local extra_name=$3
local script_name=$4
local set_as_default=$5
read -p "Enter your $provider API Key (optional): " api_key
# Only update .env if user entered a new API key
if [ -n "$api_key" ]; then
if [ -f ".env" ]; then
sed -i.bak "/^${api_key_var_name}_API_KEY=/d" .env
rm -f .env.bak
fi
echo "${api_key_var_name}_API_KEY=$api_key" >> .env
fi
# Set as default provider if requested
if [ "$set_as_default" = "set_default" ]; then
if [ -f ".env" ]; then
sed -i.bak "/^PROVIDER=/d" .env
rm -f .env.bak
fi
echo "PROVIDER=$provider" >> .env
fi
if [ -n "$extra_name" ]; then
extras+=("$extra_name")
fi
scripts_to_generate+=("$script_name")
}
function install_bedrock() {
echo "WARNING: Amazon Bedrock setup is not recommended for most users."
echo "The setup requires AWS credentials, region configuration, and enabling specific model access in the AWS Console."
echo "Proceed only if you are familiar with AWS configuration."
echo
read -p "Enter your AWS Access Key ID: " access_key
read -p "Enter your AWS Secret Access Key: " secret_key
read -p "Enter your AWS Region (e.g., us-east-1): " region
if [ -f ".env" ]; then
# Remove existing provider settings
sed -i.bak "/^AWS_ACCESS_KEY_ID=/d" .env
sed -i.bak "/^AWS_SECRET_ACCESS_KEY=/d" .env
sed -i.bak "/^AWS_REGION=/d" .env
sed -i.bak "/^PROVIDER=/d" .env
rm -f .env.bak
fi
echo "PROVIDER=Bedrock" >> .env
echo "AWS_ACCESS_KEY_ID=$access_key" >> .env
echo "AWS_SECRET_ACCESS_KEY=$secret_key" >> .env
echo "AWS_REGION=$region" >> .env
extras+=("bedrock")
scripts_to_generate+=("bedrock-subtrans")
echo "Bedrock setup complete. Default provider set to Bedrock."
}
if [ ! -d "scripts" ]; then
echo "Please run the script from the root directory of the project."
exit 1
fi
echo "Checking if Python 3 is installed..."
if ! python3 --version &>/dev/null; then
echo "Python 3 not found. Please install Python 3 and try again."
exit 1
fi
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
MIN_VERSION="3.10.0"
if [[ "$(printf '%s\n' "$MIN_VERSION" "$PYTHON_VERSION" | sort -V | head -n1)" != "$MIN_VERSION" ]]; then
echo "Detected Python version is less than 3.10.0. Please upgrade your Python version."
exit 1
else
echo "Python version is compatible."
fi
echo "Checking if \"envsubtrans\" folder exists..."
if [ -d "envsubtrans" ]; then
echo "\"envsubtrans\" folder already exists."
read -p "Do you want to perform a clean install? This will delete the existing environment. (Y/N): " user_choice
if [ "$user_choice" = "Y" ] || [ "$user_choice" = "y" ]; then
echo "Performing a clean install..."
rm -rf envsubtrans
[ -f .env ] && rm .env
elif [ "$user_choice" != "N" ] && [ "$user_choice" != "n" ]; then
echo "Invalid choice. Exiting installation."
exit 1
fi
fi
python3 -m venv envsubtrans
source envsubtrans/bin/activate
extras=()
scripts_to_generate=("llm-subtrans" "batch-translate")
echo "Select installation type:"
echo "1 = Install with GUI"
echo "2 = Install command line tools only"
read -p "Enter your choice (1/2): " install_choice
if [ "$install_choice" = "2" ]; then
echo "Installing command line modules..."
else
echo "Including GUI modules..."
extras+=("gui")
scripts_to_generate+=("gui-subtrans")
fi
# Optional: configure OpenRouter API key
echo "Optional: Configure OpenRouter API key (default provider)"
read -p "Enter your OpenRouter API Key (optional): " openrouter_key
if [ -n "$openrouter_key" ]; then
if [ -f ".env" ]; then
# Remove any existing OpenRouter API key
sed -i.bak "/^OPENROUTER_API_KEY=/d" .env
rm -f .env.bak
fi
echo "OPENROUTER_API_KEY=$openrouter_key" >> .env
fi
echo "Select additional providers to install:"
echo "0 = None"
echo "1 = OpenAI"
echo "2 = Google Gemini"
echo "3 = Anthropic Claude"
echo "4 = DeepSeek"
echo "5 = Mistral"
echo "6 = Bedrock (AWS)"
echo "a = All except Bedrock"
read -p "Enter your choice (0/1/2/3/4/5/6/a): " provider_choice
case $provider_choice in
0)
echo "No additional provider selected."
;;
1)
install_provider "OpenAI" "OPENAI" "openai" "gpt-subtrans" "set_default"
;;
2)
install_provider "Google Gemini" "GEMINI" "gemini" "gemini-subtrans" "set_default"
;;
3)
install_provider "Claude" "CLAUDE" "claude" "claude-subtrans" "set_default"
;;
4)
install_provider "DeepSeek" "DEEPSEEK" "" "deepseek-subtrans" "set_default"
;;
5)
install_provider "Mistral" "MISTRAL" "mistral" "mistral-subtrans" "set_default"
;;
6)
install_bedrock
;;
a)
install_provider "Google Gemini" "GEMINI" "gemini" "gemini-subtrans" ""
install_provider "OpenAI" "OPENAI" "openai" "gpt-subtrans" ""
install_provider "Claude" "CLAUDE" "claude" "claude-subtrans" ""
install_provider "DeepSeek" "DEEPSEEK" "" "deepseek-subtrans" ""
install_provider "Mistral" "MISTRAL" "mistral" "mistral-subtrans" ""
;;
*)
echo "Invalid choice. Exiting installation."
exit 1
;;
esac
install_target="."
if [ ${#extras[@]} -gt 0 ]; then
IFS=','; extra_str="${extras[*]}"; unset IFS
echo "Installing dependencies: $extra_str"
install_target=".[${extra_str}]"
else
echo "Installing dependencies..."
fi
pip install --upgrade -e "$install_target"
for script in "${scripts_to_generate[@]}"; do
scripts/generate-cmd.sh "$script"
done
echo "Setup completed successfully. To uninstall just delete the directory"
exit 0