systemd : créer son démon
Bonjour
J'ai regardé ici :
http://lea-linux.org/documentations/Systemd
J'ai créé mon démon (règles iptables à lancer au démarrage) : /etc/systemd/system/firewall.service . Mais, je n'arrive pas à le faire lancer au démarrage.
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| [Unit]
Description=Gestion des règles Iptables et du service de passerelle
After=network-online.target
[Service]
Type=simple
User=root
Group=root
UMask=007
ExecStart=/etc/init.d/firewall start
ExecStop=/etc/init.d/firewall stop
ExecReload=/etc/init.d/firewall restart |
J'avais une erreur signalant que je n'avais pas défini le run level du démon.
J'ai rajouté ceci au début du fichier /etc/init.d/firewall
Code:
1 2 3 4 5 6 7 8 9 10
| #!/bin/sh
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO |
l'erreur a changé :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| root@raspberrypi:~# 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
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
instance name specified. |
J'avoue que mon niveau d'anglais me cache peut-être la réponse à ma question qui se cache peut-être dans l'erreur.
nb : systemctl restart firewall.service marche bien.