Difference between revisions of "Heise Offline-Update"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(Heise website changed domain name, possibly ownership?)
(Cleaned up links and some information, and added ctcheck.js)
Line 1: Line 1:
Silent installer for Heise Offline-Update.
+
Silent installer for WSUS Offline Update. This software installs the latest Security Updates and Service Packs for Windows and Office
  
Download the [http://www.h-online.com/security/Offline-Update--/features/112953] scripts.  Run the downloader and select the products you want updates for.  One note: if you're using the [http://wpkg.org/MS_Office_2007_Compatibility_Pack Compatibility Pack for the 2007 Office System] then download the updates for Office 2007.  Those patch the Compatibility Pack as well as Office 2007.
+
Download the [http://download.wsusoffline.net] scripts.  Run the downloader and select the products you want updates for.  One note: if you're using the [http://wpkg.org/MS_Office_2007_Compatibility_Pack Compatibility Pack for the 2007 Office System] then download the updates for Office 2007.  Those patch the Compatibility Pack as well as Office 2007.
  
 
Once all of the downloads are complete copy the contents of the "client" folder to your server.  These scripts assume the share name is "offlineupdate" and the server name is "ntinstall".  You also need "rm.exe" and "mkdir.exe" from [http://gnuwin32.sourceforge.net/packages/coreutils.htm GnuWin32] in your "tools" folder.
 
Once all of the downloads are complete copy the contents of the "client" folder to your server.  These scripts assume the share name is "offlineupdate" and the server name is "ntinstall".  You also need "rm.exe" and "mkdir.exe" from [http://gnuwin32.sourceforge.net/packages/coreutils.htm GnuWin32] in your "tools" folder.
Line 22: Line 22:
  
 
<install cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
 
<install cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
         <install cmd='"%SOFTWARE%\ctcheck.exe"' />
+
         <install cmd='cscript "%SOFTWARE%\ctcheck.js"' />
 
<upgrade cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
 
<upgrade cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
         <upgrade cmd='"%SOFTWARE%\ctcheck.exe"' />  
+
         <upgrade cmd='cscript "%SOFTWARE%\ctcheck.js"' />  
 
<remove cmd='cmd /c %WPKGROOT%\tools\rm.exe -f "%SystemDrive%\netinst\wpkg\ctupdate.done"' />
 
<remove cmd='cmd /c %WPKGROOT%\tools\rm.exe -f "%SystemDrive%\netinst\wpkg\ctupdate.done"' />
  
Line 37: Line 37:
  
 
:: Make sure that the log directly exists and is hidden
 
:: Make sure that the log directly exists and is hidden
%WPKGROOT%\tools\mkdir.exe -p %SystemDrive%\netinst\wpkg
+
mkdir -p %SystemDrive%\netinst\wpkg
 
attrib +H %SystemDrive%\netinst
 
attrib +H %SystemDrive%\netinst
 
+
 
:: Update the system and log it
 
:: Update the system and log it
pushd \\ntinstall\offlineupdate
+
pushd %WPKGROOT%\wsusoffline\client
cmd /c cmd\DoUpdate.cmd >%SystemDrive%\netinst\wpkg\offlineupdate.log
+
cmd /c cmd\DoUpdate.cmd /instie8 >%SystemDrive%\netinst\wpkg\offlineupdate.log
popd \\ntinstall\offlineupdate
+
popd %WPKGROOT%\wsusoffline\client
 
date /T >%SystemDrive%\netinst\wpkg\ctupdate.done
 
date /T >%SystemDrive%\netinst\wpkg\ctupdate.done
 
</source>
 
</source>
  
Delphi source code for ctcheck.exe (ctcheck.dpr):
 
  
 +
cscript.js:
 +
<source lang="javascript">
 +
//delete ctupdate.done if a reboot is scheduled
 +
 +
var WshShell = WScript.CreateObject("WScript.Shell");
 +
var fso = WScript.CreateObject("Scripting.FileSystemObject");
 +
 +
var ForReading = 1;
 +
var BasePath = WshShell.ExpandEnvironmentStrings("%SystemDrive%\\netinst\\wpkg\\");
 +
var LogFilePath = BasePath + 'offlineupdate.log';
 +
var CtupdatePath = BasePath + 'ctupdate.done';
 +
var LastLine = '';
 +
 +
String.prototype.trim = function() {  return this.replace(/^\s+|\s+$/g, '');  }
 +
 +
try {
 +
  var f = fso.OpenTextFile(LogFilePath, ForReading);
 +
 
 +
  while (!f.AtEndOfStream) {
 +
    var r = f.ReadLine();
 +
   
 +
    //ignore last lines that are blank
 +
    if (r.trim() != '') {
 +
      LastLine = r;
 +
    }
 +
  }
 +
  if (LastLine.search(/reboot/i) != -1) {
 +
    fso.DeleteFile(CtupdatePath,true);
 +
  }
 +
}
 +
catch (e)
 +
{
 +
  WScript.Quit(1);
 +
}
 +
 +
</source>
 +
 +
 +
Delphi source code for ctcheck.exe (ctcheck.dpr)(from previous version):
 
<source lang="pascal">
 
<source lang="pascal">
 
program ctcheck;
 
program ctcheck;
 
{$APPTYPE CONSOLE}
 
{$APPTYPE CONSOLE}
 
{
 
{
   This program loads the ctupdate log file, then checks for the word "recall" in the last non-empty line.
+
   This program loads the ctupdate log file, then checks for the word "reboot" in the last non-empty line.
 
   If the word "recall" is found it then deletes the "ctupdate.done" file, so that wpkg will run ctupdate again.
 
   If the word "recall" is found it then deletes the "ctupdate.done" file, so that wpkg will run ctupdate again.
 
}
 
}
Line 89: Line 127:
 
       begin
 
       begin
 
       s := sl[sl.Count -1];
 
       s := sl[sl.Count -1];
       if(AnsiPos('recall', LowerCase(s)) > 0)
+
       if(AnsiPos('reboot', LowerCase(s)) > 0)
 
       then
 
       then
 
       begin
 
       begin

Revision as of 12:22, 25 October 2009

Silent installer for WSUS Offline Update. This software installs the latest Security Updates and Service Packs for Windows and Office

Download the [1] scripts. Run the downloader and select the products you want updates for. One note: if you're using the Compatibility Pack for the 2007 Office System then download the updates for Office 2007. Those patch the Compatibility Pack as well as Office 2007.

Once all of the downloads are complete copy the contents of the "client" folder to your server. These scripts assume the share name is "offlineupdate" and the server name is "ntinstall". You also need "rm.exe" and "mkdir.exe" from GnuWin32 in your "tools" folder.

Note: I increment the revision each Patch Tuesday. If you want this to run every time wpkg is run add 'execute="always"' to the package tag and disable the reboot.

offlineupdate.xml:

<?xml version="1.0" encoding="UTF-8"?>
<packages>
<package
	id="offlineupdate"
	name="offlineupdate"
	revision="200805131"
	reboot="true"
	priority="0">

	<check type="file" condition="exists" path="%SystemDrive%\netinst\wpkg\ctupdate.done" />

	<install cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
        <install cmd='cscript "%SOFTWARE%\ctcheck.js"' />
	<upgrade cmd='cmd /c %WPKGROOT%\scripts\offlineupdate.cmd' />
        <upgrade cmd='cscript "%SOFTWARE%\ctcheck.js"' /> 
	<remove cmd='cmd /c %WPKGROOT%\tools\rm.exe -f "%SystemDrive%\netinst\wpkg\ctupdate.done"' />

</package>
</packages>

offlineupdate.cmd:

@echo off

:: Make sure that the log directly exists and is hidden
mkdir -p %SystemDrive%\netinst\wpkg
attrib +H %SystemDrive%\netinst
 
:: Update the system and log it
pushd %WPKGROOT%\wsusoffline\client
cmd /c cmd\DoUpdate.cmd /instie8 >%SystemDrive%\netinst\wpkg\offlineupdate.log
popd %WPKGROOT%\wsusoffline\client
date /T >%SystemDrive%\netinst\wpkg\ctupdate.done


cscript.js:

//delete ctupdate.done if a reboot is scheduled

var WshShell = WScript.CreateObject("WScript.Shell");
var fso = WScript.CreateObject("Scripting.FileSystemObject");

var ForReading = 1;
var BasePath = WshShell.ExpandEnvironmentStrings("%SystemDrive%\\netinst\\wpkg\\");
var LogFilePath = BasePath + 'offlineupdate.log';
var CtupdatePath = BasePath + 'ctupdate.done';
var LastLine = '';

String.prototype.trim = function() {  return this.replace(/^\s+|\s+$/g, '');  }

try {
  var f = fso.OpenTextFile(LogFilePath, ForReading);
   
  while (!f.AtEndOfStream) {
    var r = f.ReadLine();
    
    //ignore last lines that are blank
    if (r.trim() != '') {
      LastLine = r;
    } 
  }
  if (LastLine.search(/reboot/i) != -1) {
    fso.DeleteFile(CtupdatePath,true);
  }
}
catch (e)
{
  WScript.Quit(1);
}


Delphi source code for ctcheck.exe (ctcheck.dpr)(from previous version):

program ctcheck;
{$APPTYPE CONSOLE}
{
  This program loads the ctupdate log file, then checks for the word "reboot" in the last non-empty line.
  If the word "recall" is found it then deletes the "ctupdate.done" file, so that wpkg will run ctupdate again.
}
uses Windows,classes,sysutils;

function GetDrv(): string;
const
 s = 'SYSTEMDRIVE';
var
  BufSize: Integer; 
begin
  BufSize := GetEnvironmentVariable(PChar(s), nil, 0);
  if BufSize > 0 then
  begin
    SetLength(Result, BufSize - 1);
    GetEnvironmentVariable(PChar(s),
      PChar(Result), BufSize);
  end
  else
    Result := '';
end;

var
s:String;
fpath:String;
sl:TStringList;
begin
   sl := TStringList.Create;
   try
      fpath := getDrv() + '\netinst\wpkg\';
      sl.LoadFromFile(fpath + 'offlineupdate.log');
      while(sl.Count > 0) and(trim(sl[sl.Count -1]) = '')do
       sl.Delete(sl.Count -1);
      if(sl.Count > 0) then
      begin
       s := sl[sl.Count -1];
       if(AnsiPos('reboot', LowerCase(s)) > 0)
       then
       begin
          if not(DeleteFile( fpath + 'ctupdate.done')) then Halt(1);
       end;
      end
      else Halt(1);
   except
   end;
   sl.Free;
end.


Older solution without an exe file:

CTUpdate is an alternative method for applying Windows and Office hotfixes and service packs. It consists of two parts:

  1. A program to automatically queries and downloads the latest packages into a repository.
  2. A program that reads the repository and applies any updates to the local machine.

Download it here: http://www.heise.de/ct/projekte/offlineupdate/download_uk.shtml

Note 1: CTUpdate cannot be run from a non-mapped drive, so make sure you map your repository first. The bat-file below expects %WPKG_DRIVE% to be set to this drive. Alternatively, you can modify the bat-file to temporarily map the drive. (net use x: \\ntinstall\wpkg /PERSISTENT:no)

Then run it in order to create a repository containing the languages and systems you want, but you do NOT need to create ISO files. The repository will be placed in the client subfolder. Then copy the entire tree over to the WPKG software folder and use the following entries:

<package id="ctupdate" name="Windows and Office hotfixes and service packs" revision="0" reboot="true" priority="0">
  <!--
  The bat-file touches a statefile after each successful run.
  
  Increment revision each time the CTUpdate repository is updated, and it will be run
  again by wpkg and figure out what needs to updated itself.
  
  Prioritize below Office, as Office is updated by this as well.
  
  The uninstall simply removes the statefile - we don't provide for uninstalls of
  patches, however one might want to reinstall the package in order to rerun it.

  See ctupdate4\client\cmd\doupdate.cmd for other possible flags (IE7 install etc.)
  -->
   <check type="file" condition="exists" path="%windir%\ctupdate.done" /> 
   <install cmd='cmd /c "%SOFTWARE%\ctupdate4\runwpkg.bat" /nobackup' />

   <upgrade cmd='cmd /c "%SOFTWARE%\ctupdate4\runwpkg.bat" /nobackup' />
   <remove cmd='cmd /c del %windir%\ctupdate.done'/>

</package>

The referenced bat-file:

%WPKG_DRIVE%
cd %SOFTWARE%\ctupdate4\client\cmd
del %windir%\ctupdate.done
cmd /c doupdate.cmd %*

For proper reboot cycles you will need to add a line to ctupdate4/client/cmd/DoUpdate.cmd. See diff: (make sure you don't add it to the SuggestRecall part)

--- C:/Users/Kalmi/Desktop/DoUpdate.cmd	Sat Sep 13 19:41:10 2008
+++ G:/wpkg/software/ctupdate4/client/cmd/DoUpdate.cmd	Sat Jan 31 21:57:03 2009
@@ -736,6 +736,7 @@
 echo Installation successful. Please reboot your system now.
 echo %DATE% %TIME% - Info: Installation successful >>%UPDATE_LOGFILE%
 echo.
+date /T > %windir%\ctupdate.done
 goto EoF
 
 :Cleanup

This will ensure that wpkg will only consider the install successful when ctupdate ends up in InstSuccess (and not in SuggestRecall). So if a restart is needed wpkg will restart(saying the the install failed, but it requires a resart, so I'm going to restart now) and try the install again...