bjeanes / ghost Goto Github PK
View Code? Open in Web Editor NEWCreate, list, delete, and modify /etc/hosts entries with ease...
License: MIT License
Create, list, delete, and modify /etc/hosts entries with ease...
License: MIT License
if you have a line with multiple hosts: e.g.
127.0.0.1 project_a.local project_b.local project_c.local
and then run ghost add project_d.local, itll clobber all but the first host of that line:
127.0.0.1 project_d.local
127.0.0.1 project_a.local
When you are trying to add a host as a non-root user (or the user does not have write access to /etc/hosts), you get the following error message:
Cannot overwrite an existing entry. Use the modify subcommand
Instead of something more meaningful like "/etc/hosts is not write-able, try to run this program as a super user" or something.
I'm not sure whether this is desired or not, but calling Ghost.store.delete "foo"
will remove all hosts with foo
as a substring rather than just foo
itself.
The effect of this, for example, is that if I have hosts node-1
to node-20
, trying to delete node-1
will not only delete node-1
but also all of node-10
through node-19
.
I'm guessing that as the argument to delete
is called host
rather than (say) pattern
, this probably isn't desired behaviour?
I just installed ghost on Mac OS X 10.8.2. As the first thing, I wanted to check what ghost-ssh
says with the list
parameter. This is what I got:
$ ghost-ssh list
/Library/Ruby/Gems/1.8/gems/ghost-0.3.0/bin/ghost-ssh:80: undefined method `length' for nil:NilClass (NoMethodError)
from /usr/bin/ghost-ssh:23:in `load'
from /usr/bin/ghost-ssh:23
♪ bin/ghost list
/Users/bjeanes/Code/OSS/mine/ghost/lib/ghost/linux-host.rb:101:in `initialize': Permission denied - /etc/hosts (Errno::EACCES)
from /Users/bjeanes/Code/OSS/mine/ghost/lib/ghost/linux-host.rb:101:in `open'
from /Users/bjeanes/Code/OSS/mine/ghost/lib/ghost/linux-host.rb:101:in `with_exclusive_file_access'
from /Users/bjeanes/Code/OSS/mine/ghost/lib/ghost/linux-host.rb:26:in `list'
from bin/ghost:81:in `<main>'
For reading, it shouldn't need exclusive access or anything except read permission...
Via a custom DNS server (DNSMasq?) or source (a la pow)
I think ghost is using ruby18-only case-when syntax.
Using something like https://github.com/bluemonk/ipaddress or Ruby stdlib's http://www.ruby-doc.org/stdlib-1.9.3/libdoc/ipaddr/rdoc/IPAddr.html
Via: http://support.apple.com/kb/HT5343
sudo killall -HUP mDNSResponder
This old code is awful and messy. The parts that are tested are done so in a brittle and silly way.
Rewrite all the code.
Hi,
Would it be trivial to add a filter so www.example.com and example.com can be added with one command?
something like:
ghost add (www)example.com
Hey there,
I use ghost on a regular basis. Its a great library, but there's one small change that, if implemented, would bring a smile to my face every time I use it: instead of ghost empty
to clear all ghost-managed hosts, how about making it ghost bust
?
I know it's a little cheesy, but a good pun never hurt anyone!
I'm not a ruby dev (I'm a designer) so it's unlikely I can make this happen myself.
Cheers for taking the time to maintain this library!
— G
Hi, the current gem does not work on OS X 10.8.3, whereas the master does. Could we update the gem, too?
Thanks,
Robin
Is it possible to configure a host with ghost to see the hosts' virtual hosts?
trying to do a ghost add I get:
ghost:38: uninitialized constant SocketError (NameError)
(problem fixed in my fork: alkesh/ghost).
In OSX 10.7 (Lion), specifically, you have to put your entries ABOVE the line:
fe80::1%lo0 localhost
a few references:
http://apple.stackexchange.com/questions/27415/lion-hosts-file-bug
http://thecoredump.org/2011/09/editing-the-hosts-file-in-mac-os-x-lion/
Not a ghost issue per-se, but I can't seem to get Safari 5.1 in Lion GM to resolve hosts configured with Ghost.
Firefox & Chrome load the local host without a problem.
Anyone else running into this issue?
Could you push a version with the latest changes, perhaps 0.3.x so we can get some of the latest updates/pulls in gem rather than git form?
It succesfully adds hosts to the DSCL but they arent' loaded when I type them up in the browser. How can I force ghost to use my hosts file instead?
It would be useful to have a feature / command that disables a particular host entry (simply comments it out in /etc/hosts).
Usage would be ghost disable <hostname>
.
This way, you can still see the disabled entry in the list (perhaps with *disabled at the end of the line) if you want to temporarily remove the mapping from the hosts database. I know that personally I have many commented lines in my /etc/hosts file when I manage it manually, because I may only need the host entry when I am working remotely or when I am testing a new website and need to "pretend" that it is the live site.
For instance, given:
## -- /etc/hosts -- ##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
# ghost start
127.0.0.1 magento15.local www.magento15.local
#127.0.0.1 example.com
#127.0.0.1 www.example.com
# ghost end
The command ghost list
would yield:
Listing 4 host(s):
magento15.local -> 127.0.0.1
www.magento15.local -> 127.0.0.1
example.com -> 127.0.0.1 (disabled)
www.example.com -> 127.0.0.1 (disabled)
This is probably trivial to implement in /etc/hosts, but a bit more difficult on Mac dscl.
For example, if you have the following .ssh/config:
Host foo
Hostname 127.0.0.1
Host bar
Hostname 127.0.0.2
Host baz
Hostname 127.0.0.3
And use ghost-ssh list
, you get:
Listing 2 configs(s):
foo -> 127.0.0.2:22
baz -> 127.0.0.3:22
I would expect to see three hosts, rather than two. It may be better style to end the declarations belonging to a particular Host with a blank line but the "Host" keyword should be sufficient to demarcate entries. What do you think?
When running, I get:
/usr/share/rubygems/rubygems/custom_require.rb:36:in `require': cannot load such file -- unindent (LoadError)
from lib/ghost/cli/task.rb:1:in `<top (required)>'
...
It would be great to be able to set a default IP
But Ghost assumes that an IP can have many hosts, but a host belongs to a single IP. This isn't critical as most people probably use /etc/hosts
with the same assumption, but still...
The toplevel constant Host
is a collision-prone class name. For example, one collision happens when trying to use Ghost together with vagrant.
Would it be possible to change this to Ghost::Host or something similar?
I've just installed ghost
(Ubuntu 12.10 with Ruby 1.9.3p194) and run ghost-ssh list
:
ibc@myhost:~$ ghost-ssh list
/var/lib/gems/1.9.1/gems/ghost-0.3.0/bin/ghost-ssh:80:in `block in <top (required)>': undefined method `length' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/ghost-0.3.0/bin/ghost-ssh:80:in `each'
from /var/lib/gems/1.9.1/gems/ghost-0.3.0/bin/ghost-ssh:80:in `max'
from /var/lib/gems/1.9.1/gems/ghost-0.3.0/bin/ghost-ssh:80:in `<top (required)>'
from /usr/local/bin/ghost-ssh:23:in `load'
from /usr/local/bin/ghost-ssh:23:in `<main>'
In Safari mac 10.8.5, if you have more than 18 hosts on a single line, all hosts will fail to resolve. Not an issue in chrome on same OS. This is an issue more with Safari and/or OSX.
Could ghost have an option to always use a new line for same host addresses?
For example none of these will resolve in Safari
127.0.0.1 first.domain second.domain third.domain forth.domain fifth.domain sixth.domain seventh.domain eighth.domain ninth.domain tenth.domain eleventh.domain twelfth.domain thirteenth.domain fourteenth.domain fifteenth.domain sixteenth.domain seventeenth.domain eighteenth.domain nineteenth.domain
However if you remove the last domain they will.
OS X 10.6.8
Ruby 1.9.2-p290
Ghost 0.3.0
dking@desktop21 ~/Projects $ gem install ghost
Fetching: ghost-0.3.0.gem (100%)
Successfully installed ghost-0.3.0
1 gem installed
Installing ri documentation for ghost-0.3.0...
Installing RDoc documentation for ghost-0.3.0...
dking@desktop21 ~/Projects $ ghost
USAGE: ghost add <hostname> [<ip=127.0.1.1>]
ghost modify <hostname> <ip> OR <hostname> (will lookup ip)
ghost delete <hostname>
ghost delete_matching <pattern>
ghost list [<filter>]
ghost empty
ghost export
ghost import <file>
dking@desktop21 ~/Projects $ ghost list
Listing 0 host(s):
dking@desktop21 ~/Projects $ ghost add local.test
/Users/dking/.rvm/gems/ruby-1.9.2-p290/gems/ghost-0.3.0/bin/ghost:33:in `<top (required)>': undefined method `name' for nil:NilClass (NoMethodError)
from /Users/dking/.rvm/gems/ruby-1.9.2-p290/bin/ghost:19:in `load'
from /Users/dking/.rvm/gems/ruby-1.9.2-p290/bin/ghost:19:in `<main>'
Disregard this
Just installed Ghost, so latest version of that. OSX 10.6.8, ruby 1.8.7p149, zshell/oh-my-zsh. Same error for any ghost command, empty, add, list
~/ $ ghost empty [8:57:22]
zsh: correct 'ghost' to 'host' [nyae]? n
[Emptying] NameError: uninitialized constant Host
const_missing at org/jruby/RubyModule.java:2569
(root) at /local/dev/jruby/lib/ruby/gems/1.8/gems/ghost-0.2.8/bin/ghost:94
load at org/jruby/RubyKernel.java:1063
(root) at /local/dev/jruby/bin/ghost:19
Can't get ghost to work at all in the latest Lion update...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.