From e755786109213693b8e4f680e2110f7831937f9a Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sun, 22 Jun 2025 18:15:27 -0300 Subject: [PATCH] feat: integrate JMAP client and refactor file handling - Added `jmap-client` dependency to Cargo.toml for JMAP email functionality. - Created a new `email` service to handle email listing via JMAP. - Refactored file upload and listing functionality into a dedicated `file` service. - Introduced `AppState` struct to manage shared application state, including MinIO client and configuration. - Updated main application to initialize and use the new services. --- src/scripts/set-size-5GB.sh | 41 ++------- .../tenants/default/doc-editor/doc-editor.sh | 92 +++++++++++++++++++ 2 files changed, 101 insertions(+), 32 deletions(-) create mode 100644 src/templates/opt/gbo/tenants/default/doc-editor/doc-editor.sh diff --git a/src/scripts/set-size-5GB.sh b/src/scripts/set-size-5GB.sh index b5b23d5..7d92aab 100644 --- a/src/scripts/set-size-5GB.sh +++ b/src/scripts/set-size-5GB.sh @@ -1,33 +1,10 @@ -for container in $(lxc list --format csv -c n); do - echo "Processing $container..." - - # Stop container safely - lxc stop "$container" +export container="pragmatismo-doc-editor" +lxc stop "$container" - # Set new 5GB limit (works for most drivers) - if ! lxc config device override "$container" root size=5GB; then - echo "Failed to set config, trying alternative method..." - lxc config device set "$container" root size=5GB - fi - - # Start container - lxc start "$container" - - # Find root device inside container - ROOT_DEV=$(lxc exec "$container" -- df / --output=source | tail -1) - - # Resize filesystem (with proper error handling) - if lxc exec "$container" -- which resize2fs >/dev/null 2>&1; then - echo "Resizing filesystem for $container..." - if [[ "$ROOT_DEV" == /dev/* ]]; then - lxc exec "$container" -- growpart "$(dirname "$ROOT_DEV")" "$(basename "$ROOT_DEV")" - lxc exec "$container" -- resize2fs "$ROOT_DEV" - else - echo "Non-standard root device $ROOT_DEV - manual resize needed" - fi - else - echo "resize2fs not available in $container - install it first" - fi - - echo "Completed $container" -done \ No newline at end of file +lxc config device override "$container" root size=5GB +lxc config device set "$container" root size=5GB +lxc start "$container" +ROOT_DEV=$(lxc exec "$container" -- df / --output=source | tail -1) + +lxc exec "$container" -- growpart "$(dirname "$ROOT_DEV")" "$(basename "$ROOT_DEV")" +lxc exec "$container" -- resize2fs "$ROOT_DEV" \ No newline at end of file diff --git a/src/templates/opt/gbo/tenants/default/doc-editor/doc-editor.sh b/src/templates/opt/gbo/tenants/default/doc-editor/doc-editor.sh new file mode 100644 index 0000000..44319a0 --- /dev/null +++ b/src/templates/opt/gbo/tenants/default/doc-editor/doc-editor.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +HOST_BASE="/opt/gbo/tenants/$PARAM_TENANT/doc-editor" +HOST_DATA="$HOST_BASE/data" +HOST_CONF="$HOST_BASE/conf" +HOST_LOGS="$HOST_BASE/logs" + +sudo mkdir -p "$HOST_DATA" "$HOST_CONF" "$HOST_LOGS" +sudo chmod -R 750 "$HOST_BASE" + +lxc launch images:debian/12 "${PARAM_TENANT}-doc-editor" \ + -c security.privileged=true \ + -c limits.cpu=2 \ + -c limits.memory=4096MB \ + +sleep 10 + +lxc config device add "$PARAM_TENANT"-doc-editor doceditordata disk source="$HOST_DATA" path=/opt/gbo/data +lxc config device add "$PARAM_TENANT"-doc-editor doceditorconf disk source="$HOST_CONF" path=/opt/gbo/conf +lxc config device add "$PARAM_TENANT"-doc-editor doceditorlogs disk source="$HOST_LOGS" path=/opt/gbo/logs + + +lxc exec "$PARAM_TENANT"-doc-editor -- bash -c " +sudo apt install -y cloud-guest-utils e2fsprogs + +apt install -y make g++ build-essential +apt install -y openjdk-17-jdk ant +apt install -y sudo systemd wget zip procps ccache +apt install -y automake bison flex git gperf graphviz junit4 libtool m4 nasm +apt install -y libcairo2-dev libjpeg-dev libegl1-mesa-dev libfontconfig1-dev \ + libgl1-mesa-dev libgif-dev libgtk-3-dev librsvg2-dev libpango1.0-dev +apt install -y libcap-dev libcap2-bin libkrb5-dev libpcap0.8-dev openssl libssl-dev +apt install -y libxcb-dev libx11-xcb-dev libxkbcommon-x11-dev libxtst-dev \ + libxrender-dev libxslt1-dev libxt-dev xsltproc +apt install -y libcunit1-dev libcppunit-dev libpam0g-dev libcups2-dev libzstd-dev uuid-runtime +apt install -y python3-dev python3-lxml python3-pip python3-polib +apt install -y nodejs npm +apt install -y libpoco-dev libpococrypto80 +apt install -y libreoffice-dev + + +mkdir -p /opt/lo && cd /opt/lo +wget https://github.com/CollaboraOnline/online/releases/download/for-code-assets/core-co-24.04-assets.tar.gz +tar xf core-co-24.04-assets.tar.gz && rm core-co-24.04-assets.tar.gz + +useradd cool -G sudo +mkdir -p /opt/cool && chown cool:cool /opt/cool +cd /opt/cool +sudo -Hu cool git clone https://github.com/CollaboraOnline/online.git +cd online && sudo -Hu cool ./autogen.sh + +export CPPFLAGS=-I/opt/lo/include +export LDFLAGS=-L/opt/lo/instdir/program +./configure --with-lokit-path=/opt/lo --with-lo-path=/opt/lo/instdir --with-poco-includes=/usr/local/include --with-poco-libs=/usr/local/lib + +sudo -Hu cool make -j$(nproc) + +make install +mkdir -p /etc/coolwsd /usr/local/var/cache/coolwsd +chown cool:cool /usr/local/var/cache/coolwsd +admin_pwd=$(openssl rand -hex 6) + +cat < /lib/systemd/system/coolwsd.service +[Unit] +Description=Collabora Online WebSocket Daemon +After=network.target + +[Service] +ExecStart=/opt/cool/online/coolwsd --o:sys_template_path=/opt/cool/online/systemplate \ +--o:lo_template_path=/opt/lo/instdir --o:child_root_path=/opt/cool/online/jails \ +--o:admin_console.username=admin --o:admin_console.password=$DOC_EDITOR_ADMIN_PWD \ +--o:ssl.enable=false +User=cool + +[Install] +WantedBy=multi-user.target +EOT + +systemctl daemon-reload +systemctl enable coolwsd.service +systemctl start coolwsd.service +" + +echo "Installation complete!" +echo "Admin password: $admin_pwd" +echo "Access at: https://localhost:9980" + + +lxc config device remove "$PARAM_TENANT"-doc-editor doc-proxy 2>/dev/null || true +lxc config device add "$PARAM_TENANT"-doc-editor doc-proxy proxy \ + listen=tcp:0.0.0.0:"$PARAM_DOC_PORT" \ + connect=tcp:127.0.0.1:9980 \ No newline at end of file