From 9df285ebba89ba3225605e380855642718c1e22b Mon Sep 17 00:00:00 2001 From: taotieren Date: Mon, 25 Dec 2023 14:14:36 +0800 Subject: [PATCH] Add systemd --- README.md | 24 ++++++++++++++++++++++++ update-github520-hosts.service | 14 ++++++++++++++ update-github520-hosts.timer | 9 +++++++++ 3 files changed, 47 insertions(+) create mode 100644 update-github520-hosts.service create mode 100644 update-github520-hosts.timer diff --git a/README.md b/README.md index ef8f09038907c7..8239daa42ca4d5 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,30 @@ hosts 文件在每个系统的位置不一,详情如下: ### 2.3 一行命令 (适用于类 Unix 系统) +#### 使用 Systemd 管理的 Linux + +
+Linux 发行版中 systemd 软件包状态 + +[![Packaging status](https://repology.org/badge/vertical-allrepos/systemd.svg)](https://repology.org/project/systemd/versions) + +
+ +```bash +cd GitHub520 +sudo install -Dm0644 update-github520-hosts* -t /usr/lib/systemd/system/ +sudo systemctl enable --now update-github520-hosts.timer +sudo systemctl start update-github520-hosts.service +sudo systemctl status update-github520-hosts.service +cat /etc/hosts +``` + +- Arch Linux: [AUR github520-git](https://aur.archlinux.org/packages/github520-git) + +```bash +yay -Syu github520 +``` + #### GNU(Ubuntu/CentOS/Fedora) `sudo sh -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts'` diff --git a/update-github520-hosts.service b/update-github520-hosts.service new file mode 100644 index 00000000000000..8f2078fb9de28c --- /dev/null +++ b/update-github520-hosts.service @@ -0,0 +1,14 @@ +[Unit] +Description=Update GitHub520 Hosts File +After=network.target + +[Service] +User=root +PermissionsStartOnly=true +ExecStart=/bin/bash -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && wget -O - https://raw.hellogithub.com/hosts >> /etc/hosts' +Restart=on-failure +RestartSec=30 +StartLimitInterval=3min + +[Install] +WantedBy=default.target diff --git a/update-github520-hosts.timer b/update-github520-hosts.timer new file mode 100644 index 00000000000000..4a39c85533cb7c --- /dev/null +++ b/update-github520-hosts.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Update GitHub520 Hosts File Timer + +[Timer] +OnCalendar=*-*-* *:0/1:00 +Persistent=true + +[Install] +WantedBy=timers.target