-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.sh
More file actions
43 lines (21 loc) · 725 Bytes
/
new.sh
File metadata and controls
43 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
#0 */1 * * * cd /usr/local/Cellar/nginx/1.19.1/html/makeGithubFast && echo wsbnd9 | sudo -S sh new.sh >> /tmp/crontab_new.log
hosts=/etc/hosts
IpAddress=`curl https://hosts.gitcdn.top/hosts.txt`
printf "ok edit hosts ... \n"
printf "$IpAddress"
if [ "$EUID" -ne 0 ]; then
printf "error\nwill write\n$IpAddress\nPlease run as root"
else
OS="`uname`"
if [[ "$OS" == "darwin"* ]]; then
sed -i '' -e '/^# fetch-github-hosts.*/,/&/d' $hosts
else
sed -i -e '/^# fetch-github-hosts.*/,/&/d' $hosts
fi
printf "$IpAddress" >>$hosts
printf "ok\n"
# 清除DNS缓存命令
sudo killall -HUP mDNSResponder ;say flushed
printf "Reload OK!\n"
fi