[英]update-rc.d: error: firewall Default-Start contains no runlevels, aborting
I am trying to add a service so that it starts at startup but impossible, I get the following error我正在尝试添加一项服务,以便它在启动时启动但不可能,我收到以下错误
$ 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
Edit your firewall file and add this at the beginning编辑您的防火墙文件并将其添加到开头
### 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
Move the file to the correct directory将文件移动到正确的目录
mv /etc/init.d/firewall /etc/systemd/system/firewall
Create the firewall.service file in /lib/systemd/system/在 /lib/systemd/system/ 中创建 firewall.service 文件
> /lib/systemd/system/firewall.service
Your firewall.service file should contain this您的 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
Reload systemd manager configuration and enable firewall重新加载 systemd 管理器配置并启用防火墙
systemctl daemon-reload
systemctl enable firewall
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.