mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-21 07:54:58 +02:00
Compare commits
2 Commits
fix/dispat
...
feat/setup
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
237499e4d7 | ||
|
|
bade9b289d |
@@ -54,7 +54,7 @@ function update_script() {
|
|||||||
cp /opt/dispatcharr/.env /tmp/dispatcharr.env.backup
|
cp /opt/dispatcharr/.env /tmp/dispatcharr.env.backup
|
||||||
fi
|
fi
|
||||||
if [[ -f /opt/dispatcharr/start-gunicorn.sh ]]; then
|
if [[ -f /opt/dispatcharr/start-gunicorn.sh ]]; then
|
||||||
rm -f /opt/dispatcharr/start-gunicorn.sh
|
cp /opt/dispatcharr/start-gunicorn.sh /tmp/start-gunicorn.sh.backup
|
||||||
fi
|
fi
|
||||||
if [[ -f /opt/dispatcharr/start-celery.sh ]]; then
|
if [[ -f /opt/dispatcharr/start-celery.sh ]]; then
|
||||||
cp /opt/dispatcharr/start-celery.sh /tmp/start-celery.sh.backup
|
cp /opt/dispatcharr/start-celery.sh /tmp/start-celery.sh.backup
|
||||||
@@ -83,6 +83,9 @@ function update_script() {
|
|||||||
if [[ -f /tmp/dispatcharr.env.backup ]]; then
|
if [[ -f /tmp/dispatcharr.env.backup ]]; then
|
||||||
mv /tmp/dispatcharr.env.backup /opt/dispatcharr/.env
|
mv /tmp/dispatcharr.env.backup /opt/dispatcharr/.env
|
||||||
fi
|
fi
|
||||||
|
if [[ -f /tmp/start-gunicorn.sh.backup ]]; then
|
||||||
|
mv /tmp/start-gunicorn.sh.backup /opt/dispatcharr/start-gunicorn.sh
|
||||||
|
fi
|
||||||
if [[ -f /tmp/start-celery.sh.backup ]]; then
|
if [[ -f /tmp/start-celery.sh.backup ]]; then
|
||||||
mv /tmp/start-celery.sh.backup /opt/dispatcharr/start-celery.sh
|
mv /tmp/start-celery.sh.backup /opt/dispatcharr/start-celery.sh
|
||||||
fi
|
fi
|
||||||
@@ -102,35 +105,7 @@ function update_script() {
|
|||||||
rm -rf .venv
|
rm -rf .venv
|
||||||
$STD uv venv --clear
|
$STD uv venv --clear
|
||||||
$STD uv sync
|
$STD uv sync
|
||||||
$STD uv pip install uwsgi gevent celery redis daphne
|
$STD uv pip install gunicorn gevent celery redis daphne
|
||||||
cat <<'UWSGI_EOF' >/opt/dispatcharr/start-uwsgi.sh
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
cd /opt/dispatcharr
|
|
||||||
set -a
|
|
||||||
source .env
|
|
||||||
set +a
|
|
||||||
exec .venv/bin/uwsgi \
|
|
||||||
--chdir=/opt/dispatcharr \
|
|
||||||
--module=dispatcharr.wsgi:application \
|
|
||||||
--master \
|
|
||||||
--workers=4 \
|
|
||||||
--gevent=400 \
|
|
||||||
--http=0.0.0.0:5656 \
|
|
||||||
--http-keepalive=1 \
|
|
||||||
--http-timeout=600 \
|
|
||||||
--socket-timeout=600 \
|
|
||||||
--buffer-size=65536 \
|
|
||||||
--post-buffering=4096 \
|
|
||||||
--lazy-apps \
|
|
||||||
--thunder-lock \
|
|
||||||
--die-on-term \
|
|
||||||
--vacuum
|
|
||||||
UWSGI_EOF
|
|
||||||
chmod +x /opt/dispatcharr/start-uwsgi.sh
|
|
||||||
if grep -q 'start-gunicorn.sh' /etc/systemd/system/dispatcharr.service; then
|
|
||||||
sed -i 's|start-gunicorn.sh|start-uwsgi.sh|g' /etc/systemd/system/dispatcharr.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
fi
|
|
||||||
msg_ok "Updated Dispatcharr Backend"
|
msg_ok "Updated Dispatcharr Backend"
|
||||||
|
|
||||||
msg_info "Building Frontend"
|
msg_info "Building Frontend"
|
||||||
|
|||||||
@@ -81,11 +81,7 @@ STARTEOF
|
|||||||
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
|
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
|
||||||
msg_ok "Copied Frontend"
|
msg_ok "Copied Frontend"
|
||||||
|
|
||||||
msg_info "Updating NLTK Data"
|
setup_nltk "averaged_perceptron_tagger_eng" "/nltk_data"
|
||||||
mkdir -p /nltk_data/
|
|
||||||
cd /opt/mealie
|
|
||||||
$STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
|
|
||||||
msg_ok "Updated NLTK Data"
|
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
systemctl start mealie
|
systemctl start mealie
|
||||||
|
|||||||
@@ -164,13 +164,7 @@ function update_script() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_info "Updating NLTK Data"
|
setup_nltk "snowball_data stopwords punkt_tab" "/usr/share/nltk_data"
|
||||||
cd /opt/paperless
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data snowball_data
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data stopwords
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data punkt_tab ||
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data punkt
|
|
||||||
msg_ok "Updated NLTK Data"
|
|
||||||
|
|
||||||
msg_info "Starting all Paperless-ngx Services"
|
msg_info "Starting all Paperless-ngx Services"
|
||||||
systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue
|
systemctl start paperless-consumer paperless-webserver paperless-scheduler paperless-task-queue
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ msg_info "Installing Python Dependencies with uv"
|
|||||||
cd /opt/dispatcharr
|
cd /opt/dispatcharr
|
||||||
$STD uv venv --clear
|
$STD uv venv --clear
|
||||||
$STD uv sync
|
$STD uv sync
|
||||||
$STD uv pip install uwsgi gevent celery redis daphne
|
$STD uv pip install gunicorn gevent celery redis daphne
|
||||||
msg_ok "Installed Python Dependencies"
|
msg_ok "Installed Python Dependencies"
|
||||||
|
|
||||||
msg_info "Configuring Dispatcharr"
|
msg_info "Configuring Dispatcharr"
|
||||||
@@ -118,7 +118,7 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
# All other requests proxy to uWSGI
|
# All other requests proxy to Gunicorn
|
||||||
location / {
|
location / {
|
||||||
include proxy_params;
|
include proxy_params;
|
||||||
proxy_pass http://127.0.0.1:5656;
|
proxy_pass http://127.0.0.1:5656;
|
||||||
@@ -131,30 +131,20 @@ systemctl restart nginx
|
|||||||
msg_ok "Configured Nginx"
|
msg_ok "Configured Nginx"
|
||||||
|
|
||||||
msg_info "Creating Services"
|
msg_info "Creating Services"
|
||||||
cat <<EOF >/opt/dispatcharr/start-uwsgi.sh
|
cat <<EOF >/opt/dispatcharr/start-gunicorn.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cd /opt/dispatcharr
|
cd /opt/dispatcharr
|
||||||
set -a
|
set -a
|
||||||
source .env
|
source .env
|
||||||
set +a
|
set +a
|
||||||
exec .venv/bin/uwsgi \\
|
exec uv run gunicorn \\
|
||||||
--chdir=/opt/dispatcharr \\
|
|
||||||
--module=dispatcharr.wsgi:application \\
|
|
||||||
--master \\
|
|
||||||
--workers=4 \\
|
--workers=4 \\
|
||||||
--gevent=400 \\
|
--worker-class=gevent \\
|
||||||
--http=0.0.0.0:5656 \\
|
--timeout=300 \\
|
||||||
--http-keepalive=1 \\
|
--bind 0.0.0.0:5656 \\
|
||||||
--http-timeout=600 \\
|
dispatcharr.wsgi:application
|
||||||
--socket-timeout=600 \\
|
|
||||||
--buffer-size=65536 \\
|
|
||||||
--post-buffering=4096 \\
|
|
||||||
--lazy-apps \\
|
|
||||||
--thunder-lock \\
|
|
||||||
--die-on-term \\
|
|
||||||
--vacuum
|
|
||||||
EOF
|
EOF
|
||||||
chmod +x /opt/dispatcharr/start-uwsgi.sh
|
chmod +x /opt/dispatcharr/start-gunicorn.sh
|
||||||
|
|
||||||
cat <<EOF >/opt/dispatcharr/start-celery.sh
|
cat <<EOF >/opt/dispatcharr/start-celery.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
@@ -194,7 +184,7 @@ After=network.target postgresql.service redis-server.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
WorkingDirectory=/opt/dispatcharr
|
WorkingDirectory=/opt/dispatcharr
|
||||||
ExecStart=/opt/dispatcharr/start-uwsgi.sh
|
ExecStart=/opt/dispatcharr/start-gunicorn.sh
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
User=root
|
User=root
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ msg_info "Setting up KitchenOwl"
|
|||||||
cd /opt/kitchenowl/backend
|
cd /opt/kitchenowl/backend
|
||||||
$STD uv sync --no-dev
|
$STD uv sync --no-dev
|
||||||
sed -i 's/default=True/default=False/' /opt/kitchenowl/backend/wsgi.py
|
sed -i 's/default=True/default=False/' /opt/kitchenowl/backend/wsgi.py
|
||||||
mkdir -p /nltk_data
|
setup_nltk "averaged_perceptron_tagger_eng" "/nltk_data"
|
||||||
$STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
|
|
||||||
JWT_SECRET=$(openssl rand -hex 32)
|
JWT_SECRET=$(openssl rand -hex 32)
|
||||||
mkdir -p /opt/kitchenowl/data
|
mkdir -p /opt/kitchenowl/data
|
||||||
cat <<EOF >/opt/kitchenowl/kitchenowl.env
|
cat <<EOF >/opt/kitchenowl/kitchenowl.env
|
||||||
|
|||||||
@@ -55,11 +55,7 @@ mkdir -p /opt/mealie/mealie/frontend
|
|||||||
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
|
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
|
||||||
msg_ok "Copied Frontend"
|
msg_ok "Copied Frontend"
|
||||||
|
|
||||||
msg_info "Downloading NLTK Data"
|
setup_nltk "averaged_perceptron_tagger_eng" "/nltk_data"
|
||||||
mkdir -p /nltk_data/
|
|
||||||
cd /opt/mealie
|
|
||||||
$STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
|
|
||||||
msg_ok "Downloaded NLTK Data"
|
|
||||||
|
|
||||||
msg_info "Writing Environment File"
|
msg_info "Writing Environment File"
|
||||||
SECRET=$(openssl rand -hex 32)
|
SECRET=$(openssl rand -hex 32)
|
||||||
|
|||||||
@@ -94,18 +94,12 @@ user.save()
|
|||||||
EOF
|
EOF
|
||||||
msg_ok "Set up admin Paperless-ngx User & Password"
|
msg_ok "Set up admin Paperless-ngx User & Password"
|
||||||
|
|
||||||
msg_info "Installing Natural Language Toolkit (Patience)"
|
setup_nltk "snowball_data stopwords punkt_tab" "/usr/share/nltk_data"
|
||||||
cd /opt/paperless
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data snowball_data
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data stopwords
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data punkt_tab ||
|
|
||||||
$STD uv run python -m nltk.downloader -d /usr/share/nltk_data punkt
|
|
||||||
for policy_file in /etc/ImageMagick-6/policy.xml /etc/ImageMagick-7/policy.xml; do
|
for policy_file in /etc/ImageMagick-6/policy.xml /etc/ImageMagick-7/policy.xml; do
|
||||||
if [[ -f "$policy_file" ]]; then
|
if [[ -f "$policy_file" ]]; then
|
||||||
sed -i -e 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' "$policy_file"
|
sed -i -e 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' "$policy_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
msg_ok "Installed Natural Language Toolkit"
|
|
||||||
|
|
||||||
msg_info "Creating Services"
|
msg_info "Creating Services"
|
||||||
cat <<EOF >/etc/systemd/system/paperless-scheduler.service
|
cat <<EOF >/etc/systemd/system/paperless-scheduler.service
|
||||||
|
|||||||
@@ -2095,10 +2095,10 @@ get_latest_gh_tag() {
|
|||||||
local count
|
local count
|
||||||
count=$(jq 'length' "$temp_file" 2>/dev/null || echo 0)
|
count=$(jq 'length' "$temp_file" 2>/dev/null || echo 0)
|
||||||
if [[ "$count" -gt 0 ]]; then
|
if [[ "$count" -gt 0 ]]; then
|
||||||
tag=$(jq -r '.[].ref' "$temp_file" \
|
tag=$(jq -r '.[].ref' "$temp_file" |
|
||||||
| sed 's|^refs/tags/||' \
|
sed 's|^refs/tags/||' |
|
||||||
| sort -V \
|
sort -V |
|
||||||
| tail -n1)
|
tail -n1)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# No prefix: just take the first (newest) tag from /tags
|
# No prefix: just take the first (newest) tag from /tags
|
||||||
@@ -9439,3 +9439,73 @@ function fetch_and_deploy_gl_release() {
|
|||||||
msg_ok "Deployed: $app ($version)"
|
msg_ok "Deployed: $app ($version)"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Download NLTK data packages directly from GitHub, bypassing Python.
|
||||||
|
# Avoids CPU-instruction failures (SIGILL) on older hardware lacking AVX.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# setup_nltk "averaged_perceptron_tagger_eng" "/nltk_data"
|
||||||
|
# setup_nltk "snowball_data stopwords punkt_tab" "/usr/share/nltk_data"
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1 - Space-separated list of NLTK package IDs
|
||||||
|
# $2 - Target directory (default: /usr/share/nltk_data)
|
||||||
|
#
|
||||||
|
# Returns: 0 on success, non-zero if any package failed
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
function setup_nltk() {
|
||||||
|
local packages="${1:?setup_nltk requires at least one package name}"
|
||||||
|
local target_dir="${2:-/usr/share/nltk_data}"
|
||||||
|
local NLTK_INDEX_URL="https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml"
|
||||||
|
local index_xml rc=0
|
||||||
|
|
||||||
|
ensure_dependencies unzip
|
||||||
|
|
||||||
|
index_xml=$(curl_with_retry "$NLTK_INDEX_URL" "-") || {
|
||||||
|
msg_error "Failed to fetch NLTK package index"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local pkg
|
||||||
|
for pkg in $packages; do
|
||||||
|
msg_info "Downloading NLTK: $pkg"
|
||||||
|
local pkg_line subdir pkg_url do_unzip tmp_zip
|
||||||
|
|
||||||
|
pkg_line=$(echo "$index_xml" | grep "id=\"${pkg}\"" | head -1)
|
||||||
|
if [[ -z "$pkg_line" ]]; then
|
||||||
|
msg_error "NLTK package not found in index: $pkg"
|
||||||
|
rc=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
subdir=$(echo "$pkg_line" | grep -oP 'subdir="\K[^"]+')
|
||||||
|
pkg_url=$(echo "$pkg_line" | grep -oP 'url="\K[^"]+')
|
||||||
|
do_unzip=$(echo "$pkg_line" | grep -oP 'unzip="\K[^"]+')
|
||||||
|
|
||||||
|
if [[ -z "$subdir" || -z "$pkg_url" ]]; then
|
||||||
|
msg_error "Could not parse NLTK index entry for: $pkg"
|
||||||
|
rc=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}/${subdir}"
|
||||||
|
tmp_zip=$(mktemp --suffix=.zip)
|
||||||
|
|
||||||
|
if CURL_TIMEOUT=120 curl_with_retry "$pkg_url" "$tmp_zip"; then
|
||||||
|
if [[ "$do_unzip" == "1" ]]; then
|
||||||
|
$STD unzip -q -o "$tmp_zip" -d "${target_dir}/${subdir}/"
|
||||||
|
rm -f "$tmp_zip"
|
||||||
|
else
|
||||||
|
mv "$tmp_zip" "${target_dir}/${subdir}/${pkg}.zip"
|
||||||
|
fi
|
||||||
|
msg_ok "Downloaded NLTK: $pkg"
|
||||||
|
else
|
||||||
|
msg_error "Failed to download NLTK package: $pkg"
|
||||||
|
rm -f "$tmp_zip"
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return $rc
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user