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.

85 lines
2.0 KiB

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