Triggering to affect archiving
The archive trigger type is used in conjunction with the
+X filetype modifier to replace the mechanism by
which the
Helix Core Server
archives files within the repository. Archive triggers are used for storing,
managing, or generating content archived outside of the
Helix Core Server
repository. See
Execution environment
for platform-specific considerations.
The following table describes the fields of an archive trigger definition:
| Field | Meaning |
|---|---|
|
|
The name of the trigger. |
|
|
archive: Execute the script when a user accesses
any file with a filetype containing the The script is run once per file requested. For |
|
|
A file pattern to match the name of the file being accessed in the archive. |
|
|
The trigger for the
Helix Core Server
to run when a file matching Specify the command in a way that allows the
Helix Core Server
account to locate and run the command. The
When your trigger script is stored in the depot, its path must
be specified in depot syntax, delimited by percent characters.
For example, if your script is stored in the depot as
If the command succeeds, the command’s standard output is the file content. If the command fails, the command standard output is sent to the client as the text of a trigger failure error message. |
Example
This archive trigger fires when users access files that
have the +X (archive) modifier set.
#!/bin/sh
# archive.sh - illustrate archive trigger
OP=$1
FILE=$2
REV=$3
if [ "$OP" = read ]
then
cat ${FILE}${REV}
fi
if [ "$OP" = delete ]
then
rm ${FILE}${REV}
fi
if [ "$OP" = write ]
then
# Create new file from user's submission via stdin
while read LINE; do
echo ${LINE} >> ${FILE}${REV}
done
ls -t ${FILE}* |
{
read first; read second;
cmp -s $first $second
if [ $? -eq 0 ]
then
# Files identical, remove file, replace with symlink.
rm ${FILE}${REV}
ln -s $second $first
fi
}
fi
To use the trigger, add the following line to the trigger table:
arch archive path "archive.sh %op% %file% %rev%"
When the user attempts to submit (write) a file of type
+X in the specified path, if there are
no changes between the current revision and the previous revision, the
current revision is replaced with a symlink pointing to the previous
revision.






