-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
59 lines (51 loc) · 1.7 KB
/
start.sh
File metadata and controls
59 lines (51 loc) · 1.7 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
#!/bin/bash
# 1. Check if config.json is correctly configured
if grep 'path/to/my/backend' config.json &> /dev/null;
then
echo "Please configure config.json then restart the installation."
exit 1
fi
# 2. Check if python3 is installed
if ! command -v python3 &> /dev/null; then
echo "Python3 is not installed."
# Try to detect package manager and install python3
if command -v apt &> /dev/null; then
echo "Installing python3 using apt..."
sudo apt update && sudo apt install -y python3 python3-venv
elif command -v dnf &> /dev/null; then
echo "Installing python3 using dnf..."
sudo dnf install -y python3 python3-venv
elif command -v pacman &> /dev/null; then
echo "Installing python3 using pacman..."
sudo pacman -Sy python
else
echo "Could not determine package manager. Please install Python 3 manually."
exit 1
fi
fi
# 3. Check if the venv module is available
if ! python3 -m venv --help &> /dev/null; then
echo "'venv' module is missing. Attempting to install..."
if command -v apt &> /dev/null; then
sudo apt install -y python3.10-venv
else
echo "Please install the 'python3-venv' package manually."
exit 1
fi
fi
# 4. Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
# 5. Activate the virtual environment
source venv/bin/activate
# 6. Install dependencies from requirements.txt
pip install -r requirements.txt
# 7. Run the Python script in the background and save its PID
echo "Starting RaflexBackend..."
sudo touch starter.log
sudo chmod 777 starter.log
nohup python3 main.py > starter.log 2>&1 &
echo $! > rb.pid
echo "ReflexBackend started (PID : $(cat rb.pid))"