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.

86 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.3.0"
  3. Windows_Version="8.2.1"
  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/install_pro_en.sh
  23. public/install/update_7.x_en.sh
  24. )
  25. DIR=$1
  26. SITEURL=$2
  27. if [ ! -d "$DIR" ]; then
  28. echo "网站目录不存在"
  29. exit 1
  30. fi
  31. if [ "$SITEURL" = "" ]; then
  32. echo "网站URL不正确"
  33. exit 1
  34. fi
  35. function handleFile()
  36. {
  37. Filename=$1
  38. if [ "${Filename##*.}" = "zip" ]; then
  39. handleZipFile $Filename
  40. else
  41. handleTextFile $Filename
  42. fi
  43. }
  44. function handleZipFile()
  45. {
  46. Filename=$1
  47. mkdir -p /tmp/package
  48. unzip -o -q $Filename -d /tmp/package
  49. 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" @
  50. Sprit_SITEURK=${SITEURL//\//\\\\\/}
  51. grep -rl --include=\*.sh 'http:\\\/\\\/www.example.com' /tmp/package | xargs -I @ sed -i "s|http:\\\/\\\/www.example.com|${Sprit_SITEURK}|g" @
  52. rm -f $Filename
  53. cd /tmp/package && zip -9 -q -r $Filename * && cd -
  54. rm -rf /tmp/package
  55. }
  56. function handleTextFile()
  57. {
  58. sed -i "s|http://www.example.com|${SITEURL}|g" $1
  59. }
  60. echo "=========================="
  61. echo "正在处理中..."
  62. echo "=========================="
  63. for File in ${FILES[@]}
  64. do
  65. Filename="${DIR}${File}"
  66. if [ -f "$Filename" ]; then
  67. handleFile $Filename
  68. echo -e "成功处理文件:\033[32m${Filename}\033[0m"
  69. else
  70. echo -e "文件不存在:\033[33m${Filename}\033[0m"
  71. fi
  72. done
  73. echo "=========================="
  74. echo "处理完成"
  75. echo "=========================="