From 2c0b45fadf5affc530e47931b371f4ebe33660c5 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 22 Oct 2023 16:39:35 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E9=AA=8C=E8=AF=81=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E8=99=9A=E6=8B=9F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 7d02055..77e97e0 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -204,6 +204,24 @@ add_community_repo_for_alpine() { fi } +assert_not_in_container() { + _error_and_exit() { + error_and_exit "Not Supported OS in Container.\nPlease use https://github.com/LloydAsp/OsMutation" + } + + is_in_windows && return + + if is_have_cmd systemd-detect-virt; then + if systemd-detect-virt -c >/dev/null; then + _error_and_exit + fi + else + if [ -d /proc/vz ] || grep container=lxc /proc/1/environ; then + _error_and_exit + fi + fi +} + is_virt() { if is_in_windows; then # https://github.com/systemd/systemd/blob/main/src/basic/virt.c @@ -875,8 +893,8 @@ while true; do esac done -# 验证目标系统字符串 -verify_os_string "$@" +# 不支持容器虚拟化 +assert_not_in_container # win系统盘 if is_in_windows; then