Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plan to support group #31

Closed
alswl opened this issue Aug 29, 2018 · 4 comments
Closed

Any plan to support group #31

alswl opened this issue Aug 29, 2018 · 4 comments

Comments

@alswl
Copy link
Contributor

alswl commented Aug 29, 2018

Any plan to support group, for example, use a group to manage a group of hosts.

@cbednarski
Copy link
Owner

cbednarski commented Aug 29, 2018

Are you thinking of glob-like matching on the hostname? Can you give me an example?

Unfortunately /etc/hosts does not support wildcard domains like *.example.com, though you can use these with dnsmasq or a similar tool. However, some commands like on/off could be made to work with glob-like syntax.

If you simply want act on an arbitrary groups of hostnames you can write a bash script to turn them all on/off at once, for example. Tracking arbitrary groups in /etc/hosts itself would likely require some kind of metadata to be written into a comment -- that is not something I plan to add.

@alswl
Copy link
Contributor Author

alswl commented Aug 29, 2018

@cbednarski

For example, I have a group named issue_1, when enable this group, a list of domain will enable:

  • a.issue_1.domain.com
  • b.issue_2.domain.com
  • c.domain.com
  • d.test.com

I can use hostess group on issue_1 to enable all of these domains, and use hostess group off issue_1 disable all of these domains. And use hostess group add issue_1 a.domain.com and hostess group del issue_1 b.domain to add or remove domain in group.

@cbednarski
Copy link
Owner

Thanks for clarifying! This is not something I plan to support, because it requires encoding additional metadata into /etc/hosts (or another file) to keep track of the groups. I recommend using a bash script instead to enable or disable multiple entries.

However, I would not mind supporting glob-like syntax, as in: #25. That feature may simplify things for you.

@alswl
Copy link
Contributor Author

alswl commented Sep 18, 2019

My solution, use script to manage hosts group.

demo: https://github.com/alswl/.oOo./blob/4a46365177439c729198bc8bd4092d8de6607fa0/.zshrc.etc.d/hosts-on-off.zshrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants