From ad808225114172e2ae28ce5ff311db7e8c4c1080 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 29 May 2026 15:35:48 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20ubuntu=2022.04=20?= =?UTF-8?q?=E4=B8=8B=E8=BF=90=E8=A1=8C=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #624 --- reinstall.sh | 23 +++++++++++++++++++++-- trans.sh | 15 ++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 4ab21f8..2c02f54 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1016,7 +1016,7 @@ get_windows_iso_link() { grep -Ewq 'ltsb|ltsc' <<<"$edition" } - # 部分 bash 不支持 $() 里面嵌套case,所以定义成函数 + # 部分 bash 例如 ubuntu 22.04 不支持 $() 里面嵌套case,所以定义成函数 label_msdn=$(get_label_msdn) label_msdl=$(get_label_msdl) label_vlsc=$(get_label_vlsc) @@ -3673,8 +3673,27 @@ EOF -e "/^[[:space:]]*set[[:space:]]/s/E//" \ $initrd_dir/trans.sh + # ubuntu 22.04 不支持这种语法,bash -n 会报错 + # 因此不验证 trans.sh 的语法 + # a=$( + # case 1 in + # 1) + # case 1 in + # 1) echo ;; + # 2) echo ;; + # esac + # ;; + # 2) + # case 1 in + # 1) echo ;; + # 2) echo ;; + # esac + # ;; + # esac + # ) + # 测试魔改后的 trans.sh 有没有语法问题 - bash -n $initrd_dir/trans.sh + # bash -n $initrd_dir/trans.sh } get_disk_drivers() { diff --git a/trans.sh b/trans.sh index 85a8ecd..ffbadf9 100644 --- a/trans.sh +++ b/trans.sh @@ -4273,8 +4273,21 @@ _is_ssh_kv_effective() { local key=$2 local value=$3 - # centos 7 不支持 -G + # 解决 ubuntu 22.04 报错 + # Missing privilege separation directory: /run/sshd + if [ -d "$os_dir/run/sshd" ]; then + we_create_run_sshd_dir=false + else + we_create_run_sshd_dir=true + mkdir -p "$os_dir/run/sshd" + fi + + # centos 7 / ubuntu 22.04 不支持 -G if res=$(chroot "$os_dir" sshd -G 2>/dev/null || chroot "$os_dir" sshd -T 2>/dev/null); then + # 删除自己创建的,避免后续权限不准确 + if $we_create_run_sshd_dir; then + rm -rf "$os_dir/run/sshd" + fi printf "%s\n" "$res" | grep -Fxiq "$key $value" else error_and_exit "Failed to verify sshd config."