文件预览-kkFileView离线安装脚本

1、离线安装脚本

#!/bin/bash

basicInstallPackageDir=/root/resource/
basicInstallDir=/data/mysql/
echo "下载地址 https://kkfileview.keking.cn/LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz"
echo "下载地址 https://kkfileview.keking.cn/kkFileView-4.0.0.tar.gz"
echo "${basicInstallPackageDir}kkFileView安装资源/LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz [文件浏览-LibreOffice]"
echo "${basicInstallPackageDir}kkFileView安装资源/kkFileView-4.0.0.tar.gz [文件浏览]"
echo "${basicInstallPackageDir}kkFileView安装资源/rpms.tar [文件浏览-依赖rpm文件]"
echo "${basicInstallPackageDir}kkFileView安装资源/zhFonts.tar [文件浏览-中文字体]"

echo "mkdir -p /data"
echo "groupadd mysql"
echo "useradd -d /data/mysql -g mysql -m mysql"
echo "passwd mysql"

old_pwd=$(pwd)
echo old_pwd="${old_pwd}"
cd "$(dirname "$0")" || return

echo "开始kkFileView安装"
rm -rf ${basicInstallDir}kkFileView-4.0.0
echo "卸载Libreoffice"
yum erase -y libreoffice\*
tar -zxf ${basicInstallPackageDir}kkFileView安装资源/LibreOffice_7.1.4_Linux_x86-64_rpm.tar.gz -C "${basicInstallDir}"
tar -xf ${basicInstallPackageDir}kkFileView安装资源/rpms.tar -C "${basicInstallDir}"
echo "安装libXinerama,解决依赖问题"
cd ${basicInstallDir}rpms || return
echo "解决:libXinerama.so.1()(64bit) is needed by libobasis7.1-core-7.1.4.2-2.x86_64"
rpm -ivh libXinerama-1.1.3-2.1.el7.x86_64.rpm --nodeps
cd ${basicInstallDir}LibreOffice_7.1.4.2_Linux_x86-64_rpm/RPMS || return
echo "继续执行,成功 rpm -ivh ./*.rpm"
rpm -ivh libobasis7.1-base-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-onlineupdate-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-calc-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-ooofonts-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-core-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-ooolinguistic-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-draw-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-postgresql-sdbc-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-en-US-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-python-script-provider-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-beanshell-script-provider-7.1.4.2-2.x86_64.rpm
rpm -ivh libobasis7.1-pyuno-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-javascript-script-provider-7.1.4.2-2.x86_64.rpm
rpm -ivh libobasis7.1-writer-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-mediawiki-publisher-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-xsltfilter-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-nlpsolver-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-pdf-import-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-base-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-extension-report-builder-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-calc-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-firebird-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-dict-en-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-gnome-integration-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-dict-es-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-graphicfilter-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-dict-fr-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-images-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-draw-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-impress-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-en-US-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-kde-integration-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-freedesktop-menus-7.1.4-2.noarch.rpm --nodeps
rpm -ivh libobasis7.1-librelogo-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-impress-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-libreofficekit-data-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-math-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-math-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-ure-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libobasis7.1-ogltrans-7.1.4.2-2.x86_64.rpm --nodeps
rpm -ivh libreoffice7.1-writer-7.1.4.2-2.x86_64.rpm --nodeps
echo "打印Libreoffice安装路径"
whereis libreoffice7.1
cd ${basicInstallDir}rpms || return
echo "安装libreoffice7.1依赖组件:libreoffice7.1 --headless --accept=\"socket,host=0.0.0.0,port=8100;urp;\" --nofirststartwizard"
echo "解决:/opt/libreoffice7.1/program/oosplash: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory"
rpm -ivh libX11-1.6.7-2.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/oosplash: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory"
rpm -ivh libXext-1.3.3-3.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/oosplash: error while loading shared libraries: libxcb.so.1: cannot open shared object file: No such file or directory"
rpm -ivh libxcb-1.13-1.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/oosplash: error while loading shared libraries: libXau.so.6: cannot open shared object file: No such file or directory"
rpm -ivh libXau-1.0.8-2.1.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libcairo.so.2: cannot open shared object file: No such file or directory"
rpm -ivh cairo-1.15.12-4.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory"
rpm -ivh fontconfig-2.13.0-4.3.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory"
rpm -ivh libSM-1.2.2-2.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libICE.so.6: cannot open shared object file: No such file or directory"
rpm -ivh libICE-1.0.9-9.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libpixman-1.so.0: cannot open shared object file: No such file or directory"
rpm -ivh pixman-0.34.0-1.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libEGL.so.1: cannot open shared object file: No such file or directory"
rpm -ivh libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory"
rpm -ivh libXrender-0.9.10-1.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory"
rpm -ivh libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm --nodeps
echo "解决:/opt/libreoffice7.1/program/soffice.bin: error while loading shared libraries: libGLdispatch.so.0: cannot open shared object file: No such file or directory"
rpm -ivh libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm --nodeps
echo "安装好依赖后测试Office组件: libreoffice7.1 --headless --accept=\"socket,host=0.0.0.0,port=8100;urp;\" --nofirststartwizard"
nohup libreoffice7.1 --headless --accept="socket,host=0.0.0.0,port=8100;urp;" --nofirststartwizard &
echo "netstat -nalp|grep 8100"
kill -9 "$(pgrep soffice.bin | grep -v grep)"
echo "开始安装中文字体"
echo "查询mkfontscale的依赖:yumdownloader --resolve --destdir=/root/font_rpm mkfontscale"
rpm -ivh xorg-x11-font-utils-7.5-21.el7.x86_64.rpm --nodeps
rpm -ivh mkfontscale-1.2.1-3.el9.x86_64.rpm --nodeps
rpm -ivh libfontenc-1.1.3-3.el7.x86_64.rpm --nodeps
tar -xvf zhFonts.tar
mkdir -p /usr/share/fonts
mv zhFonts /usr/share/fonts/
echo "安装字体"
mkfontscale
echo "查看安装的中文字体"
fc-list :lang=zh
echo "生成字体目录"
mkfontdir
echo "刷新缓存"
fc-cache
echo "开始安装kkFileView"
tar -zxf ${basicInstallPackageDir}kkFileView安装资源/kkFileView-4.0.0.tar.gz -C ${basicInstallDir}
echo "启动进程"
${basicInstallDir}kkFileView-4.0.0/bin/startup.sh
sleep 5
echo "netstat -nalp | grep 8012"
netstat -nalp | grep 8012
kill -9 "$(pgrep kkFileView | grep -v grep)"
chown -R mysql:mysql ${basicInstallDir}kkFileView-4.0.0
echo "其他相关操作如下:"
echo -e "\t启动进程:${basicInstallDir}kkFileView-4.0.0/bin/startup.sh"
echo -e "\t停止进程:${basicInstallDir}kkFileView-4.0.0/bin/shutdown.sh"
echo -e "\t查看日志:${basicInstallDir}kkFileView-4.0.0/bin/showlog.sh"
echo -e "\t检查Office是否启动:ps -ef|grep /opt/libreoffice7.1/program/soffice.bin | grep -v grep"
echo -e "\t如果安装失败删除安装目录${basicInstallDir}kkFileView-4.0.0,重新:tar -zxf kkFileView-4.0.0.tar.gz -C ${basicInstallDir}"
echo "结束kkFileView安装"

cd "${old_pwd}" || return

2、脚本优化
bin/showlog.sh

#!/bin/bash
old_path=`pwd`
echo 当前路径:${old_path}
KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")";pwd)
echo 执行脚本路径:${KKFILEVIEW_BIN_FOLDER}
cd ${KKFILEVIEW_BIN_FOLDER}
tail -fn 300 ../log/kkFileView.log
cd ${old_path}

bin/shutdown.sh

#!/bin/bash

officelist=`ps -ef|grep /opt/libreoffice7.1/program/soffice.bin | grep -v grep|awk '{print $2}'`
for i in $officelist;
do
    echo "结束office进程:$i";
    kill -9 $i
done

list=`ps -ef|grep kkFileView|grep -v grep|awk '{print $2}'`
for i in $list;
do
    echo "结束进程:$i";
    kill -9 $i
done
#kill -15 `ps -ef|grep kkFileView|awk 'NR==1{print $2}'`

3、离线资源下载
链接:https://pan.baidu.com/s/1k4zKw3UVCHFfsG66QbsRpQ
提取码:s6je

你可能感兴趣的:(kkFileView,linux,服务器,bash)