mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-11 18:29:17 +00:00
Create update-json.sh
This commit is contained in:
parent
f03471133e
commit
33ee969d91
23
.github/workflows/scripts/update-json.sh
vendored
Normal file
23
.github/workflows/scripts/update-json.sh
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILE=$1
|
||||
TODAY=$(date -u +"%Y-%m-%d")
|
||||
|
||||
if [[ -z "$FILE" ]]; then
|
||||
echo "No file specified. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$FILE" ]]; then
|
||||
echo "File $FILE not found. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DATE_IN_JSON=$(jq -r '.date_created' "$FILE" 2>/dev/null || echo "")
|
||||
|
||||
if [[ "$DATE_IN_JSON" != "$TODAY" ]]; then
|
||||
echo "Updating $FILE: $DATE_IN_JSON -> $TODAY"
|
||||
jq --arg date "$TODAY" '.date_created = $date' "$FILE" > tmp.json && mv tmp.json "$FILE"
|
||||
else
|
||||
echo "No update needed."
|
||||
fi
|
Loading…
Reference in New Issue
Block a user