Helper Scripts

I replaced OnlyOffice with Collabora in my lab. I was able to extend their WOPI example to produce a Minimum Viable Product. As it stands now, the software is feature complete for my use case. From there, I mount my data to my NFS storage and sync that folder with Dropbox. This lets me use a filebrowser for my currently in work documents. I can then access those contents from my reMarkable using the Dropbox integration. Unfortunately, the reMarkable reads PDFs and not docx. To combat this problem, I have created a nightly script to convert the files to PDF. This is easily packaged into a container and run as a kubernetes cronjob. Since my NFS storage is also a persistent volume claim, I can reuse the same ReadWriteMany mount for both my Waffle WOPI server and the wrapper script to libreoffice.

The Script

#!/usr/bin/env bash
set -euo pipefail

# Defaults: mounted /data directory
input_dir="${1:-/data}"
output_dir="${2:-$input_dir}"

# Ensure output directory exists
mkdir -p "$output_dir"

echo "Converting DOCX files from: $input_dir"
echo "Saving PDFs to: $output_dir"

# Convert all .docx → .pdf
shopt -s nullglob
files=("$input_dir"/*.docx)

if [ ${#files[@]} -eq 0 ]; then
  echo "No .docx files found in $input_dir"
  exit 0
fi

soffice --headless --convert-to pdf:writer_pdf_Export --outdir "$output_dir" "${files[@]}"
echo "Conversion complete."

The Dockerfile

FROM debian:bullseye-slim

# Install LibreOffice (soffice)
RUN apt-get update && apt-get install -y libreoffice && rm -rf /var/lib/apt/lists/*

# Working directory for mounted data
WORKDIR /data

# Copy script
COPY convert.sh /usr/local/bin/convert.sh
RUN chmod +x /usr/local/bin/convert.sh

# Default entrypoint
ENTRYPOINT ["/usr/local/bin/convert.sh"]

The Cronjob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: remarkable-dropbox-helper
  namespace: collabora
spec:
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 1
  jobTemplate:
    metadata:
      name: remarkable-dropbox-helper
    spec:
      template:
        spec:
          containers:
          - image: docker-domain/remarkable-dropbox-helper:latest
            command: ["convert.sh", "/data/editable"]
            imagePullPolicy: Always
            name: remarkable-dropbox-helper
            volumeMounts:
            - mountPath: /data
              name: remarkable-dropbox-helper-pvc
          dnsPolicy: ClusterFirst
          imagePullSecrets:
          - name: regsecret
          restartPolicy: OnFailure
          terminationGracePeriodSeconds: 30
          volumes:
          - name: remarkable-dropbox-helper-pvc
            persistentVolumeClaim:
              claimName: middleware-files-pvc
  schedule: '@daily'
  timeZone: Europe/Helsinki
  successfulJobsHistoryLimit: 1
  suspend: false