@@ -15,7 +15,6 @@ update_os
1515
1616msg_info " Installing Dependencies (Patience)"
1717$STD apt-get install -y \
18- git \
1918 automake \
2019 autoconf \
2120 libtool \
@@ -25,10 +24,26 @@ $STD apt-get install -y \
2524 make \
2625 g++ \
2726 unpaper \
27+ fonts-urw-base35 \
2828 qpdf \
2929 poppler-utils
3030msg_ok " Installed Dependencies"
3131
32+ PYTHON_VERSION=" 3.12" setup_uv
33+ JAVA_VERSION=" 21" setup_java
34+
35+ read -r -p " ${TAB3} Do you want to Stirling-PDF with Login? (no/n = without Login) [Y/n] " response
36+ response=${response,,} # Convert to lowercase
37+ login_mode=" false"
38+ if [[ " $response " == " y" || " $response " == " yes" || -z " $response " ]]; then
39+ USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release " stirling-pdf" " Stirling-Tools/Stirling-PDF" " singlefile" " latest" " /opt/Stirling-PDF" " Stirling-PDF-with-login.jar"
40+ mv /opt/Stirling-PDF/Stirling-PDF-with-login.jar /opt/Stirling-PDF/Stirling-PDF.jar
41+ touch ~ /.Stirling-PDF-login
42+ login_mode=" true"
43+ else
44+ USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release " stirling-pdf" " Stirling-Tools/Stirling-PDF" " singlefile" " latest" " /opt/Stirling-PDF" " Stirling-PDF.jar"
45+ fi
46+
3247msg_info " Installing LibreOffice Components"
3348$STD apt-get install -y \
3449 libreoffice-writer \
@@ -37,32 +52,35 @@ $STD apt-get install -y \
3752 libreoffice-core \
3853 libreoffice-common \
3954 libreoffice-base-core \
40- python3-uno
55+ libreoffice-script-provider-python \
56+ libreoffice-java-common \
57+ unoconv \
58+ pngquant \
59+ weasyprint
4160msg_ok " Installed LibreOffice Components"
4261
4362msg_info " Installing Python Dependencies"
44- $STD apt-get install -y \
45- python3 \
46- python3-pip
47- rm -rf /usr/lib/python3. * /EXTERNALLY-MANAGED
48- $STD pip3 install \
49- uno \
63+ mkdir -p /tmp/stirling-pdf
64+ $STD uv venv /opt/.venv
65+ export PATH= " /opt/.venv/bin: $PATH "
66+ source /opt/.venv/bin/activate
67+ $STD uv pip install --upgrade pip
68+ $STD uv pip install \
5069 opencv-python-headless \
51- unoconv \
52- pngquant \
53- WeasyPrint
70+ ocrmypdf \
71+ pillow \
72+ pdf2image
73+
74+ $STD apt-get install -y python3-uno python3-pip
75+ $STD pip3 install --break-system-packages unoserver
76+ ln -sf /opt/.venv/bin/python3 /usr/local/bin/python3
77+ ln -sf /opt/.venv/bin/pip /usr/local/bin/pip
5478msg_ok " Installed Python Dependencies"
5579
56- msg_info " Installing Azul Zulu"
57- curl -fsSL " https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" -o " /etc/apt/trusted.gpg.d/zulu-repo.asc"
58- curl -fsSL " https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb" -o " /zulu-repo_1.0.0-3_all.deb"
59- $STD dpkg -i zulu-repo_1.0.0-3_all.deb
60- $STD apt-get update
61- $STD apt-get -y install zulu17-jdk
62- msg_ok " Installed Azul Zulu"
63-
6480msg_info " Installing JBIG2"
65- $STD git clone https://github.com/agl/jbig2enc /opt/jbig2enc
81+ $STD curl -fsSL -o /tmp/jbig2enc.tar.gz https://github.com/agl/jbig2enc/archive/refs/tags/0.30.tar.gz
82+ mkdir -p /opt/jbig2enc
83+ tar -xzf /tmp/jbig2enc.tar.gz -C /opt/jbig2enc --strip-components=1
6684cd /opt/jbig2enc
6785$STD bash ./autogen.sh
6886$STD bash ./configure
@@ -74,25 +92,46 @@ msg_info "Installing Language Packs (Patience)"
7492$STD apt-get install -y ' tesseract-ocr-*'
7593msg_ok " Installed Language Packs"
7694
77- msg_info " Installing Stirling-PDF (Additional Patience)"
78- RELEASE=$( curl -fsSL https://api.github.com/repos/Stirling-Tools/Stirling-PDF/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
79- curl -fsSL " https://github.com/Stirling-Tools/Stirling-PDF/archive/refs/tags/v${RELEASE} .tar.gz" -o " v${RELEASE} .tar.gz"
80- tar -xzf v${RELEASE} .tar.gz
81- cd Stirling-PDF-$RELEASE
82- chmod +x ./gradlew
83- $STD ./gradlew build -x spotlessApply -x spotlessCheck -x test -x sonarqube
84- mkdir -p /opt/Stirling-PDF
85- touch /opt/Stirling-PDF/.env
86- mv ./stirling-pdf/build/libs/* .jar /opt/Stirling-PDF/Stirling-PDF-$RELEASE .jar
87- mv scripts /opt/Stirling-PDF/
88- mv pipeline /opt/Stirling-PDF/
89- mv stirling-pdf/src/main/resources/static/fonts/* .ttf /usr/share/fonts/opentype/noto/
90- ln -s /opt/Stirling-PDF/Stirling-PDF-$RELEASE .jar /opt/Stirling-PDF/Stirling-PDF.jar
91- ln -s /usr/share/tesseract-ocr/5/tessdata/ /usr/share/tessdata
92- msg_ok " Installed Stirling-PDF"
95+ msg_info " Creating Environment Variables"
96+ cat << EOF >/opt/Stirling-PDF/.env
97+ # Java tuning
98+ JAVA_BASE_OPTS="-XX:+UnlockExperimentalVMOptions -XX:MaxRAMPercentage=75 -XX:InitiatingHeapOccupancyPercent=20 -XX:+G1PeriodicGCInvokesConcurrent -XX:G1PeriodicGCInterval=10000 -XX:+UseStringDeduplication -XX:G1PeriodicGCSystemLoadThreshold=70"
99+ JAVA_CUSTOM_OPTS=""
100+
101+ # LibreOffice
102+ PATH=/opt/.venv/bin:/usr/lib/libreoffice/program:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
103+ UNO_PATH=/usr/lib/libreoffice/program
104+ URE_BOOTSTRAP=file:///usr/lib/libreoffice/program/fundamentalrc
105+ PYTHONPATH=/usr/lib/libreoffice/program:/opt/.venv/lib/python3.12/site-packages
106+ LD_LIBRARY_PATH=/usr/lib/libreoffice/program
107+
108+ STIRLING_TEMPFILES_DIRECTORY=/tmp/stirling-pdf
109+ TMPDIR=/tmp/stirling-pdf
110+ TEMP=/tmp/stirling-pdf
111+ TMP=/tmp/stirling-pdf
112+
113+ # Paths
114+ PATH=/opt/.venv/bin:/usr/lib/libreoffice/program:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
115+ EOF
116+
117+ if [[ " $login_mode " == " true" ]]; then
118+ cat << EOF >>/opt/Stirling-PDF/.env
119+ # activate Login
120+ DISABLE_ADDITIONAL_FEATURES=false
121+ SECURITY_ENABLELOGIN=true
122+
123+ # login credentials
124+ SECURITY_INITIALLOGIN_USERNAME=admin
125+ SECURITY_INITIALLOGIN_PASSWORD=stirling
126+ EOF
127+ fi
128+ msg_ok " Created Environment Variables"
129+
130+ msg_info " Refreshing Font Cache"
131+ $STD fc-cache -fv
132+ msg_ok " Font Cache Updated"
93133
94134msg_info " Creating Service"
95- # Create LibreOffice listener service
96135cat << EOF >/etc/systemd/system/libreoffice-listener.service
97136[Unit]
98137Description=LibreOffice Headless Listener Service
@@ -109,14 +148,6 @@ Restart=always
109148WantedBy=multi-user.target
110149EOF
111150
112- # Set up environment variables
113- cat << EOF >/opt/Stirling-PDF/.env
114- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/libreoffice/program
115- UNO_PATH=/usr/lib/libreoffice/program
116- PYTHONPATH=/usr/lib/python3/dist-packages:/usr/lib/libreoffice/program
117- LD_LIBRARY_PATH=/usr/lib/libreoffice/program
118- EOF
119-
120151cat << EOF >/etc/systemd/system/stirlingpdf.service
121152[Unit]
122153Description=Stirling-PDF service
@@ -139,16 +170,32 @@ RestartSec=10
139170WantedBy=multi-user.target
140171EOF
141172
142- # Enable and start services
173+ cat << EOF >/etc/systemd/system/unoserver.service
174+ [Unit]
175+ Description=UnoServer RPC Interface
176+ After=libreoffice-listener.service
177+ Requires=libreoffice-listener.service
178+
179+ [Service]
180+ Type=simple
181+ ExecStart=/usr/local/bin/unoserver --port 2003 --interface 127.0.0.1
182+ Restart=always
183+ EnvironmentFile=/opt/Stirling-PDF/.env
184+
185+ [Install]
186+ WantedBy=multi-user.target
187+ EOF
188+
143189systemctl enable -q --now libreoffice-listener
144190systemctl enable -q --now stirlingpdf
191+ systemctl enable -q --now unoserver
145192msg_ok " Created Service"
146193
147194motd_ssh
148195customize
149196
150197msg_info " Cleaning up"
151- rm -rf v ${RELEASE} .tar.gz /zulu-repo_1.0.0-3_all.deb
198+ rm -f /tmp/jbig2enc .tar.gz
152199$STD apt-get -y autoremove
153200$STD apt-get -y autoclean
154201msg_ok " Cleaned"
0 commit comments