Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-27T23:37:17.646Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

clear-target-dir-if-larger-than

36 lines · 1.0 KB · text
1#!/usr/bin/env bash
2
3set -euxo pipefail
4
5if [[ $# -lt 1 || $# -gt 2 ]]; then
6    echo "usage: $0 <MAX_SIZE_IN_GB> [SMALL_CLEAN_SIZE_IN_GB]"
7    exit 1
8fi
9
10if ! [[ -d target ]]; then
11    echo "target directory does not exist yet"
12    exit 0
13fi
14
15max_size_gb=$1
16small_clean_size_gb=${2:-}
17
18if [[ -n "${small_clean_size_gb}" && ${small_clean_size_gb} -ge ${max_size_gb} ]]; then
19    echo "error: small clean threshold (${small_clean_size_gb}gb) must be smaller than max size (${max_size_gb}gb)"
20    exit 1
21fi
22
23current_size=$(du -s target | cut -f1)
24current_size_gb=$(( ${current_size} / 1024 / 1024 ))
25
26echo "target directory size: ${current_size_gb}gb. max size: ${max_size_gb}gb"
27
28if [[ ${current_size_gb} -gt ${max_size_gb} ]]; then
29    echo "clearing target directory"
30    shopt -s dotglob
31    rm -rf target/*
32elif [[ -n "${small_clean_size_gb}" && ${current_size_gb} -gt ${small_clean_size_gb} ]]; then
33    echo "running cargo clean --workspace (size above small clean threshold of ${small_clean_size_gb}gb)"
34    cargo clean --workspace
35fi
36
Served at tenant.openagents/omega Member data and write actions are omitted.