如何将初始化脚本转换为systemd?

时间:2018-12-20 06:27:20

标签: systemd ubuntu-18.04

以下init代码可在ubuntu 14上运行,但是最新的Ubuntu不支持init,需要将该脚本转换为可在systemd中使用。

我想启动服务部分,但是无法弄清楚如何将其限制为仅tty2,3;我该如何解决?

(初始代码)

 # tty1 - getty
    #
    # This service maintains a getty on tty1 from the point the system is
    # started until it is shut down again.

    start on stopped rc RUNLEVEL=[23] and (
                not-container or
                container CONTAINER=lxc or
                container CONTAINER=lxc-libvirt)

    stop on runlevel [!23]

    respawn
    exec /sbin/getty -n -l /etc/init/banner.sh -8 <port> tty1

[Unit]
Description=This service maintains a getty on tty1 from the point the system is started until it is shut down again.
After=network.target

[Service]
Type=simple
ExecStart=/sbin/getty -n -l /etc/init/bapp_banner.sh -8 <Port> tty1
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

1 个答案:

答案 0 :(得分:0)

systemd中没有运行级别,并且tty1可以自动进行管理,直到系统对它们进行挂起为止。