如何将 init 脚本转换为 systemd?

How to convert init script into systemd?

下面的 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

systemd 中没有运行级别,tty1 可用并自动管理,直到系统挂断它们。