forked from bettercollected/bettercollected
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·84 lines (63 loc) · 2.04 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
#!/bin/bash
# Ensure the required Python version is installed
if ! python3.10 --version &>/dev/null; then
echo "Python 3.10 is required but not found. Please install it."
exit 1
fi
# Ensure the poetry is installed
if ! poetry --version &>/dev/null; then
echo "Poetry is required but not found. Please install it."
exit 1
fi
# Store the root directory path
root_dir=$(pwd)
# List of service directories and subservice directories in "service" and "service/subservice" format
services=("auth" "integrations/google" "integrations/typeform" "backend" "temporal/worker")
# Initialize an array to hold the background process IDs
pids=()
# Function to set up a service
setup_service() {
service="$1"
echo "Setting up $service..."
# Split the service directory into service and subservice parts
IFS="/" read -r main_service sub_service <<< "$service"
# Change to the service directory
if [ -z "$sub_service" ]; then
cd "$root_dir/$main_service" || exit
else
cd "$root_dir/$main_service/$sub_service" || exit
fi
# Check if pyproject.toml exists
if [ -f "pyproject.toml" ]; then
# Create a virtual environment using Poetry
poetry env use 3.10
# Use makefile to install dependencies
make install
elif [ -f "requirements.txt" ]; then
# Create a virtual environment using venv
python3.10 -m venv venv
# Activate the virtual environment
source venv/bin/activate
# Use pip to install dependencies from requirements.txt
pip install -r requirements.txt
# Deactivate the virtual environment
deactivate
else
echo "No dependency file found for $service"
fi
}
# Iterate through services and run setup_service function in background
for service in "${services[@]}"; do
setup_service "$service" &
pids+=($!)
done
setup_webapp() {
cd webapp || exit
yarn
}
# Wait for all background processes to finish
for pid in "${pids[@]}"; do
wait "$pid"
done
setup_webapp
echo "Initialization complete!"