Blame | Last modification | View Log | RSS feed
'=====================================================' Name: pkg_archive' Description: This library contains methods required' for dpkg_archive and deploy_archive' manipulation.'=====================================================Option ExplicitClass PkgArchive'================ Properties Declaration =============Private pRemote_HostPrivate pArchive_Path'==================== Properties =====================Public Property Let Remote_Host( SSrhost )pRemote_Host = SSrhostEnd PropertyPublic Property Let Archive_Path( SSarch_path )pArchive_Path = UnixPath(SSarch_path)End Property'====================== Methods ======================'-----------------------------------------------------------------------------------------------------------------Private Sub Get_Archive_Telnet_Login_Details ( outUser, outPassword )outUser = "releasem"outPassword = "releasem"End Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )outUser = "erg\releasem"outPassword = "releasem"End Sub'-----------------------------------------------------------------------------------------------------------------Function UnixPath( SSpath )If SSpath <> "" Then UnixPath = Replace( SSpath, "\", "/" )End Function'-----------------------------------------------------------------------------------------------------------------Sub Ensure_Read_Write ( SSpkg_name, SSpkg_version )Dim outMachine, outUser, outPasswordDim login_details, command, sysShell, oExec, outStrOut, outStrErrWScript.Echo "Allowing Read and Write on folder "& SSpkg_versionCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' Set all folders to +RWX and all files to +RW' --- Commands to run ---'command = _'"cd "& pArchive_Path &" && "&_'"chmod a+rwx "& SSpkg_name &"; "&_'"cd "& SSpkg_name &" && "&_'"find '"& SSpkg_version &"' -type d -exec chmod a+rwx {} \; ; "&_'"chmod -R a+rw "& SSpkg_version &"; "command = _"sudo ~/sbin/make_writable "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"WScript.Echo command' --- SSH client with login details ---'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPasswordlogin_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPassword'WScript.Echo login_details &" """& command &""""Set sysShell = WScript.CreateObject("WScript.Shell")sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True'Set oExec = sysShell.Exec( login_details &" "& command )'Set oExec = sysShell.Exec( login_details &" """& command &"""" )'outStrOut = oExec.StdOut.ReadAll'outStrErr = oExec.StdErr.ReadAll'If outStrErr <> "" Then' Call Raise_Event ( enumEVENT_ERROR, "[sub:Ensure_Read_Write]", _' "user: "& outUser & VBNewLine &_' "command: "& command , _' outStrErr, enum_RELEASE_NOTES_FAILED )'End If'Set oExec = NothingSet sysShell = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub All_Read_Only ( SSpkg_name, SSpkg_version )Dim outMachine, outUser, outPasswordDim login_details, command, sysShell, oExec, outStrOut, outStrErrCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' Set all folders from version folder, to -W and all files to -W' --- Commands to run ---'command = _'"cd "& pArchive_Path &"/"& SSpkg_name &" && "&_'"find '"& SSpkg_version &"' -type d -exec chmod a-w {} \; ; "&_'"chmod -R a-w "& SSpkg_version &"; "&_'"chown -R root:other "& SSpkg_version &"; "command = _"sudo ~/sbin/make_readonly "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"WScript.Echo command' --- SSH client with login details ---'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPasswordlogin_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPasswordSet sysShell = WScript.CreateObject("WScript.Shell")sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True'Set oExec = sysShell.Exec( login_details &" "& command )'outStrOut = oExec.StdOut.ReadAll'outStrErr = oExec.StdErr.ReadAll'If outStrErr <> "" Then' Call Raise_Event ( enumEVENT_ERROR, "[sub:All_Read_Only]", _' "user: "& outUser & VBNewLine &_' "command: "& command , _' outStrErr, enum_RELEASE_NOTES_FAILED )'End If'Set oExec = NothingSet sysShell = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Create_Doc_Folder ( SSpkg_name, SSpkg_version, docFolder )Dim outMachine, outDpkg_root, outUser, outPasswordDim login_details, command, sysShell, oExec, outStrOut, outStrErrCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' --- Commands to run ---' Creates doc folder if required with rwx permissions for allcommand = _"cd "& pArchive_Path &"/"& SSpkg_name &"/"& SSpkg_version &" && "&_"mkdir -p -m a+rwx "& docFolder &"; "WScript.Echo command' --- SSH client with login details ---'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPasswordlogin_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPasswordSet sysShell = WScript.CreateObject("WScript.Shell")sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True'Set oExec = sysShell.Exec( login_details &" """& command &"""" )'WScript.Echo "HERE:"& oExec'outStrOut = oExec.StdOut.ReadAll'outStrErr = oExec.StdErr.ReadAll'If outStrErr <> "" Then' Call Raise_Event ( enumEVENT_ERROR, "[sub:Create_Doc_Folder]", _' "user: "& outUser & VBNewLine &_' "command: "& command , _' outStrErr, enum_RELEASE_NOTES_FAILED )'End If'Set oExec = NothingSet sysShell = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Create_Pkg_Folder ( SSpkg_name, SSpkg_version )Dim outMachine, outDpkg_root, outUser, outPasswordDim login_details, command, sysShell, oExec, outStrOut, outStrErrCall Get_Archive_Telnet_Login_Details ( outUser, outPassword )' --- Commands to run ---' Creates pkg_name and pkg_version folder if required with rwx permissions for all'command = _'"cd "& pArchive_Path &" && "&_'"mkdir -p -m a+rwx "& SSpkg_name &"; "&_'"cd "& pArchive_Path &"/"& SSpkg_name &" && "&_'"mkdir -p -m a+rwx "& SSpkg_version &"; "command = _"sudo ~/sbin/make_pkgfolder "& pArchive_Path &" '"& SSpkg_name &"' '"& SSpkg_version &"';"WScript.Echo command' --- SSH client with login details ---'login_details = AppPath & SSH_EXE &" -ssh -batch "& outUser &"@"& pRemote_Host &" -pw "& outPasswordlogin_details = AppPath & WINRSH_EXE &" -q -h "& pRemote_Host &" -l "& outUser &" -p "& outPasswordSet sysShell = WScript.CreateObject("WScript.Shell")sysShell.Run "cmd.exe /c "& login_details &" """& command &"""", 0, True'Set oExec = sysShell.Exec( login_details &" "& command )'outStrOut = oExec.StdOut.ReadAll'outStrErr = oExec.StdErr.ReadAll'If outStrErr <> "" Then' Call Raise_Event ( enumEVENT_ERROR, "[sub:Create_Pkg_Folder]", _' "user: "& outUser & VBNewLine &_' "command: "& command , _' outStrErr, enum_RELEASE_NOTES_FAILED )'End If'Set oExec = NothingSet sysShell = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------Sub Map_Network_Drive ( SSunc, outMappedDrive )Dim outUser, outPasswordDim ValidDrivesARR, validDrive, UsedDrivesDim i, WshNetwork, oDrives, oFilesys, drvWScript.Echo "Mapping drive..."Call Get_Archive_Map_Drive_Login_Details ( outUser, outPassword )ValidDrivesARR = Array("E:","F:","G:","H:","I:","J:","K:","L:","M:","N:","O:","P:","Q:","R:","S:","T:","U:","V:","W:","X:","Y:","Z:")Set WshNetwork = WScript.CreateObject("WScript.Network")Set oDrives = WshNetwork.EnumNetworkDrives' Check for existing mapoutMappedDrive = ""For i = 0 to oDrives.Count - 1 Step 2' Reuse network map if existsIf UCase(oDrives.Item(i+1)) = UCase(SSunc) ThenoutMappedDrive = oDrives.Item(i)Exit ForEnd IfNextIf outMappedDrive = "" Then' Drive need to be mapped, hence map one.' Get all drive used drive letters.' NOTE: It will not display a drive if mapped but not connected.Set oFilesys = CreateObject("Scripting.FileSystemObject")Set oDrives = oFilesys.DrivesFor Each drv in oDrivesUsedDrives = UsedDrives &"|"& drv.DriveLetter &":|"NextFor Each validDrive In ValidDrivesARRIf NOT InStr( UCase(UsedDrives), "|"& UCase(validDrive) &"|") > 0 Then' used this unused driveOn Error Resume NextWshNetwork.MapNetworkDrive validDrive, SSunc, FALSE, outUser, outPasswordCall ErrorCheck ( "[sub:Map_Network_Drive]", _"used drives: "& UsedDrives & VBNewLine &_"valid letters to pick from: "& Join( ValidDrivesARR, ",") & VBNewLine &_"attempting to map: "& validDrive & VBNewLine &_"UNC: "& SSunc & VBNewLine &_"username: "& outUser )outMappedDrive = validDriveExit ForEnd IfNextEnd IfIf outMappedDrive = "" ThenCall Raise_Event ( enumEVENT_ERROR, "[sub:Map_Network_Drive]", _"used drives: "& UsedDrives & VBNewLine &_"valid drives to pick from: "& Join( ValidDrivesARR, ",") , _"Network drive is not mapped!", enum_RELEASE_NOTES_FAILED )End IfWScript.Echo "Using network drive: "& outMappedDriveSet oDrives = NothingSet WshNetwork = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------End Class