hass.tibber_prices/scripts/bootstrap
2025-11-06 11:43:10 +00:00

43 lines
1 KiB
Bash
Executable file

#!/bin/sh
# script/bootstrap: Install/update all dependencies required to run the project
set -e
cd "$(dirname "$0")/.."
echo "==> Updating system packages..."
sudo apt-get update
sudo apt-get upgrade -y
echo "==> Checking for uv..."
if ! command -v uv >/dev/null 2>&1; then
echo "UV not found, installing..."
pipx install uv
fi
# if no venv, create one
if [ ! -d "$HOME/.venv" ]; then
echo "==> Creating virtual environment..."
uv venv "$HOME/.venv"
fi
# shellcheck source=/dev/null
. "$HOME/.venv/bin/activate"
echo "==> Installing dependencies..."
uv pip install --requirement requirements.txt
echo "==> Installing pre-commit hooks..."
pre-commit install
echo "==> Updating shell environment..."
if ! grep -q "source $HOME/.venv/bin/activate" ~/.bashrc; then
echo "source $HOME/.venv/bin/activate" >> ~/.bashrc
fi
if [ -f ~/.zshrc ]; then
if ! grep -q "source $HOME/.venv/bin/activate" ~/.zshrc; then
echo "source $HOME/.venv/bin/activate" >> ~/.zshrc
fi
fi
echo "==> Bootstrap completed!"