Skip to content

Commit 48001cc

Browse files
committed
Create babbleapp.sh
1 parent fc56aba commit 48001cc

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

babbleapp.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
# Check if running on Linux
4+
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
5+
echo "Error: This script is only compatible with Linux operating systems."
6+
exit 1
7+
fi
8+
9+
# Check Python version
10+
if ! command -v python3 &> /dev/null; then
11+
echo "Error: Python is not installed. Please install Python 3.11 or higher."
12+
exit
13+
fi
14+
15+
python_version_major=$(python3 -c 'import platform; print(platform.python_version_tuple()[0])')
16+
python_version_minor=$(python3 -c 'import platform; print(platform.python_version_tuple()[1])')
17+
if (( python_version_major < 3 || python_version_minor < 11 )); then
18+
echo "Error: Your Python version is too low! Please install 3.11 or higher."
19+
exit 1
20+
fi
21+
22+
# Set installation directory
23+
install_dir="$HOME/.local/share/project-babble"
24+
25+
# Function to install requirements
26+
install_requirements() {
27+
# Create a temporary requirements file without the Windows-only package
28+
grep -v "onnxruntime-directml" requirements.txt > linux_requirements.txt
29+
pip install -r linux_requirements.txt --quiet
30+
rm linux_requirements.txt
31+
}
32+
33+
# Function to update the repository
34+
update_repo() {
35+
echo "Checking for updates..."
36+
git fetch
37+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
38+
echo "Updates found. Pulling changes..."
39+
git pull
40+
echo "Updating dependencies..."
41+
source venv/bin/activate
42+
install_requirements
43+
deactivate
44+
45+
# Add babbleapp.sh to PATH
46+
mkdir -p "$HOME/.local/bin"
47+
ln -s "$install_dir/babbleapp.sh" "$HOME/.local/bin/babble-app"
48+
chmod +x "$HOME/.local/bin/babble-app"
49+
50+
# Add ~/.local/bin to PATH if not already present
51+
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
52+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc"
53+
echo "Please restart your terminal or run 'source ~/.bashrc' to update your PATH."
54+
fi
55+
56+
echo "Project Babble has been updated successfully!"
57+
else
58+
echo "Project Babble is already up to date."
59+
fi
60+
}
61+
62+
cd $install_dir
63+
update_repo
64+
source venv/bin/activate
65+
cd BabbleApp
66+
echo "Verifying dependencies. This might take a second!"
67+
install_requirements
68+
echo "Starting Babble app..."
69+
python3 babbleapp.py

0 commit comments

Comments
 (0)