From ae54eb410ac74af084a4a5e875b9dd8458016e9f Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:53:09 +0100 Subject: [PATCH 1/6] Refactor: Paperless-AI --- ct/paperless-ai.sh | 57 +++++++++------------------------ install/paperless-ai-install.sh | 31 +++++++++++------- 2 files changed, 35 insertions(+), 53 deletions(-) diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index 5b5031851c4..b2b7902528f 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -27,58 +27,33 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - if ! dpkg -s python3-pip >/dev/null 2>&1; then - $STD apt install -y python3-pip - fi - RELEASE=$(curl -fsSL https://api.github.com/repos/clusterzx/paperless-ai/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_info "Stopping Service" - systemctl stop paperless-ai - msg_info "Stopped Service" - msg_info "Updating $APP to v${RELEASE}" - cd /opt - mv /opt/paperless-ai /opt/paperless-ai_bak - curl -fsSL "https://github.com/clusterzx/paperless-ai/archive/refs/tags/v${RELEASE}.zip" -o $(basename "https://github.com/clusterzx/paperless-ai/archive/refs/tags/v${RELEASE}.zip") - $STD unzip v${RELEASE}.zip - mv paperless-ai-${RELEASE} /opt/paperless-ai - mkdir -p /opt/paperless-ai/data - cp -a /opt/paperless-ai_bak/data/. /opt/paperless-ai/data/ - cd /opt/paperless-ai - if [[ ! -f /etc/systemd/system/paperless-rag.service ]]; then - cat </etc/systemd/system/paperless-rag.service -[Unit] -Description=PaperlessAI-RAG Service -After=network.target + if check_for_gh_release "paperless-ai" "fosrl/pangolin"; then + msg_info "Stopping Services" + systemctl stop paperless-ai paperless-rag + msg_ok "Stopped Services" -[Service] -WorkingDirectory=/opt/paperless-ai -ExecStart=/usr/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize -Restart=always + fetch_and_deploy_gh_release "clusterzx/paperless-ai" "/opt/paperless-ai" -[Install] -WantedBy=multi-user.target -EOF - echo "RAG_SERVICE_URL=http://localhost:8000" >>/opt/paperless-ai/data/.env - echo "RAG_SERVICE_ENABLED=true" >>/opt/paperless-ai/data/.env - fi + msg_info "Updating Paperless-AI" + cd /opt/paperless-ai + source /opt/paperless-ai/venv/bin/activate + $STD pip install --upgrade pip $STD pip install --no-cache-dir -r requirements.txt mkdir -p data/chromadb - $STD npm install - rm -rf /opt/v${RELEASE}.zip - rm -rf /opt/paperless-ai_bak - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" + $STD npm ci --only=production + msg_ok "Updated Paperless-AI" - msg_info "Starting Service" + msg_info "Starting Services" + systemctl start paperless-rag + sleep 3 systemctl start paperless-ai - msg_ok "Started Service" + msg_ok "Started Services" msg_ok "Updated successfully!" - else - msg_ok "No update required. ${APP} is already at v${RELEASE}" fi exit } + start build_container description diff --git a/install/paperless-ai-install.sh b/install/paperless-ai-install.sh index d382c1c00e9..7cec2644b16 100644 --- a/install/paperless-ai-install.sh +++ b/install/paperless-ai-install.sh @@ -20,21 +20,27 @@ msg_ok "Installed Dependencies" msg_info "Installing Python3" $STD apt install -y \ - python3-pip + python3-pip \ + python3-dev \ + python3-venv +mkdir -p ~/.config/pip +cat >~/.config/pip/pip.conf </opt/paperless-ai/data/.env PAPERLESS_API_URL= @@ -61,8 +67,6 @@ CUSTOM_MODEL= RAG_SERVICE_URL=http://localhost:8000 RAG_SERVICE_ENABLED=true EOF -rm -rf v${RELEASE}.zip -echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Setup Paperless-AI" msg_info "Creating Service" @@ -74,7 +78,9 @@ Requires=paperless-rag.service [Service] WorkingDirectory=/opt/paperless-ai -ExecStart=/usr/bin/npm start +Environment="NODE_ENV=production" +EnvironmentFile=/opt/paperless-ai/data/.env +ExecStart=/usr/bin/node server.js Restart=always [Install] @@ -88,7 +94,8 @@ After=network.target [Service] WorkingDirectory=/opt/paperless-ai -ExecStart=/usr/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize +EnvironmentFile=/opt/paperless-ai/data/.env +ExecStart=/opt/paperless-ai/venv/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize Restart=always [Install] From c2e9b9028a4c49d93267151c4851081dc9da8208 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:28:58 +0100 Subject: [PATCH 2/6] Update paperless-ai.sh --- ct/paperless-ai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index b2b7902528f..69488e8b5ba 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -28,7 +28,7 @@ function update_script() { exit fi - if check_for_gh_release "paperless-ai" "fosrl/pangolin"; then + if check_for_gh_release "paperless-ai" "clusterzx/paperless-ai"; then msg_info "Stopping Services" systemctl stop paperless-ai paperless-rag msg_ok "Stopped Services" From ea70045c2f9e48d13450d62612d97ad703f7f0f3 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:38:51 +0100 Subject: [PATCH 3/6] Fix fetch_and_deploy_gh_release repository name --- ct/paperless-ai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index 69488e8b5ba..40f7118b8ef 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -33,7 +33,7 @@ function update_script() { systemctl stop paperless-ai paperless-rag msg_ok "Stopped Services" - fetch_and_deploy_gh_release "clusterzx/paperless-ai" "/opt/paperless-ai" + fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" msg_info "Updating Paperless-AI" cd /opt/paperless-ai From 65d7f42d33dba90e2b52e571b6c873bdefcfd53a Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:39:10 +0100 Subject: [PATCH 4/6] Fix order of arguments in fetch_and_deploy_gh_release --- install/paperless-ai-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/paperless-ai-install.sh b/install/paperless-ai-install.sh index 7cec2644b16..ffd038d68e6 100644 --- a/install/paperless-ai-install.sh +++ b/install/paperless-ai-install.sh @@ -31,7 +31,7 @@ EOF msg_ok "Installed Python3" NODE_VERSION="22" setup_nodejs -fetch_and_deploy_gh_release "clusterzx/paperless-ai" "/opt/paperless-ai" +fetch_and_deploy_gh_release "/opt/paperless-ai" "clusterzx/paperless-ai" msg_info "Setup Paperless-AI" cd /opt/paperless-ai From 1635ddceb9358323ca8bb94a1bc9160b0768bf5a Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:42:12 +0100 Subject: [PATCH 5/6] Update paperless-ai-install.sh --- install/paperless-ai-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/paperless-ai-install.sh b/install/paperless-ai-install.sh index ffd038d68e6..0d53d632fc2 100644 --- a/install/paperless-ai-install.sh +++ b/install/paperless-ai-install.sh @@ -31,7 +31,7 @@ EOF msg_ok "Installed Python3" NODE_VERSION="22" setup_nodejs -fetch_and_deploy_gh_release "/opt/paperless-ai" "clusterzx/paperless-ai" +fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" msg_info "Setup Paperless-AI" cd /opt/paperless-ai From 9fadab68329f35dc75ce50fd62b3407463c1752b Mon Sep 17 00:00:00 2001 From: Tobias <96661824+CrazyWolf13@users.noreply.github.com> Date: Tue, 2 Dec 2025 14:51:55 +0100 Subject: [PATCH 6/6] Update paperless-ai.sh --- ct/paperless-ai.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index 40f7118b8ef..951e7ef39b2 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -29,9 +29,9 @@ function update_script() { fi if check_for_gh_release "paperless-ai" "clusterzx/paperless-ai"; then - msg_info "Stopping Services" + msg_info "Stopping Service" systemctl stop paperless-ai paperless-rag - msg_ok "Stopped Services" + msg_ok "Stopped Service" fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" @@ -44,11 +44,11 @@ function update_script() { $STD npm ci --only=production msg_ok "Updated Paperless-AI" - msg_info "Starting Services" + msg_info "Starting Service" systemctl start paperless-rag sleep 3 systemctl start paperless-ai - msg_ok "Started Services" + msg_ok "Started Service" msg_ok "Updated successfully!" fi exit