LibreSign / libresign

✍️ Nextcloud app to sign PDF documents
https://libresign.coop
486 stars 56 forks source link

Extended check for Java binaries. Support for Alpine/Nextcloud-AIO #3026

Closed neocult-de closed 5 months ago

neocult-de commented 5 months ago

Is your feature request related to a problem? Please describe. The currently used version of java supports the majority of glibc based linux distributions. The Nextcloud-AIO system though builds its containers with Alpine where possible and it is musl libc based. Then the java build with glibc will not work. Manual modifications are necessary and version check might fail mostly.

Describe the solution you'd like There should be a detection mechanism for musl libc and use an according openjdk version and allow the version and runtime check for it.

Describe alternatives you've considered I have tried to add compatibility to glibc with "apk add gcompat libstdc++" in the nextcloud-container. With initially good results. But it can break anytime. I also added the repository version: "apk add openjdk11" and link it instead "ln -s /usr/bin/java java" #inside the java/bin folder of libresign - But then version mismatch is obviously a thing, but it is usable. (pdftk is on a green status and java running)

Additional context As Nextcloud-AIO is an official release of Nextcloud which is quite popular, support for "Alpine"-based Java should increase adoption and reach of LibreSign as soon as it is easy to install there too.

vitormattos commented 5 months ago

Thanks by your help to LibreSign!

I will look as a soon.

neocult-de commented 5 months ago

As the issue would seem just to get a Alpine compatible openjdk release I dig a bit further to advance the cause of LibreSign for all of us.

It might be already in use for LibreSign, but the current free releases of the Eclipse Temurin project would fit LibreSign needs well. As the only issue at the moment is that the downloaded java version is the "linux x64" release for libc and there is an aquivalent release for "alpine linux x64" available (Version details below).

If we download the same release 21.0.2_13 for Alpine Linux and drop it in the java folder we get a successful version check and everything is running (See attached picture as well):

` sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ libresign:configure:check


Status Resource Message Tip


success java Java version: openjdk version "21.0.2" 2024-01-16 LTS success java Java binary: /mnt/ncdata/appdata_ocn3bta2ji2r/libresign/java/jdk-21.0.2+13-jre/bin/java success pdftk PDFtk version: 3.3.3 success pdftk PDFtk path: /mnt/ncdata//appdata_ocn3bta2ji2r/libresign/pdftk.jar success jsignpdf JSignPdf version: 2.2.2 success jsignpdf JSignPdf path: /mnt/ncdata/appdata_ocn3bta2ji2r/libresign/jsignpdf-2.2.2/JSignPdf.jar success cfssl CFSSL binary path: /mnt/ncdata/appdata_ocn3bta2ji2r/libresign/cfssl success cfssl CFSSL: Version: 1.6.4, Runtime: go1.18 success cfssl-configure Root certificate config files found.


`

That would mean the only thing LibreSign needs is a distro / or library (libc / muslc) check and downloading the according version of java to be fully compatible with Nextcloud-AIO

P.S.: Current version in libresign is OpenJDK21U-jre_x64*****_21.0.2_13 or openjdk version "21.0.2" 2024-01-16 LTS (The alpine aquivalent is available: https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.2_13.tar.gz - Or look in the web overview of releases for Linux and Alpine Linux respectivley: https://adoptium.net/de/temurin/releases/)

neocult-de commented 5 months ago

For everyone who would like to get LibreSign in Nextcloud-AIO working in the meantime:

Install LibreSign as usual by downloading the app and then all binaries in the administration interface under Libre Sign OR run after app installation: sudo docker exec --user www-data -it nextcloud-aio-nextcloud php occ libresign:install --all

Then go to the "java path" by entering the docker container, download the alpine linux release and replace the old one.

Commands step by step for current version (Consider your own NCDATA path and your appdata ID in the folder name!!) sudo docker exec --user www-data -it nextcloud-aio-nextcloud bash

cd /mnt/ncdata/appdata_APPDATAID/libresign/java

rm -R jdk-21.0.2+13-jre

wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.2_13.tar.gz

tar -xf OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.2_13.tar.gz

If you want to test the java binary running correctly run it with the --version flag jdk-21.0.2+13-jre/bin/java --version

The return output should be along the lines of: openjdk 21.0.2 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)

*Directly going to your NCDATA volume or path on the host system works as well, but you can´t test the java then.

Then go back to the LibreSign Options in your nextcloud and see if everything is checked in Green. If you haven´t setup SSL and certificate yet, you should have at least java, pdftk, jsignpdf on "Success". LibreSign should work from here for your installation and the binaries are in a persistent area.


For future updates of the java binaries by LibreSign look for the according version on https://adoptium.net/de/temurin/releases/ and get the aquivalent release for "alpine linux x64". Follow the guide, but adjust the version numbers!

vitormattos commented 5 months ago

Excellent!

Could you provide the output of the follow command?

php -r "var_dump(shell_exec('cat /etc/*-release'));"
neocult-de commented 5 months ago

Running it in the nextcloud-aio-nextcloud container reveals the following currently:

string(195) "3.19.1 NAME="Alpine Linux" ID=alpine VERSION_ID=3.19.1 PRETTY_NAME="Alpine Linux v3.19" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" "

vitormattos commented 5 months ago

Good! Then, I will use this to check if is Alpine and download the specific java package to Alpine. Thanks a lot by your contribution!

vitormattos commented 5 months ago

Could you test the newest release?

vitormattos commented 5 months ago

Closing this issue as solved.

If this issue persists, don't hesitate to open a new issue making reference to this.

[!NOTE]

If you like this app, don't hesitate to help us

Ways to help this project:

neocult-de commented 5 months ago

It works on Nextcloud-AIO stable (Nextcloud 28.0.5) that LibreSign 8.0.2 is correctly backported. A uninstall --all and reinstall via the web interface and via command line both works. A reinstallation of java by itself as well.

It works as well on Nextcloud-AIO with manual update to Nextcloud 29.0.0 and with LibreSign 9.0.2 in the same way.

Both were directly installed with the release from the App Store