-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckJiraCredentials
41 lines (38 loc) · 1.21 KB
/
checkJiraCredentials
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
HERE=$(dirname ${BASH_SOURCE[0]})
. ${HERE}/fixpath
function finish {
\rm /tmp/testcredentials$$
}
trap finish EXIT
if ! checkDANKEY ; then
exit 1
fi
JIRACRED=
while true; do
if JIRACRED=$(jirac) ; then
if [ -n "$JIRACRED" ] ; then
# test they work
curl -sS -k -u "$JIRACRED" -H "Content-Type: application/json" -X GET https://jira.code.one/rest/api/2/configuration > /tmp/testcredentials$$ 2>&1
if badcredentials /tmp/testcredentials$$ ; then
>&2 echo Unauthorized.
>&2 echo Report here: /tmp/testcredentials$$
>&2 echo You should rerun ${HERE}/refreshsavedjiracredentials
echo -n 'Do that now? [Y/n] '
read okay
if [ "${okay:0:1}" != "y" -a "${okay:0:1}" != "Y" ] ; then
exit 1
fi
else
break
fi
fi
fi
JIRACRED=
>&2 echo Excrypted jira credentials not found.
if ! refreshsavedjiracredentials ; then
>&2 echo Aborting.
>&2 echo Please run ${HERE}/refreshsavedjiracredentials, or rerun this script to try again.
exit 1
fi
done