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 timer-installation example #38

Open
Blaimi opened this issue Nov 8, 2023 · 0 comments
Open

systemd timer-installation example #38

Blaimi opened this issue Nov 8, 2023 · 0 comments

Comments

@Blaimi
Copy link

Blaimi commented Nov 8, 2023

I like systemd timers more than cronjobs so I wrote one.

Benefit against cronjob: It runs immediately after boot and from then every 5 minutes. A cronjob runs every fifth minute, i.e. you have to wait 2.5 minutes after boot on average for a initial update.

sudo curl -L https://github.com/FarrowStrange/hetzner-api-dyndns/releases/download/v1.3/dyndns.sh -o /usr/local/bin/hetzner-api-dyndns
sudo chmod +x /usr/local/bin/hetzner-api-dyndns
sudo mkdir -p /etc/hetzner-api-dyndns
cat <<EOF | sudo tee /etc/hetzner-api-dyndns.conf
HETZNER_ZONE_NAME=examle.com
HETZNER_RECORD_NAME=yourhost
HETZNER_RECORD_TYPE=AAAA
HETZNER_AUTH_API_TOKEN=<token>
EOF

cat <<EOF | sudo tee /etc/systemd/system/hetzner-api-dyndns.service
[Unit]
Description=update dyndns entry via hetzner API
After=network-online.target

[Service]
EnvironmentFile=/etc/hetzner-api-dyndns.conf
ExecStart=/usr/local/bin/hetzner-api-dyndns
EOF

cat <<EOF | sudo tee /etc/systemd/system/hetzner-api-dyndns.timer
[Unit]
Description=update dyndns entry via hetzner API every five minutes

[Timer]
Unit=hetzner-api-dyndns.service
# my network takes longer for the IPv6 address
OnBootSec=20
OnUnitActiveSec=5m

[Install]
WantedBy=timers.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now hetzner-api-dyndns.timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant