Great work on Quickstart! I was just looking at the code in quickstart.inc and thought this duplication detection script might help as I saw you had a 'fixme' in line 65. It works for me.

Cheers,
Crom

function quickstart_create_dns($domain, $params) {
  // FIXME detect duplicates
  $file = file_get_contents("/etc/hosts");
  if(!strpos($file, $domain)) {
    quickstart_shell_exec("echo '127.0.0.1 $domain #quickstart' | sudo tee -a /etc/hosts");
    echo "$file, $domain, strpos($file, $domain)";
  }else{
  echo "entry found...doing nothing";
  }  
}

Comments

Crom’s picture

Whoops, just noticed I left some duff code in...

function quickstart_create_dns($domain, $params) {
  // FIXME detect duplicates
  $file = file_get_contents("/etc/hosts");
  if(!strpos($file, $domain)) {
    quickstart_shell_exec("echo '127.0.0.1 $domain #quickstart' | sudo tee -a /etc/hosts");
  }else{
  echo "entry found...doing nothing";
  } 
}
MichaelCole’s picture

Sweet! Thanks!

Crom’s picture

Title: Quickstart.inc - dns duplicates » Quickstart.inc - dns and website duplicate detection

No problem...happy to help. I also wanted to put a check in where the script detects whether or not the website folder already exists. It doesn't exit very elegantly but here's the code in case it's useful - also with fancy yellow highlighting ;-)

This is for around line 207 of quickstart.inc (apologies for not making patch files but a bit pushed for time).

function quickstart_create_code($domain, $params) {
  $codepath = $params['codepath'];
  $makefile = $params['makefile'];

  if (file_exists($codepath)) {
    //TODO: put check here to ask whether to continue or not
    $ech = chr(27)."[1;33m"."Website already exists. $codepath will be moved to $codepath.old. Are you sure you want to do this?  Type 'yes' to continue: ".chr(27)."[0m";
    	echo $ech;
    $handle = fopen ("php://stdin","r");
    $line = fgets($handle);
    if(trim($line) != 'yes'){
      echo "ABORTING!\n";
      exit;
    }
    quickstart_shell_exec("mv $codepath $codepath.old");
    drush_log("Moved existing directory $codepath to $codepath.old", "ok");
  }
  if (!file_exists($makefile)) {
    // try to find makefile in ~/websites folder
    $makefile = quickstart_fixpath("$makefile");
    if (!file_exists($makefile)) throw new Exception("Makefile ". $makefile ." not found.");
  }

  drush_backend_invoke("make --prepare-install $makefile $codepath");
  drush_backend_invoke("quickstart-fixperms --domain=$domain --codepath=$codepath");
}
MichaelCole’s picture

Component: Code » Drush
mike stewart’s picture

Status: Active » Needs work

I need a patch. I will eventually do myself if no one else does first: http://drupal.org/project/quickstart/git-instructions (see section on patching)

mike stewart’s picture

Status: Needs work » Fixed

re-wrote DNS check based on #1. committed to 7.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.