【问题标题】:update-rc.d: error: firewall Default-Start contains no runlevels, abortingupdate-rc.d:错误:防火墙默认启动不包含运行级别,正在中止
【发布时间】:2020-08-24 22:35:46
【问题描述】:

我正在尝试添加一个服务,以便它在启动时启动但不可能,我收到以下错误

$ sudo systemctl enable firewall.service

Synchronizing state of firewall.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable firewall
update-rc.d: error: firewall Default-Start contains no runlevels, aborting
# /etc/systemd/system/firewall.service
[Unit]
ConditionPathExists=/etc/init.d/firewall
after=network.target

[Service]
ExecStart=/etc/init.d/firewall

[Install]
WantedBy=multi-user.target

【问题讨论】:

    标签: linux systemctl


    【解决方案1】:

    编辑您的防火墙文件并将其添加到开头

    ### BEGIN INIT INFO
    # Provides:          firewall
    # Required-Start:    $all
    # Required-Stop:
    # Default-Start:     2 3 4 5
    # Default-Stop:
    # Short-Description: your description here
    ### END INIT INFO
    

    将文件移动到正确的目录

    mv /etc/init.d/firewall  /etc/systemd/system/firewall
    

    在中创建 firewall.service 文件 /lib/systemd/system/

    > /lib/systemd/system/firewall.service
    

    你的 firewall.service 文件应该包含这个

     [Unit]
     Description=Firewall
    
     [Service]
     Type=simple
     RemainAfterExit=yes
     ExecStart=/etc/systemd/system/firewall start
     ExecStop=/etc/systemd/system/firewall stop
     ExecReload=/etc/systemd/system/firewall restart
    
     [Install]
     WantedBy=multi-user.target
    

    重新加载 systemd 管理器配置并启用防火墙

    systemctl daemon-reload
    systemctl enable firewall
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-26
      • 2020-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多