[wpkg-users] multiple vpn locations, a quick & dirty solution

Frank Zimmer Frank.Zimmer at Zimmer-GmbH.de
Mon Feb 19 10:50:22 CET 2007


Hello

I played around a little and found a solution on how to install from
different servers in different subnets without dns aliases. Its a very dirty
hack pls excuse, but i needed to roll out some packages last weekend ;-) 
The idea is to set a installation server based on the ip of the default
gateway, maybe someone else finds it usefull too. Just copy & paste in at
the start of the exec() funktion of wpkg.js:

[...]
/**
 * Executes a shell command and blocks until it is completed, returns the
 * program's exit code. Command times out and is terminated after the
 * specified number of seconds.
 */
function exec(cmd, timeout) {

   var wbemFlagReturnImmediately = 0x10;
   var wbemFlagForwardOnly = 0x20;
   var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
   var colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration", "WQL", wbemFlagReturnImmediately |
wbemFlagForwardOnly);
   var myIP
   var myInstallServer = "myserver1"; //default server
   var subnetmatch1 = /^192\.1\./g;
   var subnetmatch2 = /^192\.2\./g;
   var subnetmatch3 = /^192\.3\./g;
   var re = /REPLACETHIS/g     //the string that will be replaced from the
installation command
   
   var enumItems = new Enumerator(colItems);
   for (; !enumItems.atEnd(); enumItems.moveNext()) {
      var objItem = enumItems.item();
	
	try {myIP = objItem.DefaultIPGateway.toArray().join(",");
    		if (subnetmatch1.test(myIP))
    			myInstallServer = "myserver1";
    		if (subnetmatch2.test(myIP))
    			myInstallServer = "myserver2";
    		if (subnetmatch3.test(myIP))
    			myInstallServer = "myserver3";
	    }
	catch(E) {}; 
   }
   
  cmd = cmd.replace(re, myInstallServer);
[...]

The install command in the package has to look like this:

<install cmd='\\REPLACETHIS\wpkg\packages\somepackage\somesetup.exe /silent'
/>

And the directory strukture has to be the same on all servers ofc.

-- 
mfg
  Frank Zimmer

Zimmer GmbH
Technische Werkstätten
Im Salmenkopf 5
77866 Rheinau-Freistett
http://www.zimmer-gmbh.de
http://www.sommer-automatic.de
fon  : +49-7844-9138-0
fax  : +49-7844-9138-35700






VDEV
_______________________________________________
wpkg-users mailing list
wpkg-users at lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users



More information about the wpkg-users mailing list