diff --git a/install.sh b/install.sh index b44d504..b61db63 100755 --- a/install.sh +++ b/install.sh @@ -11,11 +11,33 @@ git checkout 0.8.0--dev-zipapp # if on arch linux, install python3-uv if [ -f /etc/arch-release ]; then - sudo pacman -S --needed python-uv python python-pip python-pipx nodejs npm\ - libxml2 libxslt zlib libjpeg-turbo gcc base-devel python-loguru\ - python-rapidfuzz - pipx install . --include-deps - pipx ensurepath + sudo pacman -Syy python-uv + sudo mkdir /etc/pyShelf + sudo cp -avR . /etc/pyShelf + cd /etc/pyShelf + # I need to create a system user for pyshelf, if it doesn't exist + if ! id -u pyshelf >/dev/null 2>&1; then + sudo useradd -r -s /usr/bin/nologin pyshelf + fi + # Change ownership to the pyshelf user + sudo chown -R pyshelf:pyshelf /etc/pyShelf + # Change permissions to allow the pyshelf user to read and write + sudo chmod -R 755 /etc/pyShelf + # Create a virtual environment for pyshelf + sudo -u pyshelf uv sync + sudo -u pyshelf mkdir release + # Install dependencies + + # switch to the pyshelf user + # sudo pacman -S --needed python-uv python python-pip python-pipx nodejs npm\ + # libxml2 libxslt zlib libjpeg-turbo gcc base-devel python-loguru\ + # python-rapidfuzz python-sqlalchemy python-pypdf python-beautifulsoup4\ + # python-lxml python-poetry python-standard-imghdr + # git clone https://aur.archlinux.org/python-mobi.git + # cd python-mobi + # makepkg -si --noconfirm + # cd .. + # install python-mobi from AUR else sudo apt-get update sudo apt-get install -y python3-uv python3 python3-pip nodejs npm libxml2 libxslt1-dev zlib1g-dev libjpeg-turbo8-dev build-essential @@ -23,7 +45,7 @@ else fi # Build the release -./build.sh +sudo -u pyshelf ./build.sh # Install assets sudo mkdir -p /var/lib/pyshelf/assets @@ -32,4 +54,5 @@ sudo cp -r ./src/frontend/templates /var/lib/pyshelf/assets # Install executable sudo cp ./release/pyshelf /usr/local/bin/pyshelf +sudo chown pyshelf:pyshelf /usr/local/bin/pyshelf diff --git a/pyshelf.sh b/pyshelf.sh new file mode 100755 index 0000000..1ff4042 --- /dev/null +++ b/pyshelf.sh @@ -0,0 +1,17 @@ +#!/usr/bin/sh +# This script is used to run the pyshelf application. +# It sets up the environment and runs the main script. +# first we need to activate the virtual environment +if [ -d ".venv" ]; then + source venv/bin/activate +else + echo "Virtual environment not found. Please create it first." + exit 1 +fi +# then we need to run the main script +if [ -f "release/pyshelf" ]; then + ./release/pyshelf +else + echo "Main script not found. Please check the directory." + exit 1 +fi