WPKG Multi sites

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
<package id="WpkgMultiSite" 
  name="WpkgMultiSite" 
  revision="0" 
  priority="10000" 
  execute="once">
       <install cmd='cscript \\10.31.31.31\export$\wpkg\WpkgMultiSite.vbs' />
</package>


WpkgMultiSite.vbs

  ' Wpkg multi site


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
set WshShell = CreateObject("WScript.Shell")
set oEnv=WshShell.Environment("System")
 
For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then 
        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
            'WScript.Echo IPConfig.IPAddress(i)
                mTab = Split(IPConfig.IPAddress(i), ".")
    			 
              	prefix =  mTab(0) & "." & mTab(1) 
				Select Case prefix
               'site 1 québec
         			Case "10.31"
			        	oEnv("SOFTWARE") = "\\10.31.31.31\export$\wpkg"
               'site 2 torento
				Case "10.40"
					oEnv("SOFTWARE") = "\\10.40.40.40\export$\wpkg"
               'site 3 montréal
				Case "10.41"
					oEnv("SOFTWARE") = "\\10.41.41.41\export$\wpkg"
               ' par default
				Case "else"
					oEnv("SOFTWARE") = "\\10.31.31.31\export$\wpkg"
				End Select
            
            
        Next
    End If
Next

'wscript.echo "Wpkg %SOFTWARE%: " & WshShell.Environment.item("SOFTWARE")


Specific variable depending on computer subnet

I personnaly use this kind of code in my package definition :

		<variable name="LOCAL_SOFTWARE"           value="%SOFTWARE%" />  <!-- DEFAULT SITE -->
		<variable name="LOCAL_SOFTWARE"           value="\\xxxxx-012\wpkg" 	ipaddresses="^192\.168\.5\.[0-9]+$" />  	<!-- SITE 1-->
		<variable name="LOCAL_SOFTWARE"           value="\\xxxxx-019\wpkg" 	ipaddresses="^192\.168\.6\.[0-9]+$" />  	<!-- SITE 2 -->

Then i can use this variable to define my %PKG_SOURCE% variable.

I suppose, but havn't tried that this can also be placed in the profile.xml for a more centralized way.

I doesn't override the SOFTWARE value because i only sync big files between sites which means that not every package is present in the local repository, some of them are only present on the main site...

Btw, i didn't found this myself, maybe i have read this in some mailing list, i don't remember anyways.