--- cups-x2go.orig	2010-03-09 09:16:28.000000000 +0000
+++ cups-x2go	2010-04-06 11:36:58.566761342 +0000
@@ -26,6 +26,12 @@
 my $x2goserver = "local";
 my $printdsa = "/root/.x2go/ssh/.x2goprint/id_dsa";
 my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f \"%s\"";
+my $multiserver=0;
+my $dbhost = "localhost";
+my $dbuser = "postgres";
+my $dbname = "x2go_sessions";
+my $dbschema = "";
+my $dbtable = "sessions";
 my $cfgfile="/etc/cups/cups-x2go.conf";
 my $userName;
 my @sessions;
@@ -60,8 +66,43 @@
          {
              $ps2pdf=$value;
          }
+         if($option eq "multiserver")
+         {
+           $multiserver = $value;
+         }
+         if($option eq "dbhost")
+         {
+           $dbhost=$value;
+         }
+         if($option eq "dbuser")
+         {
+           $dbuser=$value;
+         }
+         if($option eq "dbname")
+         {
+           $dbname=$value;
+         }
+         if($option eq "dbschema")
+         {
+           $dbschema=$value;
+           if($dbschema ne "")
+           {
+             $dbschema="$dbschema.";
+           } 
+         }
+         if($option eq "dbtable")
+         {
+           $dbtable=$value;
+         }         
      }
      close(CFG);
+     if ($multiserver)
+     {
+       $x2goserver=`echo "select server from $dbschema$dbtable where uname='$userName' limit 1" | psql -U $dbuser -h $dbhost -t $dbname`;
+       chomp($x2goserver);
+       chomp($x2goserver);
+       $x2goserver=~s/ //g;
+     }
  }
 }
 
@@ -119,7 +160,6 @@
     print STDERR "ERROR: Usage: cups-x2go job-id user title copies options [file]\n";
     exit 1;
 }
-
 my $jobID;
 my $jobTitle;
 my $copies;
@@ -128,7 +168,6 @@
 
 ($jobID, $userName, $jobTitle, $copies, $printOptions, $printFile) =  @ARGV;
 
-
 my $tempFile;
 if (!$printFile) 
 { 
