#!/bin/bash
mkdir /opt/office/ && cd /opt/office/
wget https://download.alblog.cn/produce/LibreOffice/LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz
wget https://download.alblog.cn/produce/LibreOffice/LibreOffice_7.1.4_Linux_x86-64_rpm_langpack_zh-CN.tar.gz
wget https://download.alblog.cn/produce/LibreOffice/LibreOffice_7.1.4_Linux_x86-64_rpm_sdk.tar.gz
wget https://download.alblog.cn/produce/LibreOffice/fonts.zip
wget https://download.alblog.cn/produce/LibreOffice/demo.docx
tar -xvf LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz && tar -xvf LibreOffice_7.1.4_Linux_x86-64_rpm_langpack_zh-CN.tar.gz && tar -xvf LibreOffice_7.1.4_Linux_x86-64_rpm_sdk.tar.gz
yum localinstall /opt/office/LibreOffice_7.1.4.2_Linux_x86-64_rpm/RPMS/*.rpm -y
yum localinstall /opt/office/LibreOffice_7.1.4.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS/*.rpm -y
yum localinstall /opt/office/LibreOffice_7.1.4.2_Linux_x86-64_rpm_sdk/RPMS/*.rpm -y
yum install ibus fontconfig ttmkfdir unzip -y
mkdir /usr/share/fonts/chinese
unzip fonts.zip
mv *.ttc /usr/share/fonts/chinese && mv *.ttf /usr/share/fonts/chinese
chmod -R 644 /usr/share/fonts/chinese
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
sed -i '24a <dir>/usr/share/fonts/chinese</dir>' /etc/fonts/fonts.conf
fc-cache -fv
/usr/bin/libreoffice7.1 --headless --invisible --convert-to pdf /opt/office/demo.docx --outdir /opt/office/