echo "### 安装 wget unzip"
yum install wget unzip -y
echo "### 移除旧的 oo"
docker stop oo -t 0
docker rm oo
docker rmi onlyoffice/documentserver
rm -rf /home/onlyoffice/
echo "### 创建 oo 目录映射"
mkdir -p /home/onlyoffice/logs && cd /home/onlyoffice/ && mkdir data lib db && pwd && ls
docker info
echo "### 拉取镜像"
docker pull onlyoffice/documentserver
docker images
echo "### 安装 oo"
docker run -i -t -d -p 9980:80 --restart=always --name=oo \
-v /home/onlyoffice/logs:/var/log/onlyoffice \
-v /home/onlyoffice/data:/var/www/onlyoffice/Data \
-v /home/onlyoffice/lib:/var/lib/onlyoffice \
-v /home/onlyoffice/db:/var/lib/postgresql onlyoffice/documentserver
echo "### 创建字体存储临时目录"
cd /home/onlyoffice/logs/ && mkdir tmp && cd tmp
echo "### 下载字体包"
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/archive/refs/heads/master.zip
echo "### 字体包解压"
unzip master.zip && mv Docker-Only-Office-Chinese-font-master oofont
echo "### 设高最大文件限制为 1G"
docker exec -it oo /bin/bash -c "sed -i /etc/onlyoffice/documentserver/default.json -e 's/104857600/1048576000/g'"
echo "### 拷贝字体"
docker exec -it oo /bin/bash -c "cp -r /var/log/onlyoffice/tmp/oofont/winfont /usr/share/fonts/"
echo "### 等待 15s 后更新字体"
sleep 15s
docker exec -it oo /bin/bash -c "fc-cache -f -v && /usr/bin/documentserver-generate-allfonts.sh"
echo "### 重启服务"
docker restart oo -t 0
echo "Done , installed successfully"