Skip to content

Commit f8ccf2f

Browse files
committed
Add systemd
1 parent 90e9359 commit f8ccf2f

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,29 @@ hosts 文件在每个系统的位置不一,详情如下:
133133

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

136+
#### 使用 Systemd 管理的 Linux
137+
138+
<details>
139+
140+
[![Systemd Packaging status](https://repology.org/badge/vertical-allrepos/systemd.svg)](https://repology.org/project/systemd/versions)
141+
142+
</details>
143+
144+
```bash
145+
cd GitHub520
146+
sudo install -Dm0644 update-github520-hosts* -t /usr/lib/systemd/system/
147+
sudo systemctl enable --now update-github520-hosts.timer
148+
sudo systemctl start update-github520-hosts.service
149+
sudo systemctl status update-github520-hosts.service
150+
cat /etc/hosts
151+
```
152+
153+
- Arch Linux: [AUR github520-git](https://aur.archlinux.org/packages/github520-git)
154+
155+
```bash
156+
yay -Syu github520
157+
```
158+
136159
#### GNU(Ubuntu/CentOS/Fedora)
137160

138161
`sudo sh -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts'`

update-github520-hosts.service

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Update GitHub520 Hosts File
3+
After=network.target
4+
5+
[Service]
6+
User=root
7+
PermissionsStartOnly=true
8+
ExecStart=/bin/bash -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && wget -O - https://raw.hellogithub.com/hosts >> /etc/hosts'
9+
Restart=on-failure
10+
RestartSec=30
11+
StartLimitInterval=3min
12+
13+
[Install]
14+
WantedBy=default.target

update-github520-hosts.timer

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Unit]
2+
Description=Update GitHub520 Hosts File Timer
3+
4+
[Timer]
5+
OnCalendar=*-*-* *:0/1:00
6+
Persistent=true
7+
8+
[Install]
9+
WantedBy=timers.target

0 commit comments

Comments
 (0)