-
Notifications
You must be signed in to change notification settings - Fork 0
/
diploi-credential-helper
32 lines (22 loc) · 1.04 KB
/
diploi-credential-helper
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
#!/bin/sh
#
# Script for continuous updates of github write token for repository
#
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` Starting $1 >> /var/log/git-credential-helper.log
# Check that the helper is called with the "get" argument
test "$1" = get || exit 2;
# Read core token from file
repository=app
ct=`cat /etc/diploi-git/credential-token-$repository` || exit 3;
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` CredentialToken $ct >> /var/log/git-credential-helper.log
# Call the core API endpoint with the token
gt=`curl -s -X GET http://core.diploi/git-token/$ct` || exit 4;
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` AccessToken $gt >> /var/log/git-credential-helper.log
# Pick the relevant information from the output
username=`echo "$gt" | sed -n '1p'`;
password=`echo "$gt" | sed -n '2p'`;
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` username=$username >> /var/log/git-credential-helper.log
echo `date -u +"%Y-%m-%dT%H:%M:%SZ"` password=$password >> /var/log/git-credential-helper.log
# Write credentials to helper output
echo "username=$username";
echo "password=$password";