You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.2 KiB

2 years ago
13 hours ago
10 months ago
2 months ago
3 weeks ago
2 years ago
9 months ago
2 years ago
11 months ago
2 years ago
4 months ago
2 years ago
4 months ago
2 years ago
  1. #!/bin/bash
  2. Linux_Version="11.3.0"
  3. Windows_Version="8.2.2"
  4. Aapanel_Version="7.0.25"
  5. Btm_Version="2.3.3"
  6. FILES=(
  7. public/install/src/panel6.zip
  8. public/install/update/LinuxPanel-${Linux_Version}.zip
  9. public/install/install_panel.sh
  10. public/install/update_panel.sh
  11. public/install/update6.sh
  12. public/win/install/panel_update.py
  13. public/win/panel/data/setup.py
  14. public/install/src/bt-monitor-${Btm_Version}.zip
  15. public/install/install_btmonitor.sh
  16. public/install/update_btmonitor.sh
  17. public/install/src/panel_7_en.zip
  18. public/install/update/LinuxPanel_EN-${Aapanel_Version}.zip
  19. public/install/install_7.0_en.sh
  20. public/install/update_7.x_en.sh
  21. )
  22. PL_FILE="public/install/update/LinuxPanel-${Linux_Version}.pl"
  23. DIR=$1
  24. SITEURL=$2
  25. if [ ! -d "$DIR" ]; then
  26. echo "网站目录不存在"
  27. exit 1
  28. fi
  29. if [ "$SITEURL" = "" ]; then
  30. echo "网站URL不正确"
  31. exit 1
  32. fi
  33. function handleFile()
  34. {
  35. Filename=$1
  36. if [ "${Filename##*.}" = "zip" ]; then
  37. handleZipFile $Filename
  38. else
  39. handleTextFile $Filename
  40. fi
  41. }
  42. function handleZipFile()
  43. {
  44. Filename=$1
  45. mkdir -p /tmp/package
  46. unzip -o -q $Filename -d /tmp/package
  47. grep -rl --include=\*.py --include=\*.sh --include=index.js 'http://www.example.com' /tmp/package | xargs -I @ sed -i "s|http://www.example.com|${SITEURL}|g" @
  48. Sprit_SITEURK=${SITEURL//\//\\\\\/}
  49. grep -rl --include=\*.sh 'http:\\\/\\\/www.example.com' /tmp/package | xargs -I @ sed -i "s|http:\\\/\\\/www.example.com|${Sprit_SITEURK}|g" @
  50. rm -f $Filename
  51. cd /tmp/package && zip -9 -q -r $Filename * && cd -
  52. rm -rf /tmp/package
  53. }
  54. function handleTextFile()
  55. {
  56. sed -i "s|http://www.example.com|${SITEURL}|g" $1
  57. }
  58. echo "=========================="
  59. echo "正在处理中..."
  60. echo "=========================="
  61. for File in ${FILES[@]}
  62. do
  63. Filename="${DIR}${File}"
  64. if [ -f "$Filename" ]; then
  65. handleFile $Filename
  66. echo -e "成功处理文件:\033[32m${Filename}\033[0m"
  67. else
  68. echo -e "文件不存在:\033[33m${Filename}\033[0m"
  69. fi
  70. done
  71. HASH=$(sha256sum "${DIR}public/install/update/LinuxPanel-${Linux_Version}.zip" | awk '{print $1}')
  72. TIMESTAMP=$(date +%s)
  73. printf '{"hash": "%s", "update_time": "%s"}' "$HASH" "$TIMESTAMP" > "${DIR}${PL_FILE}"
  74. echo "=========================="
  75. echo "处理完成"
  76. echo "=========================="