2023-06-08 12:59:00 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-12-01 13:25:10 +01:00
|
|
|
|
|
|
|
# Shell created by Raven for BorgWarehouse.
|
|
|
|
# Get the size of all repositories in a JSON output.
|
2023-06-08 12:34:19 +02:00
|
|
|
# stdout will be an array like :
|
2022-12-01 13:25:10 +01:00
|
|
|
# [
|
|
|
|
# { size: 32, name: '10e73223' },
|
|
|
|
# { size: 1155672, name: '83bd4ef1' },
|
|
|
|
# { size: 112, name: '635a6f8b' },
|
|
|
|
# { size: 32, name: 'bce68e87' },
|
|
|
|
# { size: 44, name: 'e4c04552' },
|
|
|
|
# ];
|
|
|
|
|
|
|
|
# Exit when any command fails
|
|
|
|
set -e
|
|
|
|
|
2023-08-20 20:54:27 +02:00
|
|
|
# Load .env if exists
|
|
|
|
if [[ -f .env ]]; then
|
|
|
|
source .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Default value if .env not exists
|
|
|
|
: "${home:=/home/borgwarehouse}"
|
|
|
|
|
2022-12-01 13:25:10 +01:00
|
|
|
# Use jc to output a JSON format with du command
|
2023-11-02 11:47:51 +01:00
|
|
|
cd "${home}"/repos
|
2023-08-20 20:54:27 +02:00
|
|
|
du -s -- * | jc --du
|