Proxmox/install/stirlingpdf-install.sh

120 lines
2.8 KiB
Bash
Raw Normal View History

2024-01-07 22:07:51 +01:00
#!/usr/bin/env bash
# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
2024-01-08 02:42:08 +01:00
msg_info "Installing Dependencies (Patience)"
2024-01-07 22:07:51 +01:00
$STD apt-get install -y \
curl \
sudo \
mc \
git \
automake \
autoconf \
libtool \
libleptonica-dev \
pkg-config \
zlib1g-dev \
make \
g++ \
unpaper \
ocrmypdf
2024-01-07 22:44:58 +01:00
msg_ok "Installed Dependencies"
2024-01-07 22:07:51 +01:00
2024-01-08 02:42:08 +01:00
msg_info "Installing LibreOffice Components"
$STD apt-get install -y \
libreoffice-writer \
libreoffice-calc \
libreoffice-impress
msg_ok "Installed LibreOffice Components"
2024-01-07 22:44:58 +01:00
msg_info "Installing Python Dependencies"
$STD apt-get install -y \
python3 \
python3-pip
2024-01-07 22:07:51 +01:00
$STD pip3 install \
uno \
opencv-python-headless \
unoconv \
pngquant \
WeasyPrint
2024-01-07 22:44:58 +01:00
msg_ok "Installed Python Dependencies"
2024-01-07 22:07:51 +01:00
msg_info "Installing Azul Zulu"
wget -qO /etc/apt/trusted.gpg.d/zulu-repo.asc "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9"
wget -q https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb
$STD dpkg -i zulu-repo_1.0.0-3_all.deb
$STD apt-get update
$STD apt-get -y install zulu17-jdk
msg_ok "Installed Azul Zulu"
msg_info "Installing JBIG2"
$STD git clone https://github.com/agl/jbig2enc /opt/jbig2enc
cd /opt/jbig2enc
$STD bash ./autogen.sh
$STD bash ./configure
$STD make
$STD make install
msg_ok "Installed JBIG2"
2024-01-08 02:42:08 +01:00
msg_info "Installing Language Packs (Patience)"
2024-01-07 22:07:51 +01:00
$STD apt-get install -y 'tesseract-ocr-*'
2024-01-07 22:58:09 +01:00
msg_ok "Installed Language Packs"
2024-01-07 22:07:51 +01:00
2024-01-08 02:42:08 +01:00
msg_info "Installing Stirling-PDF (Additional Patience)"
2024-01-07 22:07:51 +01:00
$STD git clone https://github.com/Stirling-Tools/Stirling-PDF.git
cd Stirling-PDF
chmod +x ./gradlew
$STD ./gradlew build
mkdir -p /opt/Stirling-PDF
touch /opt/Stirling-PDF/.env
mv ./build/libs/Stirling-PDF-*.jar /opt/Stirling-PDF/
mv scripts /opt/Stirling-PDF/
latest_version=$(ls -1 /opt/Stirling-PDF/Stirling-PDF-*.jar | sort -V | tail -n 1)
ln -s "$latest_version" /opt/Stirling-PDF/Stirling-PDF.jar
current_version=$(echo "$latest_version" | grep -oP '(?<=Stirling-PDF-)\d+(\.\d+)+(?=\.jar)')
2024-01-08 12:34:39 +01:00
msg_ok "Installed Stirling-PDF v$current_version"
2024-01-07 22:07:51 +01:00
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/stirlingpdf.service
[Unit]
Description=Stirling-PDF service
After=syslog.target network.target
[Service]
SuccessExitStatus=143
User=root
Group=root
Type=simple
EnvironmentFile=/opt/Stirling-PDF/.env
WorkingDirectory=/opt/Stirling-PDF
ExecStart=/usr/bin/java -jar Stirling-PDF.jar
2024-01-07 22:44:58 +01:00
ExecStop=/bin/kill -15 %n
2024-01-07 22:07:51 +01:00
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now stirlingpdf.service
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
2024-01-08 12:34:39 +01:00
rm -rf /zulu-repo_1.0.0-3_all.deb
2024-01-07 22:07:51 +01:00
$STD apt-get autoremove
$STD apt-get autoclean
msg_ok "Cleaned"