簡體   English   中英

update-rc.d:錯誤:防火牆默認啟動不包含運行級別,正在中止

[英]update-rc.d: error: firewall Default-Start contains no runlevels, aborting

我正在嘗試添加一項服務,以便它在啟動時啟動但不可能,我收到以下錯誤

$ 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM