介绍
基本信息
作者:朱明宇
名称:自动化部署 GRUB2 Bootloader 密码(openSUSE & SLES 版)
作用:自动化部署 GRUB2 Bootloader 密码(openSUSE & SLES 版)
使用方法
1. 给此脚本添加执行权限
2. 执行此脚本
3. 当启动系统时,左下角出现以下内容时按下 “E”:
C: Command Line E: Edit Entry
注意
1. 登录的账号是 root
2. 登录的密码是 eternalcenter
脚本
#!/bin/bash
echo "#!/bin/sh
exec tail -n +3 \$0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
set superusers=\"root\"
password_pbkdf2 root grub.pbkdf2.sha512.10000.B857B79D02FF55CA3A69B8485C1A4A427424630C804CC8A89134520A34E056D7882A778F6BC8AD856CB95DF8B99BE25F9FEAD899D826BB3915FB20BAD682D10A.4A1CF49B7F815A0578031CCA2CE98C66BDFBEAB0AE2721531BB54AFC6CFFA990FBD9062F41C006376C283B717FEC1BD9BB1AFB882AF91B5F4A812459D7974D1F
export superusers
set unrestricted_menu=\"y\"
export unrestricted_menu" > /etc/grub.d/40_custom
grep "rd.shell=0" /etc/default/grub
if [ $? -ne 0 ];then
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT="/s/"$/ rd.shell=0"/' /etc/default/grub
fi
grep "showopts" /etc/default/grub
if [ $? -ne 0 ];then
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT="/s/"$/ showopts"/' /etc/default/grub
fi
grep "LANG=C" /etc/default/grub
if [ $? -ne 0 ];then
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT="/s/"$/ LANG=C"/' /etc/default/grub
fi
grub2-mkconfig -o /boot/grub2/grub.cfg