Added Systemd unit and more verbose install.

This commit is contained in:
2025-08-09 18:11:31 +00:00
parent f6303fa3d2
commit 769bfbf12f
2 changed files with 43 additions and 18 deletions

29
install.sh vendored
View File

@@ -1,8 +1,9 @@
#!/bin/bash #!/bin/env bash
cd /tmp/ cd /tmp/
git clone https://github.com/th3r00t/pyShelf.git git clone https://github.com/th3r00t/pyShelf.git
cd /tmp/pyShelf/ cd /tmp/pyShelf/
# create pyshelf system user if it doesn't exist # create pyshelf system user if it doesn't exist
if ! id -u pyshelf >/dev/null 2>&1; then if ! id -u pyshelf >/dev/null 2>&1; then
sudo useradd -r -s /usr/bin/nologin pyshelfA sudo useradd -r -s /usr/bin/nologin pyshelfA
@@ -24,14 +25,21 @@ git checkout 0.8.0--dev-zipapp
# if on arch linux, install python3-uv # if on arch linux, install python3-uv
if [ -f /etc/arch-release ]; then if [ -f /etc/arch-release ]; then
sudo pacman --noconfirm -Syy python-uv sudo pacman --noconfirm -Syy python-uv
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
fi
sudo mkdir /etc/pyShelf sudo mkdir /etc/pyShelf
sudo cp -avR . /etc/pyShelf sudo cp -avR . /etc/pyShelf
cd /etc/pyShelf cd /etc/pyShelf
sudo uv sync sudo uv sync
sudo mkdir release # sudo mkdir release
cd /etc/pyShelf/src/frontend cd /etc/pyShelf/src/frontend
echo "Installing frontend dependencies..."
sudo npm install sudo npm install
cd /etc/pyShelf cd /etc/pyShelf
echo "Building frontend..."
if [ ! -d /etc/pyShelf/release ]; then if [ ! -d /etc/pyShelf/release ]; then
sudo mkdir release sudo mkdir release
fi fi
@@ -39,9 +47,16 @@ if [ -f /etc/arch-release ]; then
sudo ./build.sh sudo ./build.sh
echo "Linking executable..." echo "Linking executable..."
sudo ln -s /etc/pyShelf/pyshelf.sh /usr/local/bin/ sudo ln -s /etc/pyShelf/pyshelf.sh /usr/local/bin/
# sudo -u pyshelf direnv allow echo "Installing systemd service..."
else if [ -f /usr/lib/systemd/system/pyShelf.service ]; then
sudo apt-get update sudo rm /usr/lib/systemd/system/pyShelf.service
sudo apt-get install -y python3-uv python3 python3-pip nodejs npm libxml2 libxslt1-dev zlib1g-dev libjpeg-turbo8-dev build-essential
sudo pip install -r requirements.txt
fi fi
sudo cp /tmp/pyShelf/pyShelf.service /usr/lib/systemd/system/
echo "Enabling systemd service..."
sudo systemctl daemon-reload
sudo systemctl enable --now pyShelf.service
echo "Installation complete."
echo "You can now access pyShelf at http://localhost:8000"
echo "If your books are not at /mnt/books, please edit the config file at \
/etc/pyShelf/config.json"

10
pyShelf.service vendored Normal file
View File

@@ -0,0 +1,10 @@
[Unit]
Description=pyShelf Ebook Server
After=network.target
[Service]
ExecStart=/usr/local/bin/pyshelf.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target