Preparing nevisIDM for Use with OpenOffice Templates (adnooprint)
Starting with v2.6, nevisIDM is able to use OpenOffice writer documents as templates to print jobs. In this chapter, the required setup is discussed.
Adnooprint version 1.1.0.0 uses OpenOffice version 3.2 that has a memory leak issue: https://bz.apache.org/ooo/show_bug.cgi?id=41675.
To eliminate this problem with adnooprint version 1.2.x.y or 7.2311.x.y, we upgraded to LibreOffice 5.3.6.1.
Installation of adnooprint and OpenOffice
Installation of adnooprint version 1.1.0.0 and OpenOffice
Install the OpenOffice server-wrapper package adnooprint using the following command:
Linux: rpm -i adnooprint<version>.i486.rpm
If there is no OpenOffice (Writer, version 3.2.0) installation in /opt/ directory, adnooprint can be used as an installer for a minimalized headless OpenOffice server instance.
Download and unpack the following file:
Linux: OOo_3.2.0_LinuxIntel_install_wJRE_en-US.tar.gz
The file is located at the following path: http://archive.apache.org/dist/incubator/ooo/stable/3.2.0/
Install the required OpenOffice components with the following command:
adnooprint install OpenOffice <download dir>
For an OpenOffice installation, the following Linux system requirements are not resolved by the installer:
- libXext.so.6
- libX11.so.6
- libfreetype.so.6
Create and start an instance of adnooprint with the following command:
adnooprint handover RTGROUP=nvbgroup RTOWNER=nvauser
Installation of adnooprint version 1.2.x.y or 7.2311.x.y and LibreOffice
Install the LibreOffice server-wrapper package adnooprint with the following command:
Linux: rpm -i adnooprint<version>.rpm
Install LibreOffice with the following command:
yum install libreoffice-5.3.6.1
- Note: If you are upgrading from adnooprint 1.1.0.0 then you have to remove the already installed OpenOffice packages first (you have to stop any running adnooprint instances beforehand). You can use a command similar to the following:
rpm -e --nodeps $(rpm -qa | grep openoffice)
After installing adnooprint, OPENOFFICE_HOME is set to usr/lib64/libreoffice by default, which is the installation folder of LibreOffice.
- Note: If you are upgrading from adnooprint 1.1.0.0 then you have to adjust manually the OPENOFFICE_HOME configuration in the env.conf file of your adnooprint instance. adnooprint uses the following path to start the LibreOffice service:
$OPENOFFICE_HOME/program/soffice.bin
. Set yourOPENOFFICE_HOME
accordingly.
Create and start an instance of adnooprint with the following command:
adnooprint handover RTGROUP=nvbgroup RTOWNER=nvauser
Configuration of adnooprint
The following command shows every possible command and option for adnooprint, including configuration and diagnostic tools:
adnooprint
The following command opens a text editor:
adnooprint config
In the text editor, you can set the following variables:
RTOWNER=nvauser
RTGROUP=nvbgroup
OPENOFFICE_SERVER_HOST=localhost
OPENOFFICE_SERVER_PORT=8912
Make sure that the host, port and rtowner/rtgroup settings correspond to the nevisIDM configuration. For more information, see Configuration of nevisIDM.
To keep OpenOffice running, the owner-user has to have a home directory, or has to be able to create and write to the directory /tmp/.openoffice.
After saving a configuration file, restart the adnooprint instance with the following command:
adnooprint restart
Configuration of nevisIDM
Use the following command
nevisidm config idm
to set the variables corresponding to the adnooprint settings:
application.modules.printing.host=localhost
application.modules.printing.port=8912
application.modules.printing.printer=
Restart nevisIDM with the following command:
nevisidm restart
If application.modules.printing.printer is not set, the default printer is used, that is, the default printer of the host where the OpenOffice installation resides.
OpenOffice on Kubernetes
On Kubernetes installations, nevisIDM requires a LibreOffice printing service to be available.
Creating a docker image
Prerequisite is to have an image available that provides the LibreOffice printing service in the container registry. Here is an example on how to create one, if it's not already available. Save the following as Dockerfile and startup.sh.
Dockerfile
FROM centos:7
MAINTAINER nevisIDM team
RUN yum -y install \
libreoffice-headless \
libreoffice \
cups \
cups-client \
cups-bsd \
cups-filters \
hpijs \
&& yum clean all
# Add User
RUN useradd -r -G root,users -M print && echo print:print | chpasswd
# Configure cups and nowhere printer
RUN /usr/sbin/cupsd \
&& while [ ! -f /var/run/cupsd.pid ]; do sleep 1; done \
&& cupsctl --remote-admin --remote-any --share-printers
# Patch the default configuration file to only enable encryption if requested
RUN sed -i 's/Port 631/Listen 0.0.0.0:631/' /etc/cups/cupsd.conf && \
echo "ServerAlias *" >> /etc/cups/cupsd.conf && \
echo "DefaultEncryption Never" >> /etc/cups/cupsd.conf
COPY startup.sh startup.sh
RUN chmod 755 startup.sh
EXPOSE 8912 631
CMD ./startup.sh
startup.sh
#!/bin/sh
# Start soffice
/usr/bin/soffice --nologo --nofirststartwizard --headless --norestore --invisible "--accept=socket,host=0.0.0.0,port=8912,tcpNoDelay=1;urp;" &
# Start cups server
/usr/sbin/cupsd -f
fg %1
Then run the following command to create the image:
docker build -t ooprint:1.0 .
It is a CentOS-based image, which uses CUPS, and LibreOffice packages to provide the printing service.
Then push it to the registry used by the Kubernetes cluster:
docker tag ooprint:1.0 <registry>/ooprint:1.0
docker push <registry>/ooprint:1.0
The created image is intended as an example, do not use it in live setups.
Deploying the printing service
Create the necessary Kubernetes resources so the service is available. The following example manifest can be used with previously built image:
ooprint.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ooprint
labels:
app: ooprint
spec:
replicas: 1
selector:
matchLabels:
app: ooprint
template:
metadata:
labels:
app: ooprint
spec:
volumes:
- name: ooprint-config
configMap:
name: ooprint-config
defaultMode: 0750
containers:
- name: ooprint
image: <container_registry>/ooprint:1.0
ports:
- containerPort: 631
name: print1
- containerPort: 8912
name: print2
volumeMounts:
- name: ooprint-config
mountPath: /etc/cups/printers.conf
subPath: printers.conf
---
apiVersion: v1
kind: Service
metadata:
labels:
app: ooprint
name: ooprint
spec:
ports:
- name: print1
port: 631
protocol: TCP
targetPort: 631
- name: print2
port: 8912
protocol: TCP
targetPort: 8912
selector:
app: ooprint
sessionAffinity: None
type: ClusterIP
---
apiVersion: v1
data:
printers.conf: |
<Printer nowhere>
UUID urn:uuid:1eade1e7-6a28-36ac-7368-abb0d663282e
Info nowhere
DeviceURI file:/dev/null
State Idle
StateTime 1628593165
Type 4
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
kind: ConfigMap
metadata:
name: ooprint-config
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: ooprint
name: ooprint-storage
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: <storage_class>
First edit the provided manifest:
- Replace
<container_registry>
with the one used in the previous step. - Replace
<storage_class>
with a KubernetesStorageClass
thats available on the Kubernetes cluster, and supportsReadWriteMany
access mode. As an example on Azureazurefile
, and on OpenShift/Rancher aStorageClass
such aslonghorn
can be used.
Then run the following command, <namespace>
is the namespace where nevisIDM is deployed.
kubectl apply -f ooprint.yaml -n <namespace>
This creates the following resources:
- ooprint Deployment and Service used to access the printing service.
- ooprint-config ConfigMap which contains an example configuration for the printing service.
- ooprint-storage PersistentVolumeClaim used by nevisIDM to store the generated PDFs.
nevisAdmin4 configuration
Use a Generic nevisIDM Instance Setting pattern and configure the following properties:
application.modules.printing.host=ooprint
application.modules.printing.port=8912
application.modules.printing.dir.target=/openoffice/pdfstorage/
In the inventory specify a custom-volume for the nevisIDM service which uses the previously created PersistentVolumeClaim
:
services:
- idm:
kubernetes:
replicas: 1
custom-volumes:
- volumeMount:
mountPath: /openoffice/pdfstorage
name: ooprint-storage
volume:
name: ooprint-storage
persistentVolumeClaim:
claimName: ooprint-storage