| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #!/usr/bin/env bash
- set -euo pipefail
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
- RUNTIME_DIR="${PROJECT_ROOT}/local-run/runtime/full-local"
- WEBAPP_DIR="${RUNTIME_DIR}/webapp"
- if [[ ! -d "${WEBAPP_DIR}" ]]; then
- echo "运行副本不存在,请先启动完整后台:${PROJECT_ROOT}/local-run/bin/start-full.sh" >&2
- exit 1
- fi
- "${SCRIPT_DIR}/compile-hxcs-deploy-classes.sh"
- rsync -a --delete "${PROJECT_ROOT}/WebRoot/" "${WEBAPP_DIR}/"
- echo "已同步 WebRoot -> ${WEBAPP_DIR}"
- "${SCRIPT_DIR}/apply-local-runtime-config.sh"
- if [[ "$(uname -s)" == "Darwin" ]]; then
- libreoffice_path="${ZQ_LIBREOFFICE_MAC_PATH:-}"
- if [[ -z "${libreoffice_path}" ]]; then
- for candidate in \
- "/Applications/LibreOffice.app/Contents/MacOS/soffice" \
- "$(command -v soffice 2>/dev/null || true)" \
- "$(command -v libreoffice 2>/dev/null || true)"; do
- if [[ -n "${candidate}" && -x "${candidate}" ]]; then
- libreoffice_path="${candidate}"
- break
- fi
- done
- fi
- if [[ -n "${libreoffice_path}" && -x "${libreoffice_path}" ]]; then
- /usr/bin/python3 - "${WEBAPP_DIR}/WEB-INF/application.xml" "${libreoffice_path}" <<'PY'
- import re
- import sys
- from pathlib import Path
- config = Path(sys.argv[1])
- path = sys.argv[2]
- content = config.read_text(encoding="utf-8")
- content, count = re.subn(
- r"<libreOfficeMacOrMacOSXPath>.*?</libreOfficeMacOrMacOSXPath>",
- f"<libreOfficeMacOrMacOSXPath>{path}</libreOfficeMacOrMacOSXPath>",
- content,
- count=1,
- )
- if count:
- config.write_text(content, encoding="utf-8")
- PY
- echo "本地 LibreOffice 路径:${libreoffice_path}"
- else
- echo "提醒:未找到可执行的 LibreOffice,Word 导入将回退 Mammoth 基础格式。"
- fi
- fi
|