Changeset 30410 for other-projects
- Timestamp:
- 2016-03-16T19:46:02+13:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/expeditee-release-kits/process_incoming.sh
r30408 r30410 3 3 # This script is for use on the machine where the nightly Expeditee binaries are to be 4 4 # uploaded. Put this script in the same folder as the uploads are meant to go. 5 # When any binary or its log *.out file is being uploaded via secure shell, this script 6 # will be called. The invocation of this script should go into .ssh/authorizedkeys. 7 # Then this script will delete all other files in this folder that have the same naming 8 # pattern as the uploaded binary/log file, excepting any existing file with the current 9 # date in its name (in case this turns out to be the uploaded file itself). 5 # When any binary's log *.out file is being uploaded via secure shell (which is fast), 6 # this script's called. The invocation of this script should go into .ssh/authorizedkeys. 7 # Then this script will delete all other log and binary files in this folder for the same 8 # os-release that are not of the current date (in case it's the uploaded file itself). 9 # The code didn't work if the binary was processed independent of the log file, since the 10 # bin's filename (and hence target os) could not be determined as it was still being 11 # uploaded. 10 12 11 13 12 # http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script 14 # http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script 13 15 date=`date +%Y-%m-%d` 14 16 … … 18 20 #incoming_file=$1 19 21 incoming_file=`ls -rt *$date* 2>/dev/null | tail -n 1` 20 echo $incoming_file 22 #echo "Hello world. Incoming file: $incoming_file" >> out.txt 21 23 22 24 # arrays 23 25 # make sure -linux64 comes before linux, because we'll be matching against these 24 26 # strings, so need the longest strings to be matched first. 25 bin_suffix=("-linux64" "-linux" "-windows.exe" "-MacOS-intel-MountainLion.dmg")26 27 rke_suffix=("-linux64" "-linux" "-windows" "-mac-MountainLion") 27 28 os_substr=("-linux64" "-linux" "-windows" "-MountainLion") 29 #bin_suffix=("-linux64" "-linux" "-windows.exe" "-MacOS-intel-MountainLion.dmg") 28 30 29 31 # http://stackoverflow.com/questions/2172352/in-bash-how-can-i-check-if-a-string-begins-with-some-value … … 63 65 64 66 shopt -u nullglob 65 fi66 67 67 # binaries start with "Expeditee-1-" 68 bin_file_pattern= 69 if [[ $incoming_file == "Expeditee-"* ]] ; then 70 for suffix in ${bin_suffix[@]}; do 71 if [[ $incoming_file == *"$suffix" ]]; then 72 bin_file_pattern="Expeditee-1-*$suffix" 68 # We now know the OS for the binary associated with the rke log 69 # that's being uploaded too. Delete all bins for this OS except 70 # any with the current date. 71 72 bin_file_pattern= 73 # binaries start with "Expeditee-1-" 74 for os_str in ${os_substr[@]}; do 75 if [[ $incoming_file == *"$os_str"* ]]; then 76 bin_file_pattern="Expeditee-1-*$os_str*" 73 77 break 74 78 fi 75 79 done 76 80 77 81 # ONE WAY: 78 82 #echo "found $bin_file_pattern" 79 83 # -f to make it silent: will also be silent if there's nothing to rm 80 84 #rm -rf $bin_file_pattern 81 85 82 86 # OR: 83 87 # get rid of all files of the pattern that are not of the current date … … 87 91 for file in ${files[@]}; do 88 92 # set nullglob earlier, so won't be here if there's no file that matched 89 if [[ $file != "Expeditee-1-$date$suffix"]]; then90 echo "$file" 93 if [[ $file != *"$date"* ]] || [[ $file != *"$os_str"* ]]; then 94 echo "$file" 91 95 rm -rf $file 92 96 fi … … 95 99 fi 96 100 101 97 102 # clean up ._Expeditee-1-YYYY-MM-DD-MacOS-intel-MountainLion.dmg temp files 98 103 #ls -la "._Expeditee*dmg"
Note:
See TracChangeset
for help on using the changeset viewer.