forked from g7240/pipe-tf-ncr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverSideEC2Code.sh
59 lines (44 loc) · 1.55 KB
/
serverSideEC2Code.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
sleep 10
# Ensure no other apt or dpkg processes are running
sudo killall apt apt-get 2>/dev/null
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/cache/apt/archives/lock
# Wait a bit for lock removal
sleep 2
#install necessary packages
sudo apt-get update
sudo apt-get install make jq netcat-openbsd -y
# Ensure the DNS is passed as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <dns>"
exit 1
fi
DNS=$1
# test file to semonstrate the code was executed server side
echo "log: codice.sh was executed and recieved ad parameter the DNS: $DNS
" >> debugLog.log
#unzip microservice and remove the copy
tar -xzf int_didroom_issuer1.tar.gz
rm ./int_didroom_issuer1.tar.gz
#substitute the url in the config file
JSON_FILE="./microservices/int_didroom_issuer1/public/credential_issuer/.well-known/openid-credential-issuer" # The JSON file to modify
# Prefix the DNS with http:// and update the values in the JSON
jq --arg dns "$DNS" '
.credential_issuer = "http://" + $dns + "/credential_issuer" |
.credential_endpoint = "http://" + $dns + "/credential_issuer/credential" |
.authorization_servers = ["http://" + $dns + "/authz_server"]
' "$JSON_FILE" > tmp.$$.json && mv tmp.$$.json "$JSON_FILE"
if [ $? -eq 0 ]; then
echo "JSON file updated successfully.
" >> debugLog.log
else
echo "jq command failed
" >> debugLog.logg
exit 1
fi
#run the microservice
cd microservices/int_didroom_issuer1/
make > ./../../debugLog_makeStdout.log 2> ./../../debugLog_makeStderr.log &
echo "log: ran int_didroom_issuer1 make file
" >> ./../../debugLog.log