Loading... # 部署 ``` version: '3.3' services: web-start: ports: - '2000:2000' image: 'luode0320/web-start:1.0' volumes: - ./index-95ea9c5d.js:/app/dist/assets/index-95ea9c5d.js networks: webstart-network: ipv4_address: 192.168.177.110 networks: webstart-network: driver: bridge ipam: config: - subnet: 192.168.177.0/24 name: webstart-network ``` # 更新内容 首先,需要在web页面进行更改,然后下载json文件。 更新json文件 ![2024-03-04T09:33:46.png][1] * index.json:在web页面下载的json文件 * index-95ea9c5d:当前的js文件。 注意,这个文件需要修改一下: ![2024-03-04T09:35:11.png][2] 这个地方需要手动进行修改了。不过在删除kT变量内容的时候,可以在`[`选中后,按快捷键`ctrl+alt+]`快速跳转。修改这个的目的是让sed可以快速定位要更改的文件内容。 * update.sh ``` #!/bin/bash # Extract the content from index.json json_content=$(jq -c '.data' index.json) # Escape special characters in the JSON content escaped_json_content=$(echo $json_content | sed 's/[&/\]/\\&/g') # Get the line numbers of the lines containing '/*start*/' and '/*stop*/' start_line=$(grep -n '/\*start\*/' index-95ea9c5d.js | cut -d : -f 1) end_line=$(grep -n '/\*stop\*/' index-95ea9c5d.js | cut -d : -f 1) start_line=$((start_line + 1)) end_line=$((end_line - 1 )) # Replace the content between '/*start*/' and '/*stop*/' with the JSON content sed -i "${start_line},${end_line}s/.*/kT = $escaped_json_content/" index-95ea9c5d.js scp index-95ea9c5d.js root@www.sddts.cn:/opt/webstart/index-95ea9c5d.js ``` [1]: https://www.sddts.cn/usr/uploads/2024/03/876124934.png [2]: https://www.sddts.cn/usr/uploads/2024/03/1526527221.png 最后修改:2024 年 03 月 04 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏