[英]dtach in systemd service file
由于屏幕与python-newt库结合使用会在我们当前的设置中导致段错误,因此我一直在寻找替代屏幕的程序。 该系统绝对是最小的,只需要执行安装未来操作系统的python脚本即可。
我找到了dtach( http://linux.die.net/man/1/dtach )。 我可以在正在运行的tty会话中使用命令运行所需的脚本。
dtach -c /tmp/test /usr/local/bin/master.py
我还可以附加到正在运行的会话等。此外,我还需要使ut在引导时运行,因为屏幕前的用户必须能够输入不存在的值。
我制作了以下位于/etc/systemd/system/master.service中的systemd服务文件
[Unit]
Description=Job that starts the master.py
Requires=premaster.service
After=premaster.service
[Service]
Type=simple
ExecStart=/usr/bin/dtach -c /tmp/master /usr/local/bin/master.py
[Install]
WantedBy=multi-user.target
并在启动时启用了
systemctl enable /etc/systemd/system/master.service
premaster位于/etc/init.d/premaster中,并按预期执行
当我运行master.service时,出现以下错误
/usr/bin/dtach: Attaching to a session requires a terminal
使用以下文件修复了t:
主服务
[Unit]
Description=Job that starts the master.py
Requires=opsi.service
After=opsi.service
After=getty@tty6.service
[Service]
Environment=TERM=linux
Type=simple
ExecStart=/usr/local/bin/master.sh
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty6
[Install]
WantedBy=multi-user.target
大师
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
vt=6
sleep 1
chvt $vt
sleep 1
chvt $vt
. /etc/environment
export LANGUAGE
export LANG
export LC_ALL
dtach -A /tmp/bootimage master.py
通过这种配置,它可以工作并在启动时直接启动进入TTY6。 此外,它是交互式的,以防用户必须输入配置中缺少的内容。
也许有人会需要它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.