Giter Site home page Giter Site logo

mac-githubhosts-autoupdate's Introduction

Github Hosts Autoupdate for mac

此轻量级小工具将在 mac 上自动定时更新 github hosts

  • 默认情况下每小时更新一次。如需更改间隔请修改 hoststool.plist 文件中的StartInterval
  • 使用的 hosts 源为 JohyC/GithubHosts 项目的 Github 源,可能偶尔无法连接。如需更换 hosts 源,请修改 hoststool 里的 source 变量,或在手动运行时指定url。

安装

下载源代码并安装。

$ git clone https://github.com/Sansui233/mac-githubhosts-autoupdate.git && cd mac-githubhosts-autoupdate
$ sudo ./install.sh

成功安装后会立即运行一次。

此脚本使用 launchdaemon 定时运行,不会在后台长期挂起。可以使用 launchctl 查看其状态。

$ sudo launchctl list | grep hoststool
# 正常情况下的输出为。- 表示当前未运行,0 表示上次运行的状态正常。
-	0	hoststool 

查看 log 可以打开系统的日志程序 Console,右边选择 Log,搜索 hoststool 查看运行日志。

使用

安装完成之后将自动运行,无需其他配置。

如需手动运行:

$ hoststool # 查看可选参数
$ hoststool -u # 更新 Github hosts
$ hoststool -u remote_url # 更新时指定 hosts 源
$ hoststool -rm # 清除 Github hosts

Alfred Workflow

此工作流提供了手动运行 hoststool 的 Alfred 快捷方式。 workflow 使用的 hoststool 独立于系统中安装的 hoststool。

下载仓库中的 alfred workflow,双击安装即可。由于修改 host 需要管理员权限,安装时需要在 ROOTPASSWORD 中填入当前用户密码字段。

之后在 Alfred 中运行 hoststool 即可更新 hosts。

Log 中常见错误

  • [ERROR] 获取远程 host 出错,请尝试更换 source 或检查 download_dir 读写权限

    此情况会在开机后第一次运行出现,因为开机时无网络连接,为正常报错。若有网络的情况下出现此信息,请按信息内容排查。

  • [ERROR] source无效,请更换为可用hosts源

    此情况发生于获取到了远程文件,但文件内容可能被屏蔽,在Gitee上的托管的文件偶尔出现此类情况,建议更换 hoststool 文件中的 source 后重新安装此工具。

卸载

$ ./uninstall.sh

Thanks

mac-githubhosts-autoupdate's People

Contributors

sansui233 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.