Stephan Massalt | 752d3b6 | 2020-02-01 17:19:46 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Austin Schuh | 512b98f | 2020-12-28 13:12:16 -0800 | [diff] [blame^] | 3 | # Set default for disk utilisation |
| 4 | readonly DMAX="${1:-80%}" |
| 5 | # Cache folder |
| 6 | readonly CACHE_FOLDER="${HOME}/.cache/bazel/disk_cache/" |
| 7 | # Retrieve disk usages in percentage |
| 8 | readonly DSIZE="$(df -hlP "${CACHE_FOLDER}" | sed 1d | awk '{print $5}')" |
Stephan Massalt | 752d3b6 | 2020-02-01 17:19:46 -0800 | [diff] [blame] | 9 | |
Austin Schuh | 512b98f | 2020-12-28 13:12:16 -0800 | [diff] [blame^] | 10 | if [[ ${DSIZE} > ${DMAX} ]]; then |
| 11 | echo "$(hostname): Disk over ${DMAX} Clean up needed on node." |
| 12 | rm -rf "${CACHE_FOLDER}" |
Stephan Massalt | 752d3b6 | 2020-02-01 17:19:46 -0800 | [diff] [blame] | 13 | else |
Austin Schuh | 512b98f | 2020-12-28 13:12:16 -0800 | [diff] [blame^] | 14 | echo "$(hostname): No clean up needed. Disk usage is at: ${DSIZE}" |
Stephan Massalt | 752d3b6 | 2020-02-01 17:19:46 -0800 | [diff] [blame] | 15 | fi |