github.com/reds/docker@v1.11.2-rc1/contrib/report-issue.sh (about) 1 #!/bin/sh 2 3 # This is a convenience script for reporting issues that include a base 4 # template of information. See https://github.com/docker/docker/pull/8845 5 6 set -e 7 8 DOCKER_ISSUE_URL=${DOCKER_ISSUE_URL:-"https://github.com/docker/docker/issues/new"} 9 DOCKER_ISSUE_NAME_PREFIX=${DOCKER_ISSUE_NAME_PREFIX:-"Report: "} 10 DOCKER=${DOCKER:-"docker"} 11 DOCKER_COMMAND="${DOCKER}" 12 export DOCKER_COMMAND 13 14 # pulled from https://gist.github.com/cdown/1163649 15 function urlencode() { 16 # urlencode <string> 17 18 local length="${#1}" 19 for (( i = 0; i < length; i++ )); do 20 local c="${1:i:1}" 21 case $c in 22 [a-zA-Z0-9.~_-]) printf "$c" ;; 23 *) printf '%%%02X' "'$c" 24 esac 25 done 26 } 27 28 function template() { 29 # this should always match the template from CONTRIBUTING.md 30 cat <<- EOM 31 Description of problem: 32 33 34 \`docker version\`: 35 `${DOCKER_COMMAND} -D version` 36 37 38 \`docker info\`: 39 `${DOCKER_COMMAND} -D info` 40 41 42 \`uname -a\`: 43 `uname -a` 44 45 46 Environment details (AWS, VirtualBox, physical, etc.): 47 48 49 How reproducible: 50 51 52 Steps to Reproduce: 53 1. 54 2. 55 3. 56 57 58 Actual Results: 59 60 61 Expected Results: 62 63 64 Additional info: 65 66 67 EOM 68 } 69 70 function format_issue_url() { 71 if [ ${#@} -ne 2 ] ; then 72 return 1 73 fi 74 local issue_name=$(urlencode "${DOCKER_ISSUE_NAME_PREFIX}${1}") 75 local issue_body=$(urlencode "${2}") 76 echo "${DOCKER_ISSUE_URL}?title=${issue_name}&body=${issue_body}" 77 } 78 79 80 echo -ne "Do you use \`sudo\` to call docker? [y|N]: " 81 read -r -n 1 use_sudo 82 echo "" 83 84 if [ "x${use_sudo}" = "xy" -o "x${use_sudo}" = "xY" ]; then 85 export DOCKER_COMMAND="sudo ${DOCKER}" 86 fi 87 88 echo -ne "Title of new issue?: " 89 read -r issue_title 90 echo "" 91 92 issue_url=$(format_issue_url "${issue_title}" "$(template)") 93 94 if which xdg-open 2>/dev/null >/dev/null ; then 95 echo -ne "Would like to launch this report in your browser? [Y|n]: " 96 read -r -n 1 launch_now 97 echo "" 98 99 if [ "${launch_now}" != "n" -a "${launch_now}" != "N" ]; then 100 xdg-open "${issue_url}" 101 fi 102 fi 103 104 echo "If you would like to manually open the url, you can open this link if your browser: ${issue_url}" 105