From 8f33693228a2f05c52edfc3da6b9db9d54520fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 7 Oct 2023 19:55:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=8D=B8=E8=BD=BD=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++ README_EN.md | 12 ++++++ scripts/install_panel.sh | 8 ++-- scripts/uninstall_panel.sh | 86 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 scripts/uninstall_panel.sh diff --git a/README.md b/README.md index 95b0ff30..473dbd5c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,18 @@ CentOS Stream 可使用迁移脚本迁移至支持的系统: [CentOS 8/9 迁移 bash <(curl -sSL https://dl.cdn.haozi.net/panel/install_panel.sh) ``` +## 卸载面板 + +优先建议备份数据重装系统,这样可以保证系统纯净。 + +如果你无法重装系统,请以`root`用户登录服务器,执行以下命令卸载面板: + +```shell +bash <(curl -sSL https://dl.cdn.haozi.net/panel/uninstall_panel.sh) +``` + +卸载面板前请务必备份好所有数据,提前卸载面板全部插件。卸载后数据将**无法恢复**! + ## 日常维护 使用`panel`命令进行日常维护: diff --git a/README_EN.md b/README_EN.md index 8631e3d6..02285c85 100644 --- a/README_EN.md +++ b/README_EN.md @@ -51,6 +51,18 @@ If you decide to continue, please log in to the server as `root` user and execut bash <(curl -sSL https://dl.cdn.haozi.net/panel/install_panel.sh) ``` +## Uninstall Panel + +Recommended to back up data and reinstall the system first, so that the system can be kept clean. + +If you are unable to reinstall the system, log in to the server as the `root` user and execute the following command to uninstall the panel: + +```shell +bash <(curl -sSL https://dl.cdn.haozi.net/panel/uninstall_panel.sh) +``` + +Before uninstalling the panel, please be sure to back up all data and uninstall all panel plugins in advance. The data will **not be recoverable** after uninstallation! + ## Daily Maintenance Use `panel` command for daily maintenance: diff --git a/scripts/install_panel.sh b/scripts/install_panel.sh index 7eda08af..037a3f9c 100644 --- a/scripts/install_panel.sh +++ b/scripts/install_panel.sh @@ -24,7 +24,7 @@ setup_Path="/www" sshPort=$(cat /etc/ssh/sshd_config | grep 'Port ' | awk '{print $2}') inChina=$(curl --retry 2 -m 10 -L https://www.cloudflare-cn.com/cdn-cgi/trace 2> /dev/null | grep -qx 'loc=CN' && echo "true" || echo "false") -Prepare_system() { +Prepare_System() { if [ $(whoami) != "root" ]; then echo -e $HR echo "错误:请使用root用户运行安装命令。" @@ -290,12 +290,12 @@ fi echo -e $LOGO echo '安装面板依赖软件(如报错请检查 APT/Yum 源是否正常)' echo -e $HR -sleep 3s -Prepare_system +sleep 2s +Prepare_System Auto_Swap echo -e $LOGO echo '安装面板运行环境(视网络情况可能需要较长时间)' echo -e $HR -sleep 3s +sleep 2s Init_Panel diff --git a/scripts/uninstall_panel.sh b/scripts/uninstall_panel.sh new file mode 100644 index 00000000..c7aea542 --- /dev/null +++ b/scripts/uninstall_panel.sh @@ -0,0 +1,86 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright 2022 HaoZi Technology Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +' + +LOGO="+----------------------------------------------------\n| 耗子Linux面板卸载脚本\n+----------------------------------------------------\n| Copyright © 2022-"$(date +%Y)" 耗子科技 All rights reserved.\n+----------------------------------------------------" +HR="+----------------------------------------------------" +download_Url="" +setup_Path="/www" + +Prepare_System() { + if [ $(whoami) != "root" ]; then + echo -e $HR + echo "错误:请使用root用户运行卸载命令。" + exit 1 + fi + + isInstalled=$(systemctl status panel 2>&1 | grep "Active") + if [ "${isInstalled}" == "" ]; then + echo -e $HR + echo "错误:耗子Linux面板未安装,无需卸载。" + exit 1 + fi + + if ! id -u "www" > /dev/null 2>&1; then + groupadd www + useradd -s /sbin/nologin -g www www + fi +} + +Remove_Swap() { + swapFile="${setup_Path}/swap" + if [ -f "${swapFile}" ]; then + swapoff ${swapFile} + rm -f ${swapFile} + sed -i '/swap/d' /etc/fstab + fi +} + +Remove_Panel() { + systemctl stop panel + systemctl disable panel + rm -f /etc/systemd/system/panel.service + rm -rf ${setup_Path} +} + +clear +echo -e "${LOGO}" + +# 卸载确认 +echo -e "高危操作,卸载面板前请务必备份好所有数据,提前卸载面板所有插件!" +echo -e "卸载面板后,所有数据将被清空,无法恢复!" +read -r -p "输入 y 并回车以确认卸载面板:" uninstall +if [ "${uninstall}" != 'y' ]; then + echo "输入不正确,已退出卸载。" + exit +fi + +echo -e "${LOGO}" +echo '正在卸载耗子Linux面板...' +echo -e $HR + +Prepare_System +Remove_Swap +Remove_Panel + +clear + +echo -e "${LOGO}" +echo '耗子Linux面板卸载完成。' +echo '感谢您的使用,欢迎您再次使用耗子Linux面板。' +echo -e $HR