linux - update-rc.d:错误:防火墙默认启动不包含运行级别,正在中止
问题描述
我正在尝试添加一项服务,以便它在启动时启动但不可能,我收到以下错误
$ 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
在 /lib/systemd/system/ 中创建 firewall.service 文件
> /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
推荐阅读
- python - Pyspark数据框将函数应用于一行并将行添加到数据框的底部
- python - 从 Windows 上的命令提示符下载 python
- sql-server - 有没有办法告诉 SQL Server 在插入每个新行之前检查表中的重复项?
- java - 如何从 Maven 依赖项中获取类文件到 target\classes 文件夹
- javascript - kinesis 视频流 webrtc 403 在预签名的 websocket wss url 上被禁止
- python - Dockerized Python 项目 - 管理依赖项的最佳方式:Dockerfile 或 requirements.txt
- excel - Google 地图未显示在 Microsoft Excel 数据输入表单中
- vagrant - Vagrantfile - 以相同主机名显示的多台虚拟机
- c++ - 从 C 可执行文件加载 C++ 动态库时收到错误“未定义符号”
- java - Launch4J 创建的 EXE 如何与需要外部数据(例如游戏中的图像或精灵)的 java 程序一起工作?