Changeset 29998


Ignore:
Timestamp:
2015-06-30T18:01:24+12:00 (6 years ago)
Author:
ak19
Message:

Corrections to make_latest function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nightly-tasks/crons-and-scripts/do-snapshots-and-latest.sh

    r29996 r29998  
    167167    echo ""
    168168    #echo "In MAKE_LATEST"
     169
     170    # Using local variable to loop through files, seen in http://mywiki.wooledge.org/ParsingLs
     171    local latest
     172    local file
     173    local suffix
    169174   
    170175    # find the latest file in caveat, since this script is called upon each upload to puka's caveat
    171176    # http://stackoverflow.com/questions/5885934/bash-function-to-find-newest-file-matching-pattern
    172177    # http://mywiki.wooledge.org/BashFAQ/003
     178    # http://tldp.org/LDP/abs/html/fto.html, where f1 -nt f2 means file f1 is newer than file f2
     179    # http://superuser.com/questions/687523/get-the-last-file-name-in-a-variable-in-bash
     180
    173181    unset -v latest
    174     for file in "${caveat_dir}"*; do
    175     [[ -f $file ]] && [[ $file -nt $latest ]] && latest=$file
     182    #for file in "${caveat_dir}"*; do
     183    #then file would be the full path. Instead, cd into the caveat dir to just get the filename
     184    cd $caveat_dir
     185    for file in *; do
     186    [[ -f $file ]] && [[ "$file" != *"latest-server.exe" ]] && [[ "$file" != *"Greenstone3-latest-source.tar.gz" ]] && [[ $file -nt $latest ]] && latest=$file
    176187    done
     188    cd -
    177189
    178190    # latest will not be undef, because this script is only ever called upon a legitimate
    179191    # file upload into puka's caveat-emptor location   
    180     # E.g. for testing, latest=Greenstone-3.07-candidate-2015.06.26-linux   
     192    # E.g. for testing, latest=Greenstone-3.07-candidate-2015.06.30-linux-x64
    181193    echo "Latest file in caveat is: $latest"
    182194
     
    211223
    212224        # make a hardlink of the $latest file into the caveat_latest folder
     225        echo "Making a hardlink to ${caveat_dir}$latest in ${latest_dir}$latest"
    213226        ln ${caveat_dir}$latest ${latest_dir}$latest
    214227    #else
Note: See TracChangeset for help on using the changeset viewer.