From 16fca14853765a7adb1a3c46ad1b4ef4543c700f Mon Sep 17 00:00:00 2001 From: bill-auger Date: Sun, 17 Dec 2017 12:09:51 -0500 Subject: add report-bug script --- bin/report-bug.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 bin/report-bug.sh (limited to 'bin') diff --git a/bin/report-bug.sh b/bin/report-bug.sh new file mode 100755 index 0000000..a93423a --- /dev/null +++ b/bin/report-bug.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +# BEGIN installer-specific params +readonly REDMINE_PROJECT_ID=8 +readonly ISSUE_TITLE="[IMSTALL-MEDIA]: report-bug.sh uploaded install.log" +readonly ISSUE_DESC="" +readonly UPLOAD_FILENAME="install.log" +readonly UPLOAD_MIMETYPE='text/plain' +readonly UPLOAD_DESC="$(grep 'VERSION_ID=' /etc/os-release) $(grep 'VARIANT_ID=' /etc/os-release)" +readonly UPLOAD_FILE=/home/parabola/Desktop/install.log +# TODO: generalize this script to handle image uploads and user-selected tracker and description +# readonly REDMINE_PROJECT_ID=$1 +# readonly ISSUE_TITLE="$2" +# readonly UPLOAD_FILENAME="$3" +# readonly UPLOAD_MIMETYPE="$4" +# readonly UPLOAD_DESC="$5" +# readonly UPLOAD_FILE="$6" +# END installer-specific params + + +readonly REDMINE_URL=https://labs.parabola.nu +readonly REDMINE_API_KEY='978ee27e1b21969eeeae83a1760b7467b63d32bf' +readonly POST_UPLOADS_URL=$REDMINE_URL/uploads.xml +readonly POST_ISSUES_URL=$REDMINE_URL/issues.xml +readonly POST_UPLOADS_MIMETYPE='application/octet-stream' +readonly POST_ISSUES_MIMETYPE='application/xml' +readonly POST_ISSUE_XML_FMT=" + + %s + %s + %s%s + +" +readonly UPLOADS_XML_FMT=" + %s + +" +readonly UPLOAD_XML_FMT=" + + %s + %s + %s + %s + +" + + +: < + + 338.261c95326446ce36879671466457f2db + +EXAMPLE_UPLOAD_RESPONSE + +: < + + 1576 + + + + + + Creating an issue with a uploaded file via curl + details here ... + 2017-12-17 + + 0 + false + + + 2017-12-17T16:07:38Z + 2017-12-17T16:07:38Z + + +EXAMPLE_CREATE_ISSUE_RESPONSE + + +PostRequest() +{ + mimetype=$1 + body=$2 + url=$3 + + curl -X POST \ + --header "Content-Type: $mimetype" \ + --header "X-Redmine-API-Key: $REDMINE_API_KEY" \ + --data-binary "$body" \ + $url +} + + +if [ "$UPLOAD_FILE" ] +then resp=$(PostRequest $POST_UPLOADS_MIMETYPE "@$UPLOAD_FILE" $POST_UPLOADS_URL) + upload_token=$(echo "$resp" | sed 's|.*\(.*\).*|\1|' + [ -z "$upload_token" ] && echo "upload failed" && exit 1 + + upload_xml=$(printf "$UPLOAD_XML_FMT" "$upload_token" "$UPLOAD_FILENAME" \ + "$UPLOAD_DESC" $UPLOAD_MIMETYPE ) + uploads_xml=$(printf "$UPLOADS_XML_FMT" "$upload_xml") +fi +issue_xml=$(printf "$POST_ISSUE_XML_FMT" $REDMINE_PROJECT_ID "$ISSUE_TITLE" \ + "$ISSUE_DESC" "$uploads_xml" ) +resp=$(PostRequest $POST_ISSUES_MIMETYPE "$issue_xml" $POST_ISSUES_URL) +echo "$(echo "$resp" | sed 's|.*\(.*\).*|\1|')" -- cgit v1.2.2