jlanuti | 6f30d40 | 2007-04-18 19:54:42 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # script to delete warm-up builds, except the one promoted |
| 3 | # the promoted on is left just for safety |
| 4 | |
| 5 | |
| 6 | declaredStream=$1 |
| 7 | declaredDir=$2 |
| 8 | # make sure directories to delete start with same 3 chars as target |
| 9 | pattern=${declaredDir:0:5} |
| 10 | |
| 11 | |
| 12 | echo restrict to directory names that match $pattern |
| 13 | echo act on directories older than $declaredDir |
| 14 | |
| 15 | |
| 16 | # example of full form from command line |
| 17 | # find ./drops -maxdepth 1 -type d -name I-I* -not -cnewer drops/I-I200603180020-200603180020 -exec rm -fr {} \; |
| 18 | |
| 19 | |
| 20 | if [ "$3" != "-doit" ] ; then |
| 21 | echo " This is a dry run. Add -doit to actually remove" |
| 22 | thisCommand=" echo " |
| 23 | else |
| 24 | thisCommand=" rm -fr " |
| 25 | fi |
| 26 | |
| 27 | |
| 28 | |
| 29 | find ./drops -maxdepth 2 -type d -name "$pattern*" -not -newer "./drops/$declaredStream/$declaredDir" -exec $thisCommand {} \; |
| 30 | |
| 31 | |
| 32 | |
| 33 | |