Skip to content

Commit

Permalink
Add systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
taotieren committed Dec 25, 2023
1 parent 90e9359 commit f8ccf2f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ hosts 文件在每个系统的位置不一,详情如下:

### 2.3 一行命令 (适用于类 Unix 系统)

#### 使用 Systemd 管理的 Linux

<details>

[![Systemd Packaging status](https://repology.org/badge/vertical-allrepos/systemd.svg)](https://repology.org/project/systemd/versions)

</details>

```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'`
Expand Down
14 changes: 14 additions & 0 deletions update-github520-hosts.service
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions update-github520-hosts.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Update GitHub520 Hosts File Timer

[Timer]
OnCalendar=*-*-* *:0/1:00
Persistent=true

[Install]
WantedBy=timers.target

0 comments on commit f8ccf2f

Please sign in to comment.