mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-27 23:30:40 +01:00
54c8b2393e
* install: answer every prompt from the environment, survive a closed stdin Every interactive prompt takes a var_<app>_<name> override and treats a closed stdin like Enter (`|| true`), so an install keeps going after the console that started it is gone. Values the script cannot do without end with exit 64 and name the variable to set. Validation loops stop asking when nobody can answer instead of spinning on an empty read. * mongodb, paperless-gpt: accept yes as well as y
111 lines
3.2 KiB
Bash
111 lines
3.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
|
# Author: MickLesk (CanbiZ)
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/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 install -y \
|
|
gcc \
|
|
musl-dev \
|
|
mupdf \
|
|
libc6-dev \
|
|
musl-tools
|
|
msg_ok "Installed Dependencies"
|
|
|
|
NODE_VERSION="24" setup_nodejs
|
|
fetch_and_deploy_gh_release "paperless-gpt" "icereed/paperless-gpt" "tarball"
|
|
GO_VERSION="$(grep -m1 '^go ' /opt/paperless-gpt/go.mod | awk '{print $2}')" setup_go
|
|
|
|
msg_info "Setup 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 .
|
|
msg_ok "Setup Paperless-GPT"
|
|
|
|
mkdir -p /opt/paperless-gpt-data
|
|
input_url="${var_paperless_gpt_enter_url:-}"
|
|
[[ -n "$input_url" ]] || read -rp "${TAB3}Do you want to enter the Paperless local URL now? (y/n) " input_url || true
|
|
if [[ $input_url =~ ^[Yy]([Ee][Ss])?$ ]]; then
|
|
PAPERLESS_BASE_URL="${var_paperless_gpt_url:-}"
|
|
[[ -n "$PAPERLESS_BASE_URL" ]] || read -rp "${TAB3}Enter your Paperless-NGX instance URL (e.g., http://192.168.1.100:8000): " PAPERLESS_BASE_URL || true
|
|
[[ -n "$PAPERLESS_BASE_URL" ]] || { msg_error "No Paperless-NGX URL given; set var_paperless_gpt_url or answer the prompt"; exit 64; }
|
|
else
|
|
PAPERLESS_BASE_URL="http://your_paperless_ngx_url"
|
|
fi
|
|
|
|
input_token="${var_paperless_gpt_enter_token:-}"
|
|
[[ -n "$input_token" ]] || read -rp "${TAB3}Do you want to enter the Paperless API token now? (y/n) " input_token || true
|
|
if [[ $input_token =~ ^[Yy]([Ee][Ss])?$ ]]; then
|
|
PAPERLESS_API_TOKEN="${var_paperless_gpt_api_token:-}"
|
|
[[ -n "$PAPERLESS_API_TOKEN" ]] || read -rp "${TAB3}Enter your Paperless API token: " PAPERLESS_API_TOKEN || true
|
|
[[ -n "$PAPERLESS_API_TOKEN" ]] || { msg_error "No Paperless API token given; set var_paperless_gpt_api_token or answer the prompt"; exit 64; }
|
|
else
|
|
PAPERLESS_API_TOKEN="your_paperless_api_token"
|
|
fi
|
|
|
|
msg_info "Setup Environment"
|
|
cat <<EOF >/opt/paperless-gpt-data/.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
|
|
msg_ok "Setup Environment"
|
|
|
|
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-data/.env
|
|
StandardOutput=append:/var/log/paperless-gpt.log
|
|
StandardError=append:/var/log/paperless-gpt.log
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
systemctl enable -q --now paperless-gpt
|
|
msg_ok "Created Service"
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|