Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: Add systemd timer and service #2

Merged
merged 2 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ For example:
/usr/share/nft-blackhole/nft-blackhole.template
/etc/nft-blackhole.conf
/usr/lib/systemd/system/nft-blackhole.service
/usr/lib/systemd/system/nft-blackhole-reload.service
/usr/lib/systemd/system/nft-blackhole-reload.timer

## Configuration
#### Set the configuration in a file
Expand All @@ -81,14 +83,20 @@ For example:
### List table and sets for blackhole
nft list table inet blackhole
### Refresh lists
#### Manual

/usr/bin/nft-blackhole.py reload
systemctl reload nft-blackhole.service
or add to root crontab e.g.

#### Crontab

0 */6 * * * systemctl reload nft-blackhole.service

#### Systemd Timer

systemctl enable --now nft-blackhole-reload.service
systemctl list-timers

## Credits
[country-ip-blocks](https://github.com/herrbischoff/country-ip-blocks) - CIDR country-level IP lists,

Expand Down
10 changes: 10 additions & 0 deletions nft-blackhole-reload.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Update nft blackhole table
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/nft-blackhole.py reload

User=root
9 changes: 9 additions & 0 deletions nft-blackhole-reload.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description="Update blackhole lists"

[Timer]
OnBootSec=15min
OnUnitActiveSec=6h

[Install]
WantedBy=multi-user.target