startup.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. #
  3. #
  4. #############################
  5. # First_Author: 凯京科技
  6. # Second_Author: sanxi
  7. # Version: 1.1
  8. # Date: 2021/09/17
  9. # Description: v1.1:修改进程启动机制为pid形式。
  10. #############################
  11. #
  12. DIR_HOME=("/opt/openoffice.org3" "/opt/libreoffice" "/opt/libreoffice6.1" "/opt/libreoffice7.0" "/opt/libreoffice7.1" "/opt/libreoffice7.2" "/opt/libreoffice7.3" "/opt/libreoffice7.4" "/opt/openoffice4" "/usr/lib/openoffice" "/usr/lib/libreoffice")
  13. FLAG=
  14. OFFICE_HOME=
  15. KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")" || exit 1 ;pwd)
  16. PID_FILE_NAME="kkFileView.pid"
  17. PID_FILE="${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
  18. export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER
  19. #
  20. ## 如pid文件不存在则自动创建
  21. if [ ! -f ${PID_FILE_NAME} ]; then
  22. touch "${KKFILEVIEW_BIN_FOLDER}/${PID_FILE_NAME}"
  23. fi
  24. ## 判断当前是否有进程处于运行状态
  25. if [ -s "${PID_FILE}" ]; then
  26. PID=$(cat "${PID_FILE}")
  27. echo "进程已处于运行状态,进程号为:${PID}"
  28. exit 1
  29. else
  30. cd "$KKFILEVIEW_BIN_FOLDER" || exit 1
  31. echo "Using KKFILEVIEW_BIN_FOLDER $KKFILEVIEW_BIN_FOLDER"
  32. grep 'office\.home' ../config/application.properties | grep '!^#'
  33. if [ $? -eq 0 ]; then
  34. echo "Using customized office.home"
  35. else
  36. for i in ${DIR_HOME[@]}
  37. do
  38. if [ -f "$i/program/soffice.bin" ]; then
  39. FLAG=true
  40. OFFICE_HOME=${i}
  41. break
  42. fi
  43. done
  44. if [ ! -n "${FLAG}" ]; then
  45. echo "Installing LibreOffice"
  46. sh ./install.sh
  47. else
  48. echo "Detected office component has been installed in $OFFICE_HOME"
  49. fi
  50. fi
  51. ## 启动kkFileView
  52. echo "Starting kkFileView..."
  53. nohup java -Dfile.encoding=UTF-8 -Dspring.config.location=../config/application.properties -jar kkFileView-4.3.0-SNAPSHOT.jar > ../log/kkFileView.log 2>&1 &
  54. echo "Please execute ./showlog.sh to check log for more information"
  55. echo "You can get help in our official home site: https://kkview.cn"
  56. echo "If you need further help, please join our kk opensource community: https://t.zsxq.com/09ZHSXbsQ"
  57. echo "If this project is helpful to you, please star it on https://gitee.com/kekingcn/file-online-preview/stargazers"
  58. PROCESS=$(ps -ef | grep kkFileView | awk 'NR==1{print $2}')
  59. # 启动成功后将进程号写入pid文件
  60. echo "$PROCESS" > "$PID_FILE"
  61. fi