Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Stirling-PDF > LibreOffice/unoconv Integration Issues #1322

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

m6urns
Copy link
Contributor

@m6urns m6urns commented Jan 8, 2025

✍️ Description

The current installation script for the StirlingPDF LXC has issues with LibreOffice and unoconv integration, causing document conversion failures. These issues are caused by the following:

  1. Missing LibreOffice dependencies
  2. No dedicated LibreOffice listener service
  3. Incorrect port configuration for unoconv/LibreOffice communication
  4. Missing environment variables for Python-UNO bridge

Issues with document conversion and missing environmental variables were resolved by:

  1. Adding essential LibreOffice packages (libreoffice-core, libreoffice-common, libreoffice-base-core)
  2. Explicitly installing python3-uno
  3. Creating a dedicated LibreOffice listener service configured for port 2002 (unoconv's default)
  4. Adding necessary environment variables for proper Python-UNO bridge functionality
  5. Modifying StirlingPDF service to depend on LibreOffice listener service
  6. Adding service configuration for automatic restarts


🛠️ Type of Change

Please check the relevant options:

  • Bug fix (non-breaking change that resolves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change unexpectedly)
  • New script (a fully functional and thoroughly tested script or set of scripts)

✅ Prerequisites

The following steps must be completed for the pull request to be considered:

  • Self-review performed (I have reviewed my code to ensure it follows established patterns and conventions.)
  • Testing performed (I have thoroughly tested my changes and verified expected functionality.)
  • Documentation updated (I have updated any relevant documentation)

📋 Additional Information (optional)

Provide any extra context or screenshots about the feature or fix here.

…re a running libreoffice service and setup env variables so they are accessible to StirlingPDF. Modify stirlingPDF service to wait for libreoffice service to start. Enable and explicitly start libreoffice and stirlingPDF services.
@m6urns m6urns requested a review from a team as a code owner January 8, 2025 01:31
@github-actions github-actions bot added the update script A change that updates a script label Jan 8, 2025
@MickLesk
Copy link
Member

MickLesk commented Jan 8, 2025

Please add/write an short guide here for users that have already an existing LXC (Breaking Change) to update the own LXC

install/stirling-pdf-install.sh Outdated Show resolved Hide resolved
install/stirling-pdf-install.sh Outdated Show resolved Hide resolved
install/stirling-pdf-install.sh Outdated Show resolved Hide resolved
install/stirling-pdf-install.sh Show resolved Hide resolved
install/stirling-pdf-install.sh Outdated Show resolved Hide resolved
install/stirling-pdf-install.sh Outdated Show resolved Hide resolved
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Jan 8, 2025

Script validation

❌ We found issues in the following changed files:

Not executable:

  • .github/workflows/validate-filenames.yml
  • .github/workflows/validate-formatting.yaml
  • .github/workflows/validate-scripts.yml
  • CHANGELOG.md
  • install/stirling-pdf-install.sh
  • json/postgresql.json

Copyright header line missing or invalid:

  • .github/workflows/validate-filenames.yml
  • .github/workflows/validate-formatting.yaml
  • .github/workflows/validate-scripts.yml
  • CHANGELOG.md
  • json/postgresql.json

Author header line missing or invalid:

  • .github/workflows/validate-filenames.yml
  • .github/workflows/validate-formatting.yaml
  • .github/workflows/validate-scripts.yml
  • CHANGELOG.md
  • json/postgresql.json

License header line missing or invalid:

  • .github/workflows/validate-filenames.yml
  • .github/workflows/validate-formatting.yaml
  • .github/workflows/validate-scripts.yml
  • CHANGELOG.md
  • install/stirling-pdf-install.sh
  • json/postgresql.json

Source header line missing or invalid:

  • .github/workflows/validate-filenames.yml
  • .github/workflows/validate-formatting.yaml
  • .github/workflows/validate-scripts.yml
  • CHANGELOG.md
  • install/stirling-pdf-install.sh
  • json/postgresql.json

@m6urns
Copy link
Contributor Author

m6urns commented Jan 9, 2025

Repairing an existing installation of the Stirling-PDF LXC

  1. Ensure essential LibreOffice components are installed
apt-get install -y \
  libreoffice-core \
  libreoffice-common \
  libreoffice-base-core \
  python3-uno
  1. Create a LibreOffice listener service
cat <<EOF >/etc/systemd/system/libreoffice-listener.service
[Unit]
Description=LibreOffice Headless Listener Service
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/lib/libreoffice/program/soffice --headless --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --accept="socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext"
Restart=always

[Install]
WantedBy=multi-user.target
EOF
  1. Configure Environmental Variables
cat <<EOF >/opt/Stirling-PDF/.env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/libreoffice/program
UNO_PATH=/usr/lib/libreoffice/program
PYTHONPATH=/usr/lib/python3/dist-packages:/usr/lib/libreoffice/program
LD_LIBRARY_PATH=/usr/lib/libreoffice/program
EOF
  1. Update Stirling-PDF Service
cat <<EOF >/etc/systemd/system/stirlingpdf.service
[Unit]
Description=Stirling-PDF service
After=syslog.target network.target libreoffice-listener.service
Requires=libreoffice-listener.service

[Service]
SuccessExitStatus=143
Type=simple
User=root
Group=root
EnvironmentFile=/opt/Stirling-PDF/.env
WorkingDirectory=/opt/Stirling-PDF
ExecStart=/usr/bin/java -jar Stirling-PDF.jar
ExecStop=/bin/kill -15 %n
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF
  1. Enable and Restart Services
systemctl daemon-reload
systemctl enable -q --now libreoffice-listener
systemctl restart stirlingpdf

@MickLesk MickLesk changed the title Fix LibreOffice/unoconv Integration Issues in Installation Script Fix: Stirling-PDF > LibreOffice/unoconv Integration Issues Jan 9, 2025
MickLesk
MickLesk previously approved these changes Jan 9, 2025
@michelroegl-brunner michelroegl-brunner dismissed stale reviews from MickLesk and themself via 501c1f8 January 9, 2025 18:09
@michelroegl-brunner michelroegl-brunner merged commit 0b85f26 into community-scripts:main Jan 9, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
update script A change that updates a script
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants