WPKG Multi sites

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
<package id="WpkgMultiSite" 
       <install cmd='cscript \\\export$\wpkg\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") = "\\\export$\wpkg"
               'site 2 torento
				Case "10.40"
					oEnv("SOFTWARE") = "\\\export$\wpkg"
               'site 3 montréal
				Case "10.41"
					oEnv("SOFTWARE") = "\\\export$\wpkg"
               ' par default
				Case "else"
					oEnv("SOFTWARE") = "\\\export$\wpkg"
				End Select
    End If

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

Specific variable depending on computer subnet[edit]

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.