Refactor viseron installation script
Updated the installation script to install new dependencies, removed PostgreSQL setup, and adjusted Python environment setup.
This commit is contained in:
parent
b7dee560a1
commit
8719faadb6
@ -15,90 +15,54 @@ update_os
|
|||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt install -y \
|
$STD apt install -y \
|
||||||
python3-opencv jq \
|
python3 python3-pip python3-venv \
|
||||||
libglib2.0-0 pciutils gcc musl-dev \
|
git curl wget \
|
||||||
libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 \
|
libgl1-mesa-glx libglib2.0-0 \
|
||||||
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav \
|
libsm6 libxext6 libxrender-dev \
|
||||||
build-essential python3-dev python3-gi pkg-config libcairo2-dev gir1.2-glib-2.0 \
|
libgstreamer1.0-0 libgstreamer-plugins-base1.0-0 \
|
||||||
cmake gfortran libopenblas-dev liblapack-dev libgirepository1.0-dev git libpq-dev
|
libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-base \
|
||||||
|
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
|
||||||
|
gstreamer1.0-plugins-ugly gstreamer1.0-libav \
|
||||||
|
gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa \
|
||||||
|
gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 \
|
||||||
|
gstreamer1.0-pulseaudio \
|
||||||
|
libavcodec-dev libavformat-dev libswscale-dev \
|
||||||
|
libv4l-dev libxvidcore-dev libx264-dev \
|
||||||
|
libjpeg-dev libpng-dev libtiff-dev \
|
||||||
|
libatlas-base-dev gfortran \
|
||||||
|
libhdf5-dev libhdf5-serial-dev \
|
||||||
|
libhdf5-103 libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5 \
|
||||||
|
libgtk-3-dev libcanberra-gtk3-module \
|
||||||
|
libgirepository1.0-dev libcairo2-dev pkg-config \
|
||||||
|
libcblas-dev libopenblas-dev liblapack-dev \
|
||||||
|
libsm6 libxext6 libxrender-dev libxss1 \
|
||||||
|
libgconf-2-4 libasound2
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
PG_VERSION="16" setup_postgresql
|
mkdir -p ~/.config/pip
|
||||||
PYTHON_VERSION="3.11" setup_uv
|
cat > ~/.config/pip/pip.conf << EOF
|
||||||
|
[global]
|
||||||
msg_info "Setting up PostgreSQL Database"
|
break-system-packages = true
|
||||||
DB_NAME=viseron
|
EOF
|
||||||
DB_USER=viseron_usr
|
msg_ok "Installed Dependencies"
|
||||||
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
|
|
||||||
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
|
|
||||||
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
|
|
||||||
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
|
|
||||||
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
|
|
||||||
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'"
|
|
||||||
{
|
|
||||||
echo "Viseron-Credentials"
|
|
||||||
echo "Viseron Database User: $DB_USER"
|
|
||||||
echo "Viseron Database Password: $DB_PASS"
|
|
||||||
echo "Viseron Database Name: $DB_NAME"
|
|
||||||
} >>~/viseron.creds
|
|
||||||
msg_ok "Set up PostgreSQL Database"
|
|
||||||
|
|
||||||
msg_info "Setting up Hardware Acceleration"
|
|
||||||
if [[ "$CTTYPE" == "0" ]]; then
|
|
||||||
chgrp video /dev/dri
|
|
||||||
chmod 755 /dev/dri
|
|
||||||
chmod 660 /dev/dri/*
|
|
||||||
fi
|
|
||||||
msg_ok "Hardware Acceleration Configured"
|
|
||||||
|
|
||||||
fetch_and_deploy_gh_release "viseron" "roflcoopter/viseron"
|
|
||||||
|
|
||||||
msg_info "Setting up Python Environment"
|
msg_info "Setting up Python Environment"
|
||||||
uv venv --python "python3.11" /opt/viseron/.venv
|
cd /opt
|
||||||
uv pip install --python /opt/viseron/.venv/bin/python --upgrade pip setuptools wheel
|
python3 -m venv viseron
|
||||||
|
source viseron/bin/activate
|
||||||
|
pip install --upgrade pip setuptools wheel
|
||||||
msg_ok "Python Environment Setup"
|
msg_ok "Python Environment Setup"
|
||||||
|
|
||||||
msg_info "Setup Viseron (Patience)"
|
msg_info "Installing Viseron"
|
||||||
GPU_VENDOR=$(lspci | grep -E "VGA|3D" | grep -oE "NVIDIA|Intel|AMD" | head -n1)
|
RELEASE=$(curl -fsSL https://api.github.com/repos/roflcoopter/viseron/releases/latest | jq -r '.tag_name')
|
||||||
|
pip install viseron==${RELEASE#v}
|
||||||
|
msg_ok "Installed Viseron $RELEASE"
|
||||||
|
|
||||||
case "$GPU_VENDOR" in
|
msg_info "Creating Configuration Directory"
|
||||||
NVIDIA)
|
mkdir -p /config
|
||||||
msg_info "NVIDIA GPU detected → Installing PyTorch with CUDA"
|
mkdir -p /config/recordings
|
||||||
UV_HTTP_TIMEOUT=1200 uv pip install --python /opt/viseron/.venv/bin/python \
|
mkdir -p /config/logs
|
||||||
torch torchvision torchaudio
|
msg_ok "Created Configuration Directory"
|
||||||
msg_ok "Installed Torch with CUDA"
|
|
||||||
;;
|
|
||||||
Intel)
|
|
||||||
msg_info "Intel GPU detected → Installing PyTorch with Intel Extension (CPU wheels)"
|
|
||||||
UV_HTTP_TIMEOUT=1200 uv pip install --python /opt/viseron/.venv/bin/python \
|
|
||||||
torch torchvision torchaudio intel-extension-for-pytorch \
|
|
||||||
--extra-index-url https://download.pytorch.org/whl/cpu
|
|
||||||
msg_ok "Installed Torch with Intel Extension"
|
|
||||||
;;
|
|
||||||
AMD)
|
|
||||||
msg_info "AMD GPU detected → Installing PyTorch with ROCm"
|
|
||||||
UV_HTTP_TIMEOUT=1200 uv pip install --python /opt/viseron/.venv/bin/python \
|
|
||||||
torch torchvision torchaudio \
|
|
||||||
--index-url https://download.pytorch.org/whl/rocm6.0
|
|
||||||
msg_ok "Installed Torch with ROCm"
|
|
||||||
;;
|
|
||||||
CPU)
|
|
||||||
msg_info "No GPU detected → Installing CPU-only PyTorch"
|
|
||||||
UV_HTTP_TIMEOUT=1200 uv pip install --python /opt/viseron/.venv/bin/python \
|
|
||||||
torch torchvision torchaudio \
|
|
||||||
--extra-index-url https://download.pytorch.org/whl/cpu
|
|
||||||
msg_ok "Installed Torch CPU-only"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
UV_HTTP_TIMEOUT=600 uv pip install --python /opt/viseron/.venv/bin/python -e /opt/viseron/.
|
|
||||||
UV_HTTP_TIMEOUT=600 uv pip install --python /opt/viseron/.venv/bin/python -r /opt/viseron/requirements.txt
|
|
||||||
|
|
||||||
mkdir -p /config/{recordings,snapshots,segments,event_clips,thumbnails}
|
|
||||||
for d in recordings snapshots segments event_clips thumbnails; do
|
|
||||||
ln -sfn "/config/$d" "/$d"
|
|
||||||
done
|
|
||||||
msg_ok "Setup Viseron"
|
|
||||||
|
|
||||||
msg_info "Creating Default Configuration"
|
msg_info "Creating Default Configuration"
|
||||||
cat <<EOF >/config/viseron.yaml
|
cat <<EOF >/config/viseron.yaml
|
||||||
@ -152,14 +116,6 @@ motion_detection:
|
|||||||
enabled: true
|
enabled: true
|
||||||
threshold: 25
|
threshold: 25
|
||||||
sensitivity: 0.8
|
sensitivity: 0.8
|
||||||
|
|
||||||
storage:
|
|
||||||
connection_string: postgresql://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME
|
|
||||||
recordings: /recordings
|
|
||||||
snapshots: /snapshots
|
|
||||||
segments: /segments
|
|
||||||
event_clips: /event_clips
|
|
||||||
thumbnails: /thumbnails
|
|
||||||
EOF
|
EOF
|
||||||
msg_ok "Created Default Configuration"
|
msg_ok "Created Default Configuration"
|
||||||
|
|
||||||
@ -173,7 +129,8 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/opt/viseron
|
WorkingDirectory=/opt/viseron
|
||||||
ExecStart=/opt/viseron/.venv/bin/python -m viseron --config /config/viseron.yaml
|
Environment=PATH=/opt/viseron/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
ExecStart=/opt/viseron/bin/viseron --config /config/viseron.yaml
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
@ -185,8 +142,4 @@ msg_ok "Created Systemd Service"
|
|||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
cleanup_lxc
|
||||||
msg_info "Cleaning up"
|
|
||||||
$STD apt -y autoremove
|
|
||||||
$STD apt -y autoclean
|
|
||||||
msg_ok "Cleaned"
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user