fix posix arithmetic expression; fix find statement
This commit is contained in:
parent
82f93c1499
commit
5cb5edc9b3
2 changed files with 5 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
FILE_QUOTA=${FILE_QUOTA:-7}
|
||||
FILE_QUOTA=$(("$FILE_QUOTA" + 1))
|
||||
FILE_QUOTA=$((FILE_QUOTA + 1))
|
||||
TO_DELETE=$( b2v4 ls b2://"$BUCKET_NAME" | tac | tail -n +"$FILE_QUOTA" | tr '\n' ' ' )
|
||||
|
||||
PIDS=""
|
||||
|
|
|
@ -7,17 +7,17 @@ list_after_n() {
|
|||
ARCHIVE_DIR=${ARCHIVE_DIR:-"/archive"}
|
||||
FILE_QUOTA=${FILE_QUOTA:-7}
|
||||
|
||||
old_archives=$( find "$ARCHIVE_DIR" -maxdepth 1 -type f -printf "%f\n" )
|
||||
old_dirs=$( find "$ARCHIVE_DIR" -maxdepth 1 -mindepth 1 -type d -printf "%f\n" )
|
||||
old_archives=$( find "$ARCHIVE_DIR" -maxdepth 1 -type f -print )
|
||||
old_dirs=$( find "$ARCHIVE_DIR" -maxdepth 1 -mindepth 1 -type d -print )
|
||||
|
||||
last_n_archives=$( list_after_n "$old_archives" "$FILE_QUOTA" )
|
||||
last_n_dirs=$( list_after_n "$old_dirs" "$FILE_QUOTA" )
|
||||
|
||||
for archive in $last_n_archives; do
|
||||
rm "$ARCHIVE_DIR/$archive"
|
||||
rm "$archive"
|
||||
done
|
||||
|
||||
for dir in $last_n_dirs; do
|
||||
rm -r "$ARCHIVE_DIR/$dir"
|
||||
rm -r "$dir"
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue