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 timestamp of the last modification of the file integrity.* for of all repositories in a JSON output.
|
2023-06-08 12:43:18 +02:00
|
|
|
# stdout will be an array like :
|
2022-12-01 13:25:10 +01:00
|
|
|
# [
|
|
|
|
# {
|
2023-08-20 16:54:21 +02:00
|
|
|
# "repositoryName": "a7035047",
|
|
|
|
# "lastSave": 1691341603
|
2022-12-01 13:25:10 +01:00
|
|
|
# },
|
|
|
|
# {
|
2023-08-20 16:54:21 +02:00
|
|
|
# "repositoryName": "a7035048",
|
|
|
|
# "lastSave": 1691342688
|
2022-12-01 13:25:10 +01:00
|
|
|
# }
|
|
|
|
# ]
|
|
|
|
|
|
|
|
|
|
|
|
# Exit when any command fails
|
|
|
|
set -e
|
|
|
|
|
2023-08-20 16:54:21 +02:00
|
|
|
# Load .env if exists
|
|
|
|
if [[ -f .env ]]; then
|
|
|
|
source .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Default value if .env not exists
|
|
|
|
: "${home:=/home/borgwarehouse}"
|
|
|
|
|
2024-03-17 20:48:14 +01:00
|
|
|
if [ -n "$(find -L "${home}"/repos -mindepth 1 -maxdepth 1 -type d)" ]; then
|
2023-10-08 16:57:13 +02:00
|
|
|
stat --format='{"repositoryName":"%n","lastSave":%Y}' \
|
2023-11-02 11:47:51 +01:00
|
|
|
"${home}"/repos/*/integrity* |
|
2023-10-08 16:57:13 +02:00
|
|
|
jq --slurp '[.[] | .repositoryName = (.repositoryName | split("/")[-2])]'
|
|
|
|
else
|
|
|
|
echo "[]"
|
|
|
|
fi
|