New LXC: Paperless-GPT
This commit is contained in:
parent
9410f00ddb
commit
321aebbc71
84
ct/paperless-gpt.sh
Normal file
84
ct/paperless-gpt.sh
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
|
# Author: MickLesk (CanbiZ)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/icereed/paperless-gpt
|
||||||
|
|
||||||
|
APP="Debian"
|
||||||
|
var_tags="os"
|
||||||
|
var_cpu="3"
|
||||||
|
var_ram="2048"
|
||||||
|
var_disk="5"
|
||||||
|
var_os="debian"
|
||||||
|
var_version="12"
|
||||||
|
var_unprivileged="1"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
check_container_storage
|
||||||
|
check_container_resources
|
||||||
|
if [[ ! -d /opt/paperless-gpt ]]; then
|
||||||
|
msg_error "No Paperless-GPT installation found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
RELEASE=$(curl -s https://api.github.com/repos/icereed/paperless-gpt/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
|
msg_info "Stopping Service"
|
||||||
|
systemctl stop paperless-gpt
|
||||||
|
msg_ok "Service Stopped"
|
||||||
|
|
||||||
|
msg_info "Backing up .env file"
|
||||||
|
mkdir -p /opt/paperless-gpt-backup
|
||||||
|
[[ -f /opt/paperless-gpt/web-app/.env ]] && cp -f /opt/paperless-gpt/web-app/.env /opt/paperless-gpt-backup/.env
|
||||||
|
msg_ok "Backup Created"
|
||||||
|
|
||||||
|
msg_info "Updating Paperless-GPT to ${RELEASE}"
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
wget -q "https://github.com/icereed/paperless-gpt/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
|
||||||
|
tar zxf $temp_file
|
||||||
|
rm -rf /opt/paperless-gpt
|
||||||
|
mv paperless-gpt-${RELEASE} /opt/paperless-gpt
|
||||||
|
cd /opt/paperless-gpt/web-app
|
||||||
|
$STD npm install
|
||||||
|
$STD npm run build
|
||||||
|
cd /opt/paperless-gpt
|
||||||
|
go mod download
|
||||||
|
export CC=musl-gcc
|
||||||
|
CGO_ENABLED=1 go build -tags musl -o /dev/null github.com/mattn/go-sqlite3
|
||||||
|
CGO_ENABLED=1 go build -tags musl -o paperless-gpt .
|
||||||
|
echo "${RELEASE}" >"/opt/paperless-gpt_version.txt"
|
||||||
|
msg_ok "Updated Paperless-GPT to ${RELEASE}"
|
||||||
|
|
||||||
|
msg_info "Restoring .env file"
|
||||||
|
[[ -f /opt/paperless-gpt-backup/.env ]] && mv -f /opt/paperless-gpt-backup/.env /opt/paperless-gpt/web-app/.env
|
||||||
|
msg_ok "Restored .env file"
|
||||||
|
|
||||||
|
msg_info "Starting Service"
|
||||||
|
systemctl start paperless-gpt
|
||||||
|
msg_ok "Started Service"
|
||||||
|
|
||||||
|
msg_info "Cleaning Up"
|
||||||
|
rm -f $temp_file
|
||||||
|
rm -rf /opt/paperless-gpt-backup
|
||||||
|
msg_ok "Cleanup Completed"
|
||||||
|
|
||||||
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
|
fi
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"
|
133
install/paperless-gpt-install.sh
Normal file
133
install/paperless-gpt-install.sh
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
|
# Author: MickLesk (CanbiZ)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/icereed/paperless-gpt
|
||||||
|
|
||||||
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
sudo \
|
||||||
|
curl \
|
||||||
|
mc \
|
||||||
|
gcc \
|
||||||
|
ca-certificates \
|
||||||
|
musl-dev \
|
||||||
|
mupdf \
|
||||||
|
libc6-dev \
|
||||||
|
musl-tools
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Setting up Node.js Repository"
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
|
||||||
|
msg_ok "Installed Node.js"
|
||||||
|
|
||||||
|
msg_info "Installing Node.js"
|
||||||
|
$STD apt-get update
|
||||||
|
$STD apt-get install -y nodejs
|
||||||
|
msg_ok "Installed Node.js"
|
||||||
|
|
||||||
|
msg_info "Installing Golang"
|
||||||
|
set +o pipefail
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
golang_tarball=$(curl -s https://go.dev/dl/ | grep -oP 'go[\d\.]+\.linux-amd64\.tar\.gz' | head -n 1)
|
||||||
|
wget -q https://golang.org/dl/"$golang_tarball" -O "$temp_file"
|
||||||
|
tar -C /usr/local -xzf "$temp_file"
|
||||||
|
ln -sf /usr/local/go/bin/go /usr/local/bin/go
|
||||||
|
rm -f "$temp_file"
|
||||||
|
set -o pipefail
|
||||||
|
msg_ok "Installed Golang"
|
||||||
|
|
||||||
|
msg_info "Setup Paperless-GPT"
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
RELEASE=$(curl -s https://api.github.com/repos/icereed/paperless-gpt/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
|
wget -q "https://github.com/icereed/paperless-gpt/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
|
||||||
|
tar zxf $temp_file
|
||||||
|
mv paperless-gpt-${RELEASE} /opt/paperless-gpt
|
||||||
|
|
||||||
|
cd /opt/paperless-gpt/web-app
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
cd /opt/paperless-gpt
|
||||||
|
go mod download
|
||||||
|
export CC=musl-gcc
|
||||||
|
CGO_ENABLED=1 go build -tags musl -o /dev/null github.com/mattn/go-sqlite3
|
||||||
|
CGO_ENABLED=1 go build -tags musl -o paperless-gpt .
|
||||||
|
|
||||||
|
read -p "Do you want to enter the Paperless local URL now? (y/n) " input_url
|
||||||
|
if [[ "$input_url" =~ ^[Yy]$ ]]; then
|
||||||
|
read -p "Enter your Paperless-NGX instance URL (e.g., http://192.168.1.100:8000): " PAPERLESS_BASE_URL
|
||||||
|
else
|
||||||
|
PAPERLESS_BASE_URL="http://your_paperless_ngx_url"
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "Do you want to enter the Paperless API token now? (y/n) " input_token
|
||||||
|
if [[ "$input_token" =~ ^[Yy]$ ]]; then
|
||||||
|
read -p "Enter your Paperless API token: " PAPERLESS_API_TOKEN
|
||||||
|
else
|
||||||
|
PAPERLESS_API_TOKEN="your_paperless_api_token"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >/opt/paperless-gpt/web-app/.env
|
||||||
|
PAPERLESS_BASE_URL=$PAPERLESS_BASE_URL
|
||||||
|
PAPERLESS_API_TOKEN=$PAPERLESS_API_TOKEN
|
||||||
|
|
||||||
|
LLM_PROVIDER=openai
|
||||||
|
LLM_MODEL=gpt-4o
|
||||||
|
OPENAI_API_KEY=your_openai_api_key
|
||||||
|
|
||||||
|
#VISION_LLM_PROVIDER=ollama
|
||||||
|
#VISION_LLM_MODEL=minicpm-v
|
||||||
|
|
||||||
|
LLM_LANGUAGE=English
|
||||||
|
LOG_LEVEL=info
|
||||||
|
|
||||||
|
LISTEN_INTERFACE=:8080
|
||||||
|
|
||||||
|
AUTO_TAG=paperless-gpt-auto
|
||||||
|
MANUAL_TAG=paperless-gpt
|
||||||
|
AUTO_OCR_TAG=paperless-gpt-ocr-auto
|
||||||
|
|
||||||
|
OCR_LIMIT_PAGES=5
|
||||||
|
EOF
|
||||||
|
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||||
|
msg_ok "Setup Paperless-GPT"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/paperless-gpt.service
|
||||||
|
[Unit]
|
||||||
|
Description=Paperless-GPT
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/opt/paperless-gpt
|
||||||
|
ExecStart=/opt/paperless-gpt/paperless-gpt
|
||||||
|
Restart=always
|
||||||
|
User=root
|
||||||
|
EnvironmentFile=/opt/paperless-gpt/web-app/.env
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now paperless-gpt
|
||||||
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
rm -f $temp_file
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
Loading…
x
Reference in New Issue
Block a user