소스 검색

Update 服务端Docker脚本改为增量更新

Nolovenodie丶 2 년 전
부모
커밋
2e74e80b7f
2개의 변경된 파일18개의 추가작업 그리고 13개의 파일을 삭제
  1. 1 1
      README.md
  2. 17 12
      script.sh

+ 1 - 1
README.md

@@ -26,7 +26,7 @@ Chrome 扩展设置 > 开发者模式 > 加载已解压的扩展程序 > 直接
 
 _无需使用插件, 直接部署至服务端, 用户无缝使用_
 
-    # Docker 版
+    # Docker 版 (如遇脚本更新, 重新执行即可)
     # 国内请使用:
     docker exec EmbyServer /bin/sh -c 'cd /system/dashboard-ui && wget -O - https://tinyurl.com/3m72wwtk | sh'
     # 国外请使用:

+ 17 - 12
script.sh

@@ -1,21 +1,26 @@
 #!/bin/bash
 
 # 创建emby-crx目录并下载所需文件
-mkdir emby-crx
-wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/css/style.css -P emby-crx/
-wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/common-utils.js -P emby-crx/
-wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/jquery-3.6.0.min.js -P emby-crx/
-wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/md5.min.js -P emby-crx/
-wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/content/main.js -P emby-crx/
+mkdir -p emby-crx
+wget -N https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/css/style.css -P emby-crx/
+wget -N https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/common-utils.js -P emby-crx/
+wget -N https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/jquery-3.6.0.min.js -P emby-crx/
+wget -N https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/md5.min.js -P emby-crx/
+wget -N https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/content/main.js -P emby-crx/
 
 # 读取index.html文件内容
 content=$(cat index.html)
 
-# 定义要插入的代码
-code='<link rel="stylesheet" id="theme-css"  href="emby-crx/style.css" type="text/css" media="all" />\n<script src="emby-crx/common-utils.js"></script>\n<script src="emby-crx/jquery-3.6.0.min.js"></script>\n<script src="emby-crx/md5.min.js"></script>\n<script src="emby-crx/main.js"></script>'
+# 检查index.html是否包含emby-crx
+if [[ "$content" == *"emby-crx"* ]]; then
+    echo "Index.html already contains emby-crx, skipping insertion."
+else
+    # 定义要插入的代码
+    code='<link rel="stylesheet" id="theme-css" href="emby-crx/style.css" type="text/css" media="all" />\n<script src="emby-crx/common-utils.js"></script>\n<script src="emby-crx/jquery-3.6.0.min.js"></script>\n<script src="emby-crx/md5.min.js"></script>\n<script src="emby-crx/main.js"></script>'
 
-# 在</head>之前插入代码
-new_content=$(echo -e "${content/<\/head>/$code<\/head>}")
+    # 在</head>之前插入代码
+    new_content=$(echo -e "${content/<\/head>/$code<\/head>}")
 
-# 将新内容写入index.html文件
-echo -e "$new_content" > index.html
+    # 将新内容写入index.html文件
+    echo -e "$new_content" > index.html
+fi