linux-kernel - 从 GRUB 菜单项运行脚本
问题描述
我按照出色的指南https://willhaley.com/blog/custom-debian-live-environment/创建了 Debian Live DVD 。
I would like to be able to great two grub menu enteries when selected auto login and run a script.
menuentry "Run Script 1" {
linux /vmlinuz boot=live quiet nomodeset
initrd /initrd
}
menuentry "Run Script 2" {
linux /vmlinuz boot=live quiet nomodeset
initrd /initrd
}
当我以 root 身份自动登录时,如何从 grub 菜单条目传递要运行的脚本的绝对路径?
/lib/live/mount/medium/scripts/script1.bash
要自动登录,我已将 /lib/systemd/system/getty@.service 修改为使用上述菜单项以 root 身份自动登录。
解决方案
使用自定义参数启动:
linux /vmlinuz .... my_dummy_param=/lib/live/mount/medium/scripts/script1.bash
然后稍后在您的登录 shell 启动文件中读取/proc/cmdline
并解析它,例如。用于.bashrc
bash shell 或.profile
:
#!/bin/bash
. /proc/cmdline
echo "Running $my_dummy_param"
"$my_dummy_param"
推荐阅读
- xamarin - 如何捕获 Xamarin 轮播页面的后退按钮
- azure-storage - 无法在 AKS 上为 pod 挂载卷
- data-science - Vowpal Wabbit:拆分训练和测试文件时如何使用命令行参数
- java - 我成功登录,但只能在第二次尝试后访问该站点
- python - 如何创建关联表?
- python - “大”Pyspark 数据帧写入镶木地板/转换为 Pandas 数据帧
- java - Axon Framework 从 domain_event_entry 表中读取所有事件,而不是在其中序列化有效负载
- neo4j - 如何处理由于堆大小错误而失去与服务器的连接?
- html - 使页脚成为页面上的最后一个 div
- fullcalendar - 第二列中的日期未正确呈现