Homas / ioc2rpz

ioc2rpz is a place where threat intelligence meets DNS.
Apache License 2.0
105 stars 17 forks source link

systemctl wrapper to restart ioc2rpz when config file is changed #51

Open dmgeurts opened 10 months ago

dmgeurts commented 10 months ago

For those interested in automatically restarting ioc2rpz

Create a new watcher restart service:

sudo systemctl edit --force --full ioc2rpz-cfg-watcher.service

[Unit]
Description=ioc2rpz restarter
After=network.target
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=oneshot
ExecStart=/usr/bin/docker compose -f /opt/ioc2rpz.dc/docker-compose.yml restart ioc2rpz

[Install]
WantedBy=multi-user.target

Create a new watcher path service:

sudo systemctl edit --force --full ioc2rpz-cfg-watcher.path

[Path]
Unit=ioc2rpz-cfg-watcher.service
PathChanged=/opt/ioc2rpz/cfg/ioc2rpz.conf

[Install]
WantedBy=multi-user.target

Enable and start the new services:

sudo systemctl enable --now ioc2rpz-cfg-watcher.{path,service}

Check the new services with:

sudo systemctl status ioc2rpz-cfg-watcher sudo systemctl status ioc2rpz-cfg-path

Now edit the config file and observe whether ioc2rpz is restarted

sudo journalctl -fu docker

And then edit the config file, by changing the time stamp in the first line of the config file (the comment).