Abstract | UpDater is a "mirroring program" for the SREhttp/2 web servers. UpDater is used to update a set of files on a remote server (or on a client workstation) so that they are the same as a set of files on a central server. UpDater uses rsync and gzip to minimize bandwidth requirements, and is managed via a www-aware interface (using HTML forms). |
To minimize bandwidth requirements, UpDater uses GZIP and Rsync. Rsync is a differencing algorithim that is used to transmit only the fraction of a file that has changed, and GZIP is used to compress this fraction.
What is especially nice about RSYNC is that the central-server does NOT need to maintain old versions of files. Instead, the remote server sends a synopsis of an old version of a file, and the central server uses this synopsis to compute a difference file. Thus, one trades off processor utilization (the need to compute a synopsis, and to compute a difference given this synopsis) to lessen bandwidth requirements and to remove the need for the central server to maintain extensive archives of old versions.
UpDater has two components: a remote component, and the central component.
Central | The central component is installed on a
computer that maintains and distributes packages of files.
|
||
---|---|---|---|
remote |
The remote component is installed on a computer that needs to
recieve updates from a central server.
|
Technical notes |
|
UpDater and CGI-BIN | This version of UpDater is designed to work with the SREhttp/2 web server. If you are interested in using UpDater on other OS/2 web servers, you can use an earlier version (1.10), which can be found at http://www.srehttp.org/apps/updater/ |
UpDater is installed using an installation program named INSTALL.CMD.
C:>e: E:>cd temp E:\TEMP>install
After installing UpDater on a central and a remote server (or, on single machine if you want to test it out), you'll need to create a few files.
In particular:
If you will be using the "remote client" mode, you will also need to
Having completed the preceeding, you can run UpDater. It's easy to do:
if you are updating files on a remote server |
|
if you are using a remote client (say, to update files on your personal workstation): |
|
To define a package on a central server, you must create a package file. These are fairly simple, "mime-like" files; they must have an extension of .PKG, and they must be in the PACKAGE subdirectory of the UpDater directory (that you defined when you installed UpDater). For example, E:\SRE2003\SREHTTP2\ADDON\UPDATER\PACKAGE\SAMPLE.PKG.
A package file contains several entries, with each entry seperated by a blank line. Entries must begin with a "name:" (without the quotes), where name is one of the following:
title: -- the title of this package description: -- a longer description of this package privileges: -- required privileges (possibly *) include: -- files to include exclude: -- files to exclude no_encode: -- files for which content-encoding is suppresed cache: -- days to cache a package's "list of files" run: -- an installation program to run after updating encrypt: -- supported encryption methodsThe following alphabetical list describes these options in greater detail. The only required options are TITLE and INCLUDE.
Note: | If you do not want to limit access, you should NOT specify a privileges: entry. |
---|
run: /install.cmd run: epm PM READ.ME run: /bin/myinstall PM in\params.1 out\out.2Note that since EPM is NOT preceeded by a /, it will be run from the client's machine PATH.
;---------------------------------- ; example of a package file title: The srehttp/2 files description: This is the srehttp/2 distribution files, including a set of addons. privileges: * include: \ f:\srehttp\* \lib f:\srehttp\srf\* \addons\updater f:\srehttp\addons\updater\* /S \newstuff e:\work\dec99\* \htmls g:\users\*.htm* /s exclude: f:\srehttp\*.ZIP f:\addons\*.FAQ /S no_encode: f:\newstuf\*.zip /S f:\srehttp\*.GZ cache: 0.5 run: /install.cmd encrypt: blowfish des ; end of example ;----------------------------------Notes:
E:\SRE -- will contain F:\SREHTTP\* but excluding files that end with .ZIP. E:\SRE\LIB -- will contain F:\SREHTTP\SRF\*, but excluding files that end with .ZIP E:\SRE\ADDONS\UPDATER -- will contain F:\SREHTTP\ADDONS\UPDATER\* and it's subdirectories, but excluding files that end with .FAQ E:\SRE\NEWSTUFF --- will contain E:\WP\DEC99\*.* E:\SRE\HTMLS -- will contain G:\USES\*.HTM* (and files in subdirectories that match *.HTM*)Also, an SREHTTP.PKC "cache" file will be created if it doesn't exist. If it does exist, and is less then 12 hours old, it will be used (the central server will not regenerate a list of files in F:\SREHTTP, etc.)
Security note | This requirement for a list of accessible sites is largely for security reasons -- it limits the damage that an unauthorized user of UpDater can cause. |
---|
A SITELIST.IN file contains "mime-like" records, with each record containing several single-line entries, and with records seperated by blank lines.
This is a security option -- it prevents hackers from writing junk all over your machine (or, worse, causing files to be deleted). We recommend that these "root directories" be dedicated to the storage of these "packages", or that you exercise caution in who you grant UpDater access to.
Note that this username & password are not the username & password that the remote server may require. That is, the remote server may have access restrictions placed on using the remote server component (RUPDATER.CMD; restrictions that require a username & password that have nothing to do with the username & password required by a package on a central server.
In other words, the remote server component (RUPDATER.CMD) has two levels of access controls:
;======================================== ; This is a sample sitelist.in file for UpDater site: srehttp address: www.srehttp.org description: The SREHttp/2 home page root: e:\srehttp f:\srehttp site: cool_stuff address: www.invisible.net description: Wonderful stuff,but not for everyone username: mutwo password: xy321 root: g:\wonders\set1 ;========================================
To do this, you need to:
Step b is accomplished by modifying user specific privileges (see
SREhttp/2 USERS.HTM for the details).
Step C can be accomplished in one of several ways:
To tell UpDater how to use this software you must create an ENTRY. "stem" variable in UPDATER.CMD (the central server proram), and in UPCLIENT.CMD (the remote client program) and/or UPDAEMON.CMD (the remote server program).
ENCRYPT. variables should have the following format:
ENCRYPT.!METHOD=progname opt1 %in opt2 %out opt3 "%key" ... where: METHOD - the "method" (case-insensitive). progname - the program name opt1 .. - options understood by the program %in - a placeholder for the input file %out - a placeholder for the output file %key - a placeholder for the "key". This will replaced by the xxx in the ?UPDATER:xxx shared-secret. Examples: encrypt.!blowfish=e:\apps\bf -q -e %in %out "%key" could be used by the UPDATER.CMD to "encrypt", and encrypt.!blowfish=g:\bf -q -i %in %out "%key" could be used by UPCLIENT.CMD to "decrypt".
ENCRYPT.!METHOD=proc_name(arg1,%out,arg2,%in) where the ( must IMMEDIATELY follow the proc_name (no intervening spaces allowed). Otherwise, use arguments exactly as you would if you were calling this procedure from your own rexx program. For example: ENCRYPT.!MYWAY=encfast(%in,%out,%key,"q")
APPENDICES |
install.cmd -- The installation program. rxzlib.dll -- A dynamic link library used to gzip (requires EMX) rxrsync.dll -- A dynamic link library containing several useful procedures. sample.pkg -- A sample "package" file sitelist.smp -- A sample SITELIST.IN file updater.htm -- This documentation file updater.cmd -- The "central server" component rupdater.cmd -- The "client interface" portion of the remote server component updaemon.cmd -- The "daemon" portion of the "remote server" component upclient.cmd -- The Netscape helper app (that is used as a remote client). updateme.cmd -- Stand-alone "remote client" component
UPDATER_DIR: The UpDater directory (RUPDATER.CMD and UPDATER.CMD) This is where UpDater stores various files, and where UpDaemon.CMD is installed. Note that UPDATER.CMD and RUPDATER.CMD are installed to your SREhttp/2 addon directory. Examples: updater_dir='F:\UPDATER' updater_dir='' Notes * the second example means use the UPDATER sub-directory of the SREhptt/2 addon directory. * UPDATER_DIR (in RUPDATER.CMD and UPDATER.CMD) is set by the UpDater installation program. ADDCRC: Compute an Adler-32 value when constructing a package (UPDATER.CMD) The CRC-32 value is used by UpDater's "only update if contents have changed" option. If you do NOT enable ADDCRC, then this option will not work. Set ADDCRC=1 to enable, ADDCRC=0 to disable. Note that computation of an Adler-32 takes a bit of time, but not much (typically, less then a second per Mb of file). Example: addcrc=1 ALWAYS_USE_CACHE: Always use cache entry if it's current (UPDATER.CMD). In a few places, you can "request the latest version" (this causes a &nocache=1 option to be added to a request). If you do NOT want to allow clients to suppress the use of cached "list of files in a package", set ALWAYS_USE_CACHE=1. If you do want to allow this, set ALWAYS_USE_CACHE=0. BACK1: The "body background" (RUPDATER.CMD and UPDATER.CMD) BACK1 is used to set the background color (or image) used when UpDater communicates with client. Examples: back1='background="/imgs/web2.gif"' back1='bgcolor="#aa9933"' CanDoGZIP: Enable GZIP encoding (UPDATER.CMD, UPDAEMON.CMD, UPCLIENT.CMD and RUPDATER.CMD) Set this to 1 to enable GZIP encoding, 0 to disable. GZIP encoding takes a bit of CPU time, but can substantially reduce the size of a file (hence saving bandwidth). Note that, as currently built, the rxZlib library requires EMX 0.9d (emxrev should report 60 or above). You can get emx from http://hobbes.nmsu.edu (search for emxrt.zip). Example: candogzip=1 CanDoRsync: Enable RSync differencing (UPDATER.CMD, UPDAEMON.CMD, UPCLIENT.CMD, and RUPDATER.CMD) Set this to 1 to enable RSync differencing, 0 to disable. RSync differencing takes a bit of CPU time, but can substantially reduce the size of a file (hence saving bandwidth). Example: candorsync=1 Timeout: number of seconds to wait between socket calls (UPCLIENT.CMD and UPDAEMON.CMD) If a socket call takes longer then timeout seconds, then UpDater will give up on this file. Large values may be needed over very slow lines. Note that Timeout is NOT the total time required to get a file, it's the max seconds for each 1000 byte "sockrecv" call. Example: timeout=30 Use_abbrev: use numeric abbreviations If Use_abbrev=1, then numeric abbreviations are used to display files size (i.e.; 28K instead of 28126). Otherwise, the full number is display. Example: use_abbrev=1
Assuming this describes you, after downloading UpClient.CMD you should
Note that the INSTALL program will setup your central server with a page that describes how to install UpClient, and which contains links to UPCLIENT.CMD, RXRSYNC.DLL,and RXGZLIB.DLL.
Once UpClient is installed, you can use your browser to retrieve a package from a central server (that is running UpDater). After making the initial request (say, to /updater?), and selecting a few options, Netscape (or whatever browser you are using) will run UpClient.CMD in a seperate window. After asking a few more questions, UpClient.CMD will use tcp/ip socket calls to GET files and write them to your hard drive (and possibly run an installation program after all the files have been retrieved).
For details on rxRsync and rxZlib, see http://www.srehttp.org/apps/rxrsync/ and http://www.srehttp.org/apps/rxzlib/
To assist in such endeavours, the following lists the "options" understood by UPDATER.CMD, which is the "central server component" of UpDater. The remote components (RUPDATER.CMD, UPCLIENT.CMD,and UPDAEMON.CMD) will not be discussed -- the notion is that you'll be replacing these with your own tools!
As a "server side program" (running as an SREhttp/2 addon) one communicates with UPDATER.CMD by using web requests that contain options. Although there are several ways of defining options (such as through html forms), for illustrative purposes this documentation will assume that options appear after a request string.
action: An action to take. Recognized values are: display: Display a page describing the package that is identified by the package option. file1: Get a file from this package, and return it. Also requires that an entry option be defined. The file will be returned using one of the standard mime type (such as text/plain), or using a mime type of application/octet-stream (if the file's extension does not map to a common mimetype). file: Get a file from this package, and return it (possibly after GZIP compression and RSYNC differencing). Also requires that entry option be defined. The file will be returned with a mimetype of application/x-updater. Ax x-updater response header is added, that may contain several values (described below). getl: Return a list of all the files in the package. This list is described below. An x-updater response header is also returned. You can examine this for "GZIP" and "RSYNC" entries -- they signify that the server can handle GZIP and RSYNC. getl2: Return an html form used by a client to specify where/how to update. Upon submitting this form, UpClient will be called and will be passed a list of files in the package. upclientdoc: display a page that describes the UpClient helper app. Note: the "GETL3" and "GETL4" actions can be used to obtain specific files (and "sections") from a package -- contact the author for details. ashtml: When an ashtml=1 option is specified in combination with a action=GETL, then the "list of files" will be returned as an html page containing "action=file1" links to the various files in the package. In addition, when ashtml=1 is specified with a package=!list option, then the "list of packages" will be returned as an html page containing "action=display" links to the various packages on the server. client: Used with action=getl. When client=1, this request is from a "remote" client. This has two effects: i) updater will check for some options (destination directory and possibly username/password), and return an error message if they have not been specified. ii) if ashtm<>1, some extra information will be added to the "list of files" header (see below for the details) encrypt: A comma delimited list of encryption methods that the client supports. This should be a subset of the server supported methods (as specified in the ENCRYPT option in the "list of files", described in section 4.b.ii). Note: the capitalized shared-secret used by the central-server to encrypt the file is pulled from an ?UPDATER:shared_secret "secret privilege". It is your responsibility to know what this value is (UpDater does NOT use public-key codes or other SSL-like mechanisms). entry: The "entry number" in the package. The entry number is basically the index into the list of "root directory\ies" specified in the .PKG file of the specified package. It is combined with a file option to define a particular file. Example: entry=1 file: A filename; which may contain subdirectory information. The actual file this refers to will depend on the value of the entry (and package) options -- the filename is relative to the subdirectory identified bye the entry option. Examples: file=foo.bar foo=/programs/math/calc.exe getuser: When getuser=1, and client=1, and action=GETL, then updater will check that a username and pwd options have been specified. gzip If gzip=1, then "use gzip, if possible, to compress the response" md4: A 32 hex character MD4 hash of an old version of a requested file. If the md4 of the requested file matches this md4 value, then a "304 not modified" response will be generated. nocache: If nocache=1, and action=getl, then do NOT return a cached version of the "list of files". This is ignored if ALWAYS_USE_CACHE=1 is set in user configurable parameters section of UPDATER.CMD. package: Specifies the name of a package on the central server. Packages are specified in .PKG files in \PACKAGE subdirectory of the UPDATER directory. See section III (above) for details on package files This is an important option, almost all the other options refer to actions to take using this package. Example: package=sample package=my_package package=!list Note: do NOT included the ,PKG in the value The last example, value=!list, is used to return "list of packages". See Appendix 4b for the details. rsync: If rsync=1, then "use rsync, if possible, to shorten the response". This MUST be combined with an "rsync-signature_updater" request header that contains the "rsync synopsis" of a "prior version" of the requested file. send: Transfer a file in (or under) the updater directory. This is currently used by the UpClient helper app page to allow clients to obtain the upclient.cmd (and other files). The syntax is: UPDATER.DOC, RXZLIB.DLL, GZIP.EXE, RXRSYNC.DLL, UPCLIENT.CMD To add files to this list, you should change the SEND_FILES parameter in UPDATER>CMD. Examples: send=upclient.cmd send=morefile\help.doc Note: SEND could have been specified using "action=SEND&file=filename". However, since these files (in the updater directory) are NOT identified with a "package" or "entry" option, we decided to use a seperate option. text: When text=1, and a send option is specified, then transfer the file as a text/plain mimetype. backupdir dodelete check quiet dorun: These options are used when action=getl and client=1 (and asthml<>1). They control what extra "remote client" specific information is added to the "list of files header". For example, UpClient uses the values: backupdir: the relative location of a backup directory dodelete: 1 (used to signal "delete all orphaned files from destination directory" check: 0,1,2 or 3. The time of "check" to do before requesting the file. 0=none, 1=time, 2=crc32, 3=add an md4 option quiet: 1 (non-verbose reporting in UpClient) dorun: Name of an "installation" program
When package=!list, then a "list of packages" is returned. You can then use this list to choose a package for use in later requests to UPDATER.CMD. The format of this list is: n yyyy/mm/dd/hr/min Name1 title 1 ... yyyy/mm/dd/hr/min NameNthg title nth where: yyyy/mm/nn/dd/hh = timestamp (last revision of package file) name1 ... nameNth = name of the package title = a short, mutli word, description of the package Example: 4 1999/12/10/02/29 sample This is a sample package file 1999/12/10/00/17 SREHTTP The SREHttp/2 package 1999/11/23/21/14 ZIPFIP The ZIPFIP package Note that the timestamp refers to the .PKG file, and NOT to files that may be referenced by the .PKG file.
header_line yyyy/mm/dd/hr/min entry File1 relDir no_encode crc32where:
yyyy/mm/nn/dd/hh = timestamp (last revision of package file) entry = entry number (index into the .PKG file) file1 ... fileN = name of file in this package relDir = relative directory to copy file to This is typically relative to a root directory that you provide no_encode = Hint to not attempt to encode this file (RSYNC and GZIP should not be attempted) crc32 = Adler-32 checksum (can be used to see if file has changed) Note that an md4 checksum is NOT send as part of this "list of files"The header line has the format:
var=value var1=value var2=valueThat is, each var=value pair is seperated by a space. Recognized variables are:
package = required -- the package this file belongs to server = requird -- ip address that this package is on selector = recommended -- the "resource", on this server, that will process UpDater requests. GZIP = optional. If GZIP=1, then the server knows GZIP RSYNC = optional. If RSYNC=1, then the server knows RSYNC CREATED = Timestamp, when this "list of packages" was created. Format is basedate.decimal_fraction_of_a_day PKG_DATE = Timestamp, when this .PKG file was last modified. CURRENT_TIME = Timestamp, when this "list of files" was sent. Note that CURRENT_TIME is ONLY used when this is a cached "list of files". CURRENT_TIME will always be greater then or equal to CREATED. ENCRYPT = A comma delimited list of encryption methods supported by this server (for this package).Example:
Package=sample Server=localhost CREATED=730101.92986 PKG_DATE=730097.1035 GZIP=1 RSYNC=1 CURRENT_TIME=730102.02361 ENCRYPT=BLOWFISH,DES SELECTOR=UPDATER 1999/07/20/20/56 1 /ACCESCFG.CMD / 0 652FD5DA 1999/11/11/14/33 1 /ACCESCHK.RXX / 0 A2D10DAA 1999/06/19/10/30 1 /access.cnt / 0 45DD05E8 1999/06/13/16/14 1 /access.in / 0 A69D859ENote that the "header line" should be on one long line (in the above example, it is split for readability sake).
Content-type: application/x-updater X-updater: alistIt may also have,
Content-encoding: alist X-NotMod: 1X-updater: Xupdater takes a comma delimited list of case-insensitive options.
The important options are: DIR=/rel_dir MD4=md4_value ERROR where rel_dir is a "relative directory": it can be used instead of the "relDIR" specified in the list of files. md4_value is a 32 hex character md4 value. It is only included when an RSYNC has been used. As an error check, this value should be compared against the MD4 value of reconstructed file. ERROR takes no value -- it signals that "an error occurred" Examples: X-updater: dir=/sub1 X-updater: dir=/home/particles,md4=3234a67abdf2f456ca90155156789012 X-updater: dir=/secure/stuff1,encryt=blowfishContent-encoding: Content-encoding takes a comma delimited list of case-insensitive "content-encodings".
UpDater supports three kinds of content-encodings: GZIP, RSYNC, and ENCRYPT=method.
Note that the order of appearance of these content-encodings is the reverse order of their application --- you should do the last one first. For example,
Content-encoding:rsync,gzip,encrypt=method1 means ENCRYPT=method1 -- first deencrypt, using the encryption "method1" GZIP -- then inflate (de-compress) it RSYNC -- then apply this "GDIFF" difference file to the old file Examples: Content-encoding: gzip Content-encoding: rsync,gzip Content-encoding: gzip,Encrypt=blowfish
You may use this (or subsets of this) program as you see fit, including for commercial purposes; so long as proper attribution is made, and so long as such use does not in any way preclude others from making use of this code.