为 1.sh 添加 bash 默认 shell 设置功能

- 支持 Debian 和 Alpine 系统设置 bash 为默认 shell
- 使用系统特定的方法切换默认 shell
- 增加彩色输出提示设置结果
This commit is contained in:
mini2024
2025-03-11 23:40:01 +08:00
parent 9a852c78c4
commit f7fdaf038a

12
1.sh
View File

@ -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"