|
| 1 | + |
| 2 | +### 安装插件 |
| 3 | + |
| 4 | +参考 [商业插件的安装与升级](/welcome/getting-started/plugin) |
| 5 | + |
| 6 | +### 安装 LibreOffice(可选) |
| 7 | + |
| 8 | +生成 PDF 必须安装 LibreOffice,[请前往官网下载]( |
| 9 | +https://www.libreoffice.org/download/download-libreoffice)。Docker 版本,可以直接在 `./storage/scripts` 目录下,编写一段脚本。 |
| 10 | + |
| 11 | +```bash |
| 12 | +mkdir ./storage/scripts |
| 13 | +vim install-libreoffice.sh |
| 14 | +``` |
| 15 | + |
| 16 | +`install-libreoffice.sh` 的内容如下: |
| 17 | + |
| 18 | +```sh |
| 19 | +#!/bin/bash |
| 20 | + |
| 21 | +# Define variables |
| 22 | +INSTALL_DIR="/opt/libreoffice24.8" |
| 23 | +DOWNLOAD_URL="https://download.documentfoundation.org/libreoffice/stable/24.8.4/deb/x86_64/LibreOffice_24.8.4_Linux_x86-64_deb.tar.gz" |
| 24 | + |
| 25 | +# Check if LibreOffice is already installed |
| 26 | +if [ -d "$INSTALL_DIR" ]; then |
| 27 | + echo "LibreOffice is already installed, skipping installation." |
| 28 | + exit 0 |
| 29 | +fi |
| 30 | + |
| 31 | +# Update APT sources |
| 32 | +tee /etc/apt/sources.list > /dev/null <<EOF |
| 33 | +deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free |
| 34 | +deb-src http://mirrors.aliyun.com/debian/ bookworm main contrib non-free |
| 35 | +deb http://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free |
| 36 | +deb-src http://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free |
| 37 | +deb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free |
| 38 | +deb-src http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free |
| 39 | +deb http://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free |
| 40 | +deb-src http://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free |
| 41 | +EOF |
| 42 | + |
| 43 | +# Update APT and install dependencies |
| 44 | +apt-get update |
| 45 | + |
| 46 | +apt-get install -y \ |
| 47 | + libfreetype6 \ |
| 48 | + fontconfig \ |
| 49 | + libgssapi-krb5-2 \ |
| 50 | + libxml2 \ |
| 51 | + libnss3 \ |
| 52 | + libdbus-1-3 \ |
| 53 | + libcairo2 \ |
| 54 | + libxslt1.1 \ |
| 55 | + libglib2.0-0 \ |
| 56 | + libcups2 \ |
| 57 | + libx11-xcb1 \ |
| 58 | + ttf-mscorefonts-installer \ |
| 59 | + fonts-wqy-zenhei |
| 60 | + |
| 61 | +rm -rf /var/lib/apt/lists/* |
| 62 | + |
| 63 | +cd /app/nocobase/storage/scripts |
| 64 | + |
| 65 | +# Download and install LibreOffice if not already present |
| 66 | +if [ ! -d "./libreoffice" ]; then |
| 67 | + rm -rf libreoffice.tar.gz |
| 68 | + wget --no-check-certificate -O libreoffice.tar.gz $DOWNLOAD_URL |
| 69 | + if [ $? -ne 0 ]; then |
| 70 | + echo "Failed to download LibreOffice." |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | + rm -rf libreoffice && mkdir libreoffice |
| 74 | + tar -zxvf libreoffice.tar.gz -C ./libreoffice --strip-components=1 |
| 75 | + if [ $? -ne 0 ]; then |
| 76 | + echo "Failed to extract LibreOffice." |
| 77 | + exit 1 |
| 78 | + fi |
| 79 | +fi |
| 80 | + |
| 81 | +# Install LibreOffice |
| 82 | +dpkg -i libreoffice/DEBS/*.deb |
| 83 | + |
| 84 | +ln -s /opt/libreoffice24.8/program/soffice.bin /usr/bin/libreoffice |
| 85 | +libreoffice --version |
| 86 | + |
| 87 | +if [ $? -ne 0 ]; then |
| 88 | + echo "Failed to install LibreOffice." |
| 89 | + exit 1 |
| 90 | +fi |
| 91 | + |
| 92 | +echo "LibreOffice installation completed successfully." |
| 93 | +``` |
| 94 | + |
| 95 | +重启 app 容器 |
| 96 | + |
| 97 | +```bash |
| 98 | +docker compose restart app |
| 99 | +# 查看日志 |
| 100 | +docker compose logs app |
| 101 | +``` |
| 102 | + |
| 103 | +检测是否安装成功 |
| 104 | + |
| 105 | +```bash |
| 106 | +$ docker compose exec app bash -c "libreoffice --version" |
| 107 | + |
| 108 | +LibreOffice 24.8.4.2 bb3cfa12c7b1bf994ecc5649a80400d06cd71002 |
| 109 | +``` |
0 commit comments