Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·70 lines (57 loc) · 2.05 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·70 lines (57 loc) · 2.05 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
#!/bin/bash
set -e
# Store the initial directory to ensure we can always return to it
INITIAL_DIR=$(pwd)
# Function to ensure we return to the initial directory
cleanup() {
cd "$INITIAL_DIR"
}
# Set up trap to ensure we always return to the initial directory
trap cleanup EXIT
# Install poetry if not already installed
echo "Checking for poetry installation..."
if ! command -v poetry &> /dev/null; then
echo "Installing poetry..."
pip install poetry
else
echo "Poetry already installed."
fi
# Install project dependencies with poetry
echo "Installing project dependencies..."
poetry install
# Enable widgets
echo "Enabling widgets..."
poetry run enable-widgets
# Apply the patch to fix the config package version
echo "Checking translation-server patch status..."
cd translation-server
# Check if patch has already been applied
if git apply --check ../translation-server-config-fix.patch &> /dev/null; then
echo "Applying patch to translation-server..."
git apply ../translation-server-config-fix.patch
else
echo "Patch already applied or not applicable."
fi
# Install translation-server dependencies if node_modules doesn't exist or package.json is newer
if [ ! -d "node_modules" ] || [ "package.json" -nt "node_modules" ]; then
echo "Installing translation-server dependencies..."
npm install
else
echo "Translation-server dependencies already installed."
fi
# Return to the project root directory
cd "$INITIAL_DIR"
echo "Setup complete! The project dependencies and translation-server are now installed."
# Check if .env file exists and contains required variables with values
if [ ! -f .env ] || \
! grep -q "OXYLABS_USERNAME=.*[^[:space:]]" .env || \
! grep -q "OXYLABS_PASSWORD=.*[^[:space:]]" .env || \
! grep -q "OPENAI_API_KEY=.*[^[:space:]]" .env; then
echo "Don't forget to set up your environment variables in a .env file:"
echo "OXYLABS_USERNAME="
echo "OXYLABS_PASSWORD="
echo "OPENAI_API_KEY="
echo ""
fi
echo "To start the Zotero translation server, run:"
echo "cd translation-server && npm start"