gpt4 book ai didi

linux - update-rc.d : error: firewall Default-Start contains no runlevels, 正在中止

转载 作者:行者123 更新时间:2023-12-03 08:45:22 26 4
gpt4 key购买 nike

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

$ 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

最佳答案

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

### 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/系统/

> /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

关于linux - update-rc.d : error: firewall Default-Start contains no runlevels, 正在中止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61694929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com