From ad11f42d3dae493bf949c38c79a35cf090fa4c32 Mon Sep 17 00:00:00 2001 From: zhangxinhui02 Date: Tue, 19 Aug 2025 22:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99volume-linker.sh=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E8=A6=86=E7=9B=96core=E5=AE=B9=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=90=AF=E5=8A=A8=E5=91=BD=E4=BB=A4=20?= =?UTF-8?q?=E7=94=B1=E4=BA=8Ek8s=E4=B8=8Edocker-compose=E7=9A=84=E5=8D=B7?= =?UTF-8?q?=E6=8C=82=E8=BD=BD=E6=96=B9=E5=BC=8F=E6=9C=89=E6=89=80=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=EF=BC=8C=E9=9C=80=E8=A6=81=E5=88=A9=E7=94=A8=E6=AD=A4?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=BA=E4=B8=80=E4=BA=9B=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E7=9B=AE=E5=BD=95=E6=8F=90=E5=89=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=A5=BD=E8=BD=AF=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/files/volume-linker.sh | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 helm-chart/files/volume-linker.sh diff --git a/helm-chart/files/volume-linker.sh b/helm-chart/files/volume-linker.sh new file mode 100644 index 00000000..944a6e1e --- /dev/null +++ b/helm-chart/files/volume-linker.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# 此脚本用于覆盖core容器的默认启动命令 +# 由于k8s与docker-compose的卷挂载方式有所不同,需要利用此脚本为一些文件和目录提前创建好软链接 +# /MaiMBot/data是麦麦数据的实际挂载路径 +# /MaiMBot/statistics是统计数据的实际挂载路径 + +set -e +echo "[VolumeLinker]Preparing volume..." + +# 初次启动,在存储卷中检查并创建关键文件和目录 +if [ -d /MaiMBot/data/plugins ] +then + echo "[VolumeLinker] '/MaiMBot/data/plugins' exists." +else + mkdir /MaiMBot/data/plugins +fi +if [ -d /MaiMBot/data/logs ] +then + echo "[VolumeLinker] '/MaiMBot/data/logs' exists." +else + mkdir /MaiMBot/data/logs +fi +if [ -f /MaiMBot/statistics/index.html ] +then + echo "[VolumeLinker] '/MaiMBot/statistics/index.html' exists." +else + touch /MaiMBot/statistics/index.html +fi + +# 删除空的插件目录,准备创建软链接 +rm -rf /MaiMBot/plugins + +# 创建软链接,从存储卷链接到实际位置 +ln -s /MaiMBot/data/plugins /MaiMBot/plugins +ln -s /MaiMBot/data/logs /MaiMBot/logs +ln -s /MaiMBot/statistics/index.html /MaiMBot/maibot_statistics.html + +# 启动麦麦 +echo "[VolumeLinker]Starting MaiBot..." +python bot.py