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.

80 lines
1.8 KiB

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