如何在systemd引导过程中运行最后一个并打印脚本输出?
问题描述:
我正在尝试在部署过程中配置主机,并将输出提供给我的配置脚本正在执行的操作。如何在systemd引导过程中运行最后一个并打印脚本输出?
在RHEL6中,我很容易回显我想要的屏幕或使用对话框显示输出,只有当我的脚本完成后,我才得到登录提示。
- (I使用rc3.d中或rc5.d夹与脚本名S99.myscript.sh)
在RHEL7我不能模仿这个过程。 rc.local在启动时不显示我的输出,也不保证它会最后运行。
我想我需要创建一个systemd服务文件来运行我的脚本。
但是如何在启动时将结果输出到屏幕?
我该如何确保在脚本结束前我不会得到登录提示?
答
以下服务的例子就像一个魅力:)
[Unit]
Description=ldt_bootscript1.service
After=network.target
[email protected]
[Service]
Type=oneshot
ExecStart=/bin/bash -c "/bin/bash /tmp/ldt_scripts/postinstall/rc.firstboot.qas | /usr/bin/dialog --clear --backtitle \"Linux Deployment\" --title \"tests\" --progressbox 20 70 > /dev/console 2>&1"
ExecStartPre=/usr/bin/echo -e \033%G
ExecReload=/bin/kill -HUP $MAINPID
RemainAfterExit=no
WorkingDirectory=/
Environment=TERM=xterm
[Install]
WantedBy=multi-user.target