24 lines
877 B
Bash
Executable File
24 lines
877 B
Bash
Executable File
#!/bin/bash
|
|
# changelog.sh — Append an entry to the Hermes changelog
|
|
# Usage: changelog.sh "Category" "Description"
|
|
# changelog.sh "Backup" "Changed S3 sync from hourly to every 15 min"
|
|
# changelog.sh "SSH" "Deployed itpp-infra key to all servers"
|
|
# changelog.sh "$(date +%H:%M)" "Quick note without a category"
|
|
|
|
CHANGELOG="/root/.hermes/CHANGELOG.md"
|
|
DATE=$(date "+%Y-%m-%d")
|
|
TIME=$(date "+%H:%M")
|
|
CATEGORY="${1:-General}"
|
|
DESCRIPTION="${2:-No description}"
|
|
|
|
# Create a new date section if this is the first entry for today
|
|
if ! grep -q "^## $DATE" "$CHANGELOG" 2>/dev/null; then
|
|
echo -e "\n---\n## $DATE\n" >> "$CHANGELOG"
|
|
fi
|
|
|
|
# Insert the entry under today's section
|
|
# We use sed to find today's section and append after it
|
|
sed -i "/^## $DATE/a\\\n### $CATEGORY\n- $DESCRIPTION" "$CHANGELOG"
|
|
|
|
echo "✅ Changelog entry added: [$DATE] $CATEGORY — $DESCRIPTION"
|