3 ##############################################################################
4 # Moves nightly build files from the uploads directory to the download
5 # directory. Checks the integrity of files before moving, so incomplete or
6 # broken files are not available for download.
8 #-- Configuration & Setup ----------------------------------------------------
9 ROOT
=/home
/groups
/a
/ar
/aros
10 SRC
=$ROOT/uploads
/nightly
11 DST
=$ROOT/htdocs
/downloads
/nightly
16 #-- Support Functions --------------------------------------------------------
20 # Checks the MD5 sum of the given file. Will return failure if the MD5 sum
21 # is incorrect, the file is missing, or the MD5 sum file is missing.
23 # The MD5 sum must be stored in a separate file with the same name as the
24 # file to be tested, with ".md5" appended. Eg., if the file is "foo.txt",
25 # then the MD5 sum must be stored in "foo.txt.md5". The format of the file
26 # is that of the output from the GNU md5sum command.
29 # $1 - path of file to check.
32 # $? - 0 if file is OK, !0 if FAILED.
36 md5sum -c "$(basename $1).md5" >/dev
/null
2>&1; rc
=$?
42 #-- Acquire Lock -------------------------------------------------------------
44 if [[ $?
!= 0 ]]; then
45 echo Could not acquire lock. Aborting...
49 #-- Process Pending Files ----------------------------------------------------
53 for file in $
(find .
-type f
-not -name "*.md5" -printf "%p;"); do
54 if [ ! -z "$file" ]; then
59 dst
="$DST/$(dirname $file)"
62 if [ "${file:${#file}-4:4}" = ".xml" ]; then
63 cl
="$(basename ${file:0:${#file}-4})"
64 xsltproc
-o $dst/$cl.php
--stringparam date ${cl:5:8} --stringparam module
${cl:24} $ROOT/scripts
/cl2html.xslt
"$file"
72 mv -f "$file.md5" $dst
81 #-- Prune Downloads Directory ------------------------------------------------
84 count
=$
(($
(ls -1 |
wc -l) - 1))
85 for directory
in *; do
86 if [[ $count -gt 0 ]]; then
92 #-- Release Lock -------------------------------------------------------------