Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

http://live.julik.nl

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Create virtual host entries in your NetInfo hosts database

This will generate entries for every folder in your /Sites folder so that you can address your local machine as client1.box, client2.box etc. "box' in this case is the name you give the machine in the "Sharing" prefpane. Very convenient for rapid multisite work.

ATTN: this is OS X only but you can refactor it to work on *X.

   1  
   2  #!/usr/bin/env ruby
   3  SitesDir = '/Sites'
   4  DomainSuffix = `hostname`.gsub('.local', '').downcase.gsub(/\s/, '')
   5  
   6  ###############################################
   7  `nidump hosts .`.split("\n").uniq.sort.each do | dir |
   8    next unless (dir.split('.').pop == DomainSuffix)
   9    host = dir.split("\t").pop
  10    cmd = `niutil -destroy . /machines/#{host}`
  11  end
  12  
  13  Dir.entries(SitesDir).each do | entry |
  14    next if (!File.stat("#{SitesDir}/#{entry}").directory? || entry == '.' || entry == '..')
  15    puts "> Adding website #{entry}.#{DomainSuffix}"
  16    `niutil -create . /machines/#{entry}.#{DomainSuffix}`
  17    `niutil -createprop . /machines/#{entry}.#{DomainSuffix} ip_address 127.0.0.1`
  18  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS