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.

76 lines
1.7 KiB

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