#! /bin/bash # Lecture configuration pad CONFIG_PAD="/etc/pad.chapril.org/padchaprilorg.conf" source ${CONFIG_PAD} # Lecture configuration agirbot CONFIG_AGIRBOT="/etc/chagirbot/agiraprilorg.conf" source ${CONFIG_AGIRBOT} main() { post_report } post_report() { datafile=$(mktemp /tmp/report_stats_$(date +%Y-%m-%d_%H%M)_XXXX.json) cat < "${datafile}" { "issue": { "notes": "$(python3 /srv/pad.chapril.org/tools/rapports_activites/generate_pad_stats.py | sed -z 's/\n/\\n/g')" } } EOF curl -v -s \ -H "Content-Type: application/json" \ -H "X-Redmine-API-Key: ${key}" \ -X PUT --data-binary "@${datafile}" \ "${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json" rm "${datafile}" } last_comment_date() { curl -H "X-Redmine-API-Key: ${key}" -s "${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json?include=journals" \ | jq '.issue.journals | last | .created_on' } list() { curl -H "X-Redmine-API-Key: ${key}" -s "${REDMINE_BASE_URL}/issues/${REDMINE_TICKET_ID}.json?include=journals" \ | jq '.issue.journals[] | [.user.name, .notes]' } main