为 Alpine 系统添加 bash 默认 shell 设置功能,安装 shadow 包以支持更改

This commit is contained in:
mini2024
2025-03-13 01:16:53 +08:00
parent b5a187bf33
commit 5ef6f876e7

5
1.sh
View File

@ -20,7 +20,10 @@ if [ -f /etc/debian_version ]; then
chsh -s $(which bash) chsh -s $(which bash)
print_green "已将 bash 设置为默认 shell" print_green "已将 bash 设置为默认 shell"
elif [ -f /etc/alpine-release ]; then elif [ -f /etc/alpine-release ]; then
sed -i 's/^root:.*/root:\/bin\/bash/' /etc/passwd apk add shadow
chsh -s $(which bash) root
# sed -i 's|^\(root:.*\):[^:]*$|\1:/bin/bash|' /etc/passwd
# sed -i 's|^\(root:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*\):[^:]*$|\1:/bin/bash|' /etc/passwd
print_yellow "已将 bash 设置为默认 shell" print_yellow "已将 bash 设置为默认 shell"
fi fi