Skip to content

Commit

Permalink
Update diy.sh
Browse files Browse the repository at this point in the history
调整一下设置虚拟机启动这个功能逻辑,
只有当用户创建了虚拟机的时候,才会设置开机自动登录。
  • Loading branch information
wukongdaily committed Dec 11, 2023
1 parent dfd259b commit e4e3167
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shell/diy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ set_vm_autostart() {
exit 1
;;
*)
# 设置自动登录 免GUI桌面登录
setautologin
do_autostart_vm
;;
esac
Expand All @@ -298,6 +296,8 @@ setautologin() {
sudo sed -i '/^#autologin-user=/s/^#//' /etc/lightdm/lightdm.conf
sudo sed -i "s/^autologin-user=.*/autologin-user=$USERNAME/" /etc/lightdm/lightdm.conf
sudo sed -i "s/^#autologin-user-timeout=.*/autologin-user-timeout=0/" /etc/lightdm/lightdm.conf
# 去掉开机提示:解锁您的开机密钥环
sudo rm -rf ~/.local/share/keyrings/*
}

# 设置开机5秒后
Expand Down Expand Up @@ -328,6 +328,9 @@ do_autostart_vm() {
return
fi

# 设置自动登录 免GUI桌面登录
setautologin

# 创建一个临时文件用于存储新的rc.local内容
TMP_RC_LOCAL=$(mktemp)

Expand Down Expand Up @@ -366,8 +369,7 @@ do_autostart_vm() {
# 删除临时文件
rm "$TMP_VM_LIST"

# 去掉开机提示:解锁您的开机密钥环
sudo rm -rf ~/.local/share/keyrings/*

# 显示/etc/rc.local的内容
Show 0 "已将所有虚拟机设置为开机无头自启动。查看配置 /etc/rc.local,如下"
cat /etc/rc.local
Expand Down

0 comments on commit e4e3167

Please sign in to comment.