From a402f6b3d5fa0fbbdb0c25d560ff769fc05f015b Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 18 Mar 2025 22:14:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E5=8D=8F=E8=AE=AE=E6=A3=80=E6=9F=A5=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_debian12.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/run_debian12.sh b/run_debian12.sh index 5a51a1a3..6550a01b 100644 --- a/run_debian12.sh +++ b/run_debian12.sh @@ -186,6 +186,42 @@ update_config() { fi } +check_eula() { + # 首先计算当前EULA的MD5值 + current_md5=$(md5sum ${INSTALL_DIR}/repo/EULA.md | awk '{print $1}') + + # 首先计算当前隐私条款文件的哈希值 + current_md5_privacy=$(md5sum ${INSTALL_DIR}/repo/PRIVACY.md | awk '{print $1}') + + # 检查eula.confirmed文件是否存在 + if [[ -f repo/elua.confirmed ]]; then + # 如果存在则检查其中包含的md5与current_md5是否一致 + confirmed_md5=$(cat ${INSTALL_DIR}/repo/elua.confirmed) + else + confirmed_md5="" + fi + + # 检查privacy.confirmed文件是否存在 + if [[ -f repo/privacy ]]; then + # 如果存在则检查其中包含的md5与current_md5是否一致 + confirmed_md5_privacy=$(cat ${INSTALL_DIR}/repo/privacy.confirmed) + else + confirmed_md5_privacy="" + fi + + # 如果EULA或隐私条款有更新,提示用户重新确认 + if [[ $current_md5 != $confirmed_md5 || $current_md5_privacy != $confirmed_md5_privacy ]]; then + whiptail --title "📜 使用协议更新" --yesno "检测到麦麦Bot EULA或隐私条款已更新。\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\nhttps://github.com/SengokuCola/MaiMBot/blob/main/PRIVACY.md\n\n您是否同意上述协议? \n\n " 12 70 + if [[ $? -eq 0 ]]; then + echo $current_md5 > ${INSTALL_DIR}/repo/elua.confirmed + echo $current_md5_privacy > ${INSTALL_DIR}/repo/privacy.confirmed + else + exit 1 + fi + fi + +} + # ----------- 主安装流程 ----------- run_installation() { # 1/6: 检测是否安装 whiptail @@ -195,7 +231,7 @@ run_installation() { fi # 协议确认 - if ! (whiptail --title "ℹ️ [1/6] 使用协议" --yes-button "我同意" --no-button "我拒绝" --yesno "使用麦麦Bot及此脚本前请先阅读ELUA协议\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\n\n您是否同意此协议?" 12 70); then + if ! (whiptail --title "ℹ️ [1/6] 使用协议" --yes-button "我同意" --no-button "我拒绝" --yesno "使用麦麦Bot及此脚本前请先阅读ELUA协议及隐私协议\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\nhttps://github.com/SengokuCola/MaiMBot/blob/main/PRIVACY.md\n\n您是否同意上述协议?" 12 70); then exit 1 fi @@ -355,7 +391,15 @@ run_installation() { pip install -r repo/requirements.txt echo -e "${GREEN}同意协议...${RESET}" - touch repo/elua.confirmed + + # 首先计算当前EULA的MD5值 + current_md5=$(md5sum repo/EULA.md | awk '{print $1}') + + # 首先计算当前隐私条款文件的哈希值 + current_md5_privacy=$(md5sum repo/PRIVACY.md | awk '{print $1}') + + echo $current_md5 > repo/elua.confirmed + echo $current_md5_privacy > repo/privacy.confirmed echo -e "${GREEN}创建系统服务...${RESET}" cat > /etc/systemd/system/${SERVICE_NAME}.service < Date: Tue, 18 Mar 2025 22:17:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BC=8F=E6=8E=89?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_debian12.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_debian12.sh b/run_debian12.sh index 6550a01b..f352bca9 100644 --- a/run_debian12.sh +++ b/run_debian12.sh @@ -194,7 +194,7 @@ check_eula() { current_md5_privacy=$(md5sum ${INSTALL_DIR}/repo/PRIVACY.md | awk '{print $1}') # 检查eula.confirmed文件是否存在 - if [[ -f repo/elua.confirmed ]]; then + if [[ -f ${INSTALL_DIR}/repo/elua.confirmed ]]; then # 如果存在则检查其中包含的md5与current_md5是否一致 confirmed_md5=$(cat ${INSTALL_DIR}/repo/elua.confirmed) else @@ -202,7 +202,7 @@ check_eula() { fi # 检查privacy.confirmed文件是否存在 - if [[ -f repo/privacy ]]; then + if [[ -f ${INSTALL_DIR}/repo/privacy.confirmed ]]; then # 如果存在则检查其中包含的md5与current_md5是否一致 confirmed_md5_privacy=$(cat ${INSTALL_DIR}/repo/privacy.confirmed) else From 8c89c0b95e63d3c243521de550e353551e194ba6 Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 18 Mar 2025 22:22:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=9A=BE=E7=BB=B7=E7=9A=84typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_debian12.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/run_debian12.sh b/run_debian12.sh index f352bca9..7acd62e5 100644 --- a/run_debian12.sh +++ b/run_debian12.sh @@ -161,8 +161,8 @@ switch_branch() { sed -i "s/^BRANCH=.*/BRANCH=${new_branch}/" /etc/maimbot_install.conf BRANCH="${new_branch}" + check_eula systemctl restart ${SERVICE_NAME} - touch "${INSTALL_DIR}/repo/elua.confirmed" whiptail --msgbox "✅ 已切换到分支 ${new_branch} 并重启服务!" 10 60 } @@ -194,9 +194,9 @@ check_eula() { current_md5_privacy=$(md5sum ${INSTALL_DIR}/repo/PRIVACY.md | awk '{print $1}') # 检查eula.confirmed文件是否存在 - if [[ -f ${INSTALL_DIR}/repo/elua.confirmed ]]; then + if [[ -f ${INSTALL_DIR}/repo/eula.confirmed ]]; then # 如果存在则检查其中包含的md5与current_md5是否一致 - confirmed_md5=$(cat ${INSTALL_DIR}/repo/elua.confirmed) + confirmed_md5=$(cat ${INSTALL_DIR}/repo/eula.confirmed) else confirmed_md5="" fi @@ -213,7 +213,7 @@ check_eula() { if [[ $current_md5 != $confirmed_md5 || $current_md5_privacy != $confirmed_md5_privacy ]]; then whiptail --title "📜 使用协议更新" --yesno "检测到麦麦Bot EULA或隐私条款已更新。\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\nhttps://github.com/SengokuCola/MaiMBot/blob/main/PRIVACY.md\n\n您是否同意上述协议? \n\n " 12 70 if [[ $? -eq 0 ]]; then - echo $current_md5 > ${INSTALL_DIR}/repo/elua.confirmed + echo $current_md5 > ${INSTALL_DIR}/repo/eula.confirmed echo $current_md5_privacy > ${INSTALL_DIR}/repo/privacy.confirmed else exit 1 @@ -231,7 +231,7 @@ run_installation() { fi # 协议确认 - if ! (whiptail --title "ℹ️ [1/6] 使用协议" --yes-button "我同意" --no-button "我拒绝" --yesno "使用麦麦Bot及此脚本前请先阅读ELUA协议及隐私协议\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\nhttps://github.com/SengokuCola/MaiMBot/blob/main/PRIVACY.md\n\n您是否同意上述协议?" 12 70); then + if ! (whiptail --title "ℹ️ [1/6] 使用协议" --yes-button "我同意" --no-button "我拒绝" --yesno "使用麦麦Bot及此脚本前请先阅读EULA协议及隐私协议\nhttps://github.com/SengokuCola/MaiMBot/blob/main/EULA.md\nhttps://github.com/SengokuCola/MaiMBot/blob/main/PRIVACY.md\n\n您是否同意上述协议?" 12 70); then exit 1 fi @@ -398,7 +398,7 @@ run_installation() { # 首先计算当前隐私条款文件的哈希值 current_md5_privacy=$(md5sum repo/PRIVACY.md | awk '{print $1}') - echo $current_md5 > repo/elua.confirmed + echo $current_md5 > repo/eula.confirmed echo $current_md5_privacy > repo/privacy.confirmed echo -e "${GREEN}创建系统服务...${RESET}" From 8dfccfce76599eb5a9aa6acc70c4805da452f6f5 Mon Sep 17 00:00:00 2001 From: Cookie987 Date: Tue, 18 Mar 2025 22:28:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8A=A0=E5=BC=95?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_debian12.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run_debian12.sh b/run_debian12.sh index 7acd62e5..ae189844 100644 --- a/run_debian12.sh +++ b/run_debian12.sh @@ -188,10 +188,10 @@ update_config() { check_eula() { # 首先计算当前EULA的MD5值 - current_md5=$(md5sum ${INSTALL_DIR}/repo/EULA.md | awk '{print $1}') + current_md5=$(md5sum "${INSTALL_DIR}/repo/EULA.md" | awk '{print $1}') # 首先计算当前隐私条款文件的哈希值 - current_md5_privacy=$(md5sum ${INSTALL_DIR}/repo/PRIVACY.md | awk '{print $1}') + current_md5_privacy=$(md5sum "${INSTALL_DIR}/repo/PRIVACY.md" | awk '{print $1}') # 检查eula.confirmed文件是否存在 if [[ -f ${INSTALL_DIR}/repo/eula.confirmed ]]; then @@ -393,10 +393,10 @@ run_installation() { echo -e "${GREEN}同意协议...${RESET}" # 首先计算当前EULA的MD5值 - current_md5=$(md5sum repo/EULA.md | awk '{print $1}') + current_md5=$(md5sum "repo/EULA.md" | awk '{print $1}') # 首先计算当前隐私条款文件的哈希值 - current_md5_privacy=$(md5sum repo/PRIVACY.md | awk '{print $1}') + current_md5_privacy=$(md5sum "repo/PRIVACY.md" | awk '{print $1}') echo $current_md5 > repo/eula.confirmed echo $current_md5_privacy > repo/privacy.confirmed