From f7fdaf038a99b9a5286bd3c6d1be807952fdeb90 Mon Sep 17 00:00:00 2001 From: mini2024 Date: Tue, 11 Mar 2025 23:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=201.sh=20=E6=B7=BB=E5=8A=A0=20bash=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=20shell=20=E8=AE=BE=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 支持 Debian 和 Alpine 系统设置 bash 为默认 shell - 使用系统特定的方法切换默认 shell - 增加彩色输出提示设置结果 --- 1.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/1.sh b/1.sh index ce9d876..c66da03 100644 --- a/1.sh +++ b/1.sh @@ -12,6 +12,18 @@ print_red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } print_green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } print_yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } +# 设置 bash 为默认 shell +print_green "###################" +print_green "##### shell ######" +print_green "###################" +if [ -f /etc/debian_version ]; then + chsh -s $(which bash) + print_green "已将 bash 设置为默认 shell" +elif [ -f /etc/alpine-release ]; then + sed -i 's/^root:.*/root:\/bin\/bash/' /etc/passwd + print_green "已将 bash 设置为默认 shell" +fi + # 先检查是 Debian 还是 Alpine if [ -f /etc/debian_version ]; then SYSTEM_TYPE="debian"