-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·69 lines (57 loc) · 1.94 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·69 lines (57 loc) · 1.94 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
#!/bin/bash
# Simple setup script for BackItUp application
PYTHON_CMD="python3"
VENV_DIR="BackItUp/.venv"
REQUIREMENTS_FILE="BackItUp/requirements.txt" # Use requirements file
echo "--- BackItUp Setup ---"
# Check for Python 3
if ! command -v $PYTHON_CMD &> /dev/null
then
echo "Error: $PYTHON_CMD command not found. Please install Python 3."
exit 1
fi
echo "Found $PYTHON_CMD: $($PYTHON_CMD --version)"
# Check if venv module is available
if ! $PYTHON_CMD -m venv --help &> /dev/null
then
echo "Error: Python 3 'venv' module not found. It might need to be installed (e.g., sudo apt install python3-venv)."
exit 1
fi
echo "Python 'venv' module found."
# Create virtual environment if it doesn't exist
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment in $VENV_DIR..."
$PYTHON_CMD -m venv "$VENV_DIR"
if [ $? -ne 0 ]; then
echo "Error: Failed to create virtual environment."
exit 1
fi
echo "Virtual environment created."
else
echo "Virtual environment already exists in $VENV_DIR."
fi
# Check if requirements file exists
if [ ! -f "$REQUIREMENTS_FILE" ]; then
echo "Error: Requirements file not found at $REQUIREMENTS_FILE"
exit 1
fi
# Activate virtual environment (for installing packages) and install requirements
echo "Installing required packages from $REQUIREMENTS_FILE..."
source "$VENV_DIR/bin/activate" && pip install -r "$REQUIREMENTS_FILE"
if [ $? -ne 0 ]; then
echo "Error: Failed to install required packages."
# Deactivate manually if activation succeeded but pip failed
deactivate &> /dev/null
exit 1
fi
# Deactivate after installation (user needs to activate manually to run)
deactivate &> /dev/null
echo ""
echo "--- Setup Complete ---"
echo ""
echo "To run the application:"
echo "1. Activate the virtual environment: source $VENV_DIR/bin/activate"
echo "2. Run the main script: python -m BackItUp.main"
echo "3. When finished, deactivate: deactivate"
echo ""
exit 0