2017-04-08 13:56:31 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Remove all but the N newest test run dirs (that have been started)
|
|
|
|
|
|
|
|
trial_rx_dir="$1"
|
|
|
|
trial_prep_dir="$2"
|
|
|
|
if [ -z "$trial_rx_dir" ]; then
|
2017-05-11 15:39:02 +00:00
|
|
|
trial_rx_dir="/var/tmp/osmo-gsm-tester/trials"
|
2017-04-08 13:56:31 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$trial_prep_dir" ]; then
|
2017-05-11 15:39:02 +00:00
|
|
|
trial_prep_dir="/var/tmp/osmo-gsm-tester/.prep-trials"
|
2017-04-08 13:56:31 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$trial_prep_dir"
|
|
|
|
|
|
|
|
rm_trial() {
|
|
|
|
trial_dir="$1"
|
|
|
|
trial_name="$(basename "$trial_dir")"
|
|
|
|
echo "Removing: $(ls -ld "$trial_dir")"
|
|
|
|
# ensure atomic removal, so that the gsm-tester doesn't take it as a
|
2017-05-06 19:56:27 +00:00
|
|
|
# newly added dir (can happen when the 'taken' marker is removed first).
|
2017-04-08 13:56:31 +00:00
|
|
|
mv "$trial_dir" "$trial_prep_dir/"
|
|
|
|
rm -rf "$trial_prep_dir/$trial_name"
|
|
|
|
}
|
|
|
|
|
|
|
|
# keep the N newest test session dirs that have been started: find all that
|
|
|
|
# have been started sorted by time, then discard all but the N newest ones.
|
|
|
|
|
2017-05-06 19:56:27 +00:00
|
|
|
for seen in $(ls -1t "$trial_rx_dir"/*/taken | tail -n +31); do
|
2017-04-08 13:56:31 +00:00
|
|
|
rm_trial "$(dirname "$seen")"
|
|
|
|
done
|