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
Your firewall.service file should contain this
[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
systemctl daemon-reload
systemctl enable firewall
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.