GithubHelp home page GithubHelp logo

ghost's Introduction

Ghost

A gem that allows you to create, list, and modify local hostnames with ease in Linux and other Unix-based operating systems (more to come)...

Requirements

Unix-based OS (for now)

Intended Usage

This gem is designed primarily for web developers who need to add and modify hostnames to their system for virtual hosts on their local/remote web server. However, it could be of use to other people who would otherwise modify their /etc/hosts file manually and flush the cache.

Command

$ sudo ghost add mydevsite.local
  [Adding] mydevsite.local -> 127.0.0.1

$ sudo ghost add staging-server.local 67.207.136.164
  [Adding] staging-server.local -> 67.207.136.164

$ ghost list
Listing 2 host(s):
  mydevsite.local      -> 127.0.0.1
  staging-server.local -> 67.207.136.164

$ sudo ghost delete mydevsite.local
  [Deleting] mydevsite.local

$ sudo ghost delete_matching test
  [Deleting] test2.local
  [Deleting] test.local

$ ghost list
Listing 1 host(s):
  staging-server.local -> 67.207.136.164

$ sudo ghost modify staging-server.local 64.233.167.99
  [Modifying] staging-server.local -> 64.233.167.99

$ ghost list
Listing 1 host(s):
  staging-server.local -> 64.233.167.99

$ ghost export > some_file

$ ghost empty
  [Emptying] Done.

$ ghost list
Listing 0 host(s):

$ ghost import some_file
  [Adding] staging-server.local -> 64.233.167.99

$ ghost list
Listing 1 host(s):
  staging-server.local -> 64.233.167.99

With RVM, you need to add rvmsudo before the command:

$ rvmsudo ghost add mydevsite.local
  [Adding] mydevsite.local -> 127.0.0.1

Library

There is also a library that can be used in Ruby scripts. The ghost command is a wrapper for the library. View the source of bin/ghost to see how to use the library.

Installation

gem install ghost

Using sudo may be necessary in some circumstances, depending on your setup (for example, using the stock Ruby that comes on OS X).

Contributors

A list of contributors can be found here..

Legal Stuff

Copyright (c) 2008-2013 Bodaniel Jeanes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ghost's People

Contributors

benhoskings avatar bjeanes avatar coderanger avatar duncanbeevers avatar ev0rtex avatar extraordinaire avatar fcoury avatar finn avatar larsfronius avatar mgalv avatar mvr avatar outerim avatar radar avatar rhc2104 avatar sbeam avatar thedeveloper avatar turadg 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ghost's Issues

Allow Disabling Host Entries

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.

Subdomains?

Is it possible to configure a host with ghost to see the hosts' virtual hosts?

rewrite gem

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.

ghost-ssh doesn't recognize hosts not separated by a blank line.

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?

missing dependency: "unindent"

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)>'
...

`ghost list` needs sudo when using linux adapter

♪ 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...

Safari in 10.7-10.8 Lion not resolving DS hosts

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?

Multi line hosts entry fails in safari at 18 hosts

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.

"Host" is a collision-prone class name

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?

Mind releasing?

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?

Hosts have an N:N relationship with IPs

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...

NoMethodError in ghost-ssh list

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

"Cannot overwrite an existing entry" when trying to add a host as a non-root user

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.

<top (required)> undefined method "name" error

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>'

0.2.7 doesn't work under linux

trying to do a ghost add I get:
ghost:38: uninitialized constant SocketError (NameError)

(problem fixed in my fork: alkesh/ghost).

ghost clobbers multiple-hosts-per-line entries

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

update gem

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

Bust

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

NameError: uninitialized constant Host

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

delete matches against substrings

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?

`ghost-ssh list` produces "undefined method `length' for nil:NilClass"

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>'

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.