Archive for the ‘Linux’ Category

Keep Your Google Search Appliance Synced

Wednesday, April 9th, 2008

There have been a lot of people asking how they can keep their GSA synced. Here is quick, simple, and easily configurable solution that should help. Set this up as a CRON job and you’re done.

Requires: PHP, cURL

<?php
/**
* @author Chris Williams ctwilliams[at]gmail[dot]com
* @version 0.0.1
* @example php gsa-sync.php
*/

define(‘GSA_PATH’, ‘http://gsa.xyz.com:8000′); // Replace ‘http://…’ with your gsa host and port
define(‘GSA_USERNAME’, ‘user’); // Replace ‘user’ with your username
define(‘GSA_PASSWORD’, ’secret’); // Replace ‘password’ with your password

/** Define DB collections */
$dbSources = array(‘dbcollection1′, ‘dbcollection2′);

/** Go to log in prompt */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, GSA_PATH . ‘/EnterpriseController’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_COOKIEJAR, dirname(__FILE__).‘/cookie.txt’);
curl_exec($ch);

/** Authenticate */
curl_setopt($ch, CURLOPT_URL, GSA_PATH . ‘/EnterpriseController’);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,‘actionType=authenticateUser&userName=’ . GSA_USERNAME . ‘&password=’ . GSA_PASSWORD);
curl_exec($ch);

/** Loop through and trigger db sync for each collection in $dbSources */
if(is_array($dbSources)) {
foreach(
$dbSources as $source) {
curl_setopt($ch, CURLOPT_URL, GSA_PATH . ‘/EnterpriseController?actionType=syncDatabase&entryName=’ . $source);
curl_setopt($ch, CURLOPT_POST, false);
curl_exec($ch);
}
}

/** Close cURL connection */
curl_close($ch);

?>
Feedback and suggestions are appreciated… Enjoy!

Mount Remote Filesystems With SSHFS (Ubuntu)

Monday, March 3rd, 2008

SSHFS

For anyone that frequently accesses remote file systems or actively develops on remote servers, you may find this brief tutorial helpful.  SSHFS allows for mounting remote file systems over SSH.  For example you have a server, let’s call it foobar.com.  On this server you have your web root directory you want to access directly (/var/www/htdocs).  From your local machine you could simply go to /media/foobar.com and view the files contained on foosprinkle.com:/var/www/htdocs.  Here’s how…

Step 1:

$ sudo apt-get install sshfs

Note: It may fetch some dependencies.  This is okay.

Step 2:

Now go ahead and create a local directory for your mounted directory.  You’ll want permissions for that fresh directory so let’s do that as well.

$ sudo mkdir /media/foobar.com
$ sudo chown  yourusername /media/foobar.com

Step 3:

You are going to need to add your account to fuse group.  Not a problem, it’s simple.

$ sudo adduser yourusername fuse

Note: If you are running Ubuntu (perhaps others do this as well), you will need to logout and log back in.  For added security this is required in order for your system to recognize you in your newly added group.

Step 4:

$ sudo sshfs remoteusername@foobar.com:/var/www/htdocs /media/foobar.com

Note: You can easily unmount this drive by issuing yet another simple command :)

$ fusermount -u /media/foobar.com

Enjoy!

Bye Windoze! Welcome Ubuntu!

Friday, February 29th, 2008

Ubuntu Logo

 At work I spend 8 hours a day invested in one facet of web development or another.  I have been noticing that I spend less and less time working directly from my Windows box.  PuTTy is my BFF!  While working with Java based web services it’s not very practical, or good practice to be, developing on a Windows machine when ultimately it will be shipped over to Linux for production.  What is the point of developing through Windows when the target is *nix?  The sole reason I haven’t made the change prior is because much of the licensed software is for Windoze.  I’ve been giving it some thought and since any IDE or DBMS application that I need have a greater, or at very least an acceptable, *nix counterpart.  So today I popped in the Ubuntu install disk, kissed Windows goodbye, and am now looking forward to a more streamlined development approach.  Just in case I feel the need to play with DLL’s I have a Windows box with VNC that I can remote into :D