Update docspell-install.sh

This commit is contained in:
CanbiZ 2025-03-17 13:10:34 +01:00
parent 598f6a091c
commit b7aae6802e

View File

@ -5,7 +5,7 @@
# License: MIT # License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE # https://github.com/tteck/Proxmox/raw/main/LICENSE
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color color
verb_ip6 verb_ip6
catch_errors catch_errors
@ -14,7 +14,7 @@ network_check
update_os update_os
msg_info "Installing Dependencies (Patience)" msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y --no-install-recommends \ $STD apt-get install -y \
unzip \ unzip \
htop \ htop \
gnupg2 \ gnupg2 \
@ -29,67 +29,78 @@ $STD apt-get install -y --no-install-recommends \
unoconv \ unoconv \
wkhtmltopdf \ wkhtmltopdf \
ocrmypdf \ ocrmypdf \
wget \
zip \
curl \
sudo \ sudo \
git \
make \ make \
mc mc
msg_ok "Installed Dependencies"
mkdir -p /opt/docspell && cd /opt/docspell msg_info "Setting up PostgreSQL Repository"
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list
msg_ok "Set up PostgreSQL Repository"
msg_info "Setup Apache Solr"
mkdir -p /opt/docspell
cd /opt/docspell
SOLR_DOWNLOAD_URL="https://downloads.apache.org/lucene/solr/" SOLR_DOWNLOAD_URL="https://downloads.apache.org/lucene/solr/"
latest_version=$(curl -s "$SOLR_DOWNLOAD_URL" | grep -oP '(?<=<a href=")[^"]+(?=/">[0-9])' | head -n 1) latest_version=$(curl -s "$SOLR_DOWNLOAD_URL" | grep -oP '(?<=<a href=")[^"]+(?=/">[0-9])' | head -n 1)
download_url="${SOLR_DOWNLOAD_URL}${latest_version}/solr-${latest_version}.tgz" download_url="${SOLR_DOWNLOAD_URL}${latest_version}/solr-${latest_version}.tgz"
$STD wget "$download_url" wget -q "$download_url"
tar xzf "solr-$latest_version.tgz" tar xzf "solr-$latest_version.tgz"
$STD bash "/opt/docspell/solr-$latest_version/bin/install_solr_service.sh" "solr-$latest_version.tgz" $STD bash "/opt/docspell/solr-$latest_version/bin/install_solr_service.sh" "solr-$latest_version.tgz"
mv /opt/solr /opt/docspell/solr mv /opt/solr /opt/docspell/solr
$STD systemctl start solr systemctl enable -q --now solr
$STD su solr -c '/opt/docspell/solr/bin/solr create -c docspell' $STD su solr -c '/opt/docspell/solr/bin/solr create -c docspell'
msg_ok "Installed Dependencies" msg_ok "Setup Apache Solr"
msg_info "Install/Set up PostgreSQL Database" msg_info "Install/Set up PostgreSQL Database"
DB_NAME=docspelldb
DB_USER=docspell
DB_PASS="$(openssl rand -base64 18 | cut -c1-13)"
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list
$STD apt-get update
$STD apt-get install -y postgresql-16 $STD apt-get install -y postgresql-16
$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" DB_NAME=docspell_db
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" DB_USER=docspell_usr
$STD systemctl enable postgresql DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)"
echo "" >>~/docspell.creds $STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
echo -e "Docspell Database Name: $DB_NAME" >>~/docspell.creds $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
echo -e "Docspell Database User: $DB_USER" >>~/docspell.creds $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
echo -e "Docspell Database Password: $DB_PASS" >>~/docspell.creds $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
{
echo "Docspell-Credentials"
echo "Docspell Database Name: $DB_NAME"
echo "Docspell Database User: $DB_USER"
echo "Docspell Database Password: $DB_PASS"
} >>~/docspell.creds
msg_ok "Set up PostgreSQL Database" msg_ok "Set up PostgreSQL Database"
msg_info "Setup Docspell (Patience)" msg_info "Setup Docspell (Patience)"
Docspell=$(wget -q https://github.com/eikek/docspell/releases/latest -O - | grep "title>Release" | cut -d " " -f 5) Docspell=$(wget -q https://github.com/eikek/docspell/releases/latest -O - | grep "title>Release" | cut -d " " -f 5)
DocspellDSC=$(wget -q https://github.com/docspell/dsc/releases/latest -O - | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//') DocspellDSC=$(wget -q https://github.com/docspell/dsc/releases/latest -O - | grep "title>Release" | cut -d " " -f 4 | sed 's/^v//')
cd /opt cd /opt
$STD wget https://github.com/eikek/docspell/releases/download/v${Docspell}/docspell-joex_${Docspell}_all.deb wget -q https://github.com/eikek/docspell/releases/download/v${Docspell}/docspell-joex_${Docspell}_all.deb
$STD wget https://github.com/eikek/docspell/releases/download/v${Docspell}/docspell-restserver_${Docspell}_all.deb wget -q https://github.com/eikek/docspell/releases/download/v${Docspell}/docspell-restserver_${Docspell}_all.deb
$STD dpkg -i docspell-* $STD dpkg -i docspell-*
$STD wget https://github.com/docspell/dsc/releases/download/v${DocspellDSC}/dsc_amd64-musl-${DocspellDSC} wget -q https://github.com/docspell/dsc/releases/download/v${DocspellDSC}/dsc_amd64-musl-${DocspellDSC}
mv dsc_amd* dsc mv dsc_amd* dsc
chmod +x dsc chmod +x dsc
mv dsc /usr/bin mv dsc /usr/bin
ln -s /etc/docspell-joex /opt/docspell/docspell-joex && ln -s /etc/docspell-restserver /opt/docspell/docspell-restserver && ln -s /usr/bin/dsc /opt/docspell/dsc ln -s /etc/docspell-joex /opt/docspell/docspell-joex && ln -s /etc/docspell-restserver /opt/docspell/docspell-restserver && ln -s /usr/bin/dsc /opt/docspell/dsc
cd /opt && rm -R solr-$latest_version && rm -R docspell-joex_${Docspell}_all.deb && rm -R docspell-restserver_${Docspell}_all.deb cd /opt && rm -R solr-$latest_version && rm -R docspell-joex_${Docspell}_all.deb && rm -R docspell-restserver_${Docspell}_all.deb
cd /opt/docspell && rm -R solr-$latest_version.tgz && rm -R solr-$latest_version cd /opt/docspell && rm -R solr-$latest_version.tgz && rm -R solr-$latest_version
sudo sed -i "s|url = \"jdbc:postgresql://localhost:5432/db\"|url = \"jdbc:postgresql://localhost:5432/$DB_NAME\"|" /opt/docspell/docspell-restserver/docspell-server.conf
sudo sed -i "s|url = \"jdbc:postgresql://localhost:5432/db\"|url = \"jdbc:postgresql://localhost:5432/$DB_NAME\"|" /opt/docspell/docspell-joex/docspell-joex.conf sed -i -E "
sudo sed -i "s/user=.*/user=$DB_USER/" /opt/docspell/docspell-restserver/docspell-server.conf s|bind\.address = \".*\"|bind.address = \"0.0.0.0\"|;
sudo sed -i "s/password=.*/password=$DB_PASS/" /opt/docspell/docspell-restserver/docspell-server.conf s|url = \"jdbc:postgresql://server:5432/db\"|url = \"jdbc:postgresql://localhost:5432/$DB_NAME\"|;
sudo sed -i "s/user=.*/user=$DB_USER/" /opt/docspell/docspell-joex/docspell-joex.conf s|user = \".*\"|user = \"$DB_USER\"|;
sudo sed -i "s/password=.*/password=$DB_PASS/" /opt/docspell/docspell-joex/docspell-joex.conf s|password = \".*\"|password = \"$DB_PASS\"|;
systemctl start docspell-restserver " /opt/docspell/docspell-restserver/docspell-server.conf
systemctl enable docspell-restserver sed -i -E "
systemctl start docspell-joex s|bind\\.address = \".*\"|bind.address = \"0.0.0.0\"|;
systemctl enable docspell-joex s|url = \"jdbc:postgresql://server:5432/db\"|url = \"jdbc:postgresql://localhost:5432/$DB_NAME\"|;
s|user = \".*\"|user = \"$DB_USER\"|;
s|password = \".*\"|password = \"$DB_PASS\"|;
" /opt/docspell/docspell-joex/docspell-joex.conf
systemctl enable -q --now docspell-restserver
systemctl enable -q --now docspell-joex
motd_ssh motd_ssh
customize customize