forked from walt-id/waltid-ssikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssikit.sh
executable file
·164 lines (148 loc) · 3.11 KB
/
ssikit.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
set -e
function header() {
echo "waltid-ssi-kit wrapper script"
echo
}
function build() {
echo "Building walt.id build files..."
if ./gradlew clean build; then
echo
echo "Build was successful."
echo "Continuing with build file extraction..."
echo
extract
else
echo
echo "Build was unsuccessful. Will not extract the build files."
exit
echo
fi
}
function build_skip_tests() {
echo "Building walt.id build files..."
if ./gradlew clean build -x test; then
echo
echo "Build was successful."
echo "Continuing with build file extraction..."
echo
extract
else
echo
echo "Build was unsuccessful. Will not extract the build files."
exit
echo
fi
}
function build_docker() {
if docker build -t ssikit .; then
echo
echo "Docker container build was successful."
echo
else
echo
echo "Docker container build was unsuccessful."
echo
exit
fi
}
function build_podman() {
if podman build -t ssikit .; then
echo
echo "Podman container build was successful."
echo
else
echo
echo "Podman container build was unsuccessful."
echo
exit
fi
}
function extract() {
echo "Extracting walt.id build files..."
echo
if [[ ! -d build/distributions ]]; then
echo "The directory ./build/distributions does not exist."
echo "Have you run \"./ssikit.sh build\" yet?"
echo
exit
fi
if [[ ! -f build/distributions/waltid-ssi-kit-1.1-SNAPSHOT.tar ]]; then
echo "The build files do not exist (directory ./build/distributions)."
echo "Have you run \"./ssikit.sh build\" yet?"
echo
exit
fi
(
cd build/distributions
if tar xf waltid-ssi-kit-1.1-SNAPSHOT.tar; then
echo "Extraction successful."
else
echo "Extracting was unsuccessful."
echo
exit
fi
echo
)
}
function execute() {
if [[ -f build/distributions/waltid-ssi-kit-1.1-SNAPSHOT/bin/waltid-ssi-kit ]]; then
build/distributions/waltid-ssi-kit-1.1-SNAPSHOT/bin/waltid-ssi-kit "$@"
else
header
echo "Cannot run walt.id: Runscript does not exist."
echo "Have you built and extracted the buildfiles? ($0 build)"
echo
echo -n "Do you want to build ($0 build)? [y/n]: "
read -r ans
if [[ $ans != "n" ]]; then
build
execute "$@"
fi
fi
}
function help() {
echo "Usage: $0 {build|build-docker|build-podman|extract|execute (default)}"
echo
echo "Use \"execute\" to execute waltid-ssi-kit with no arguments. If you don't supply any"
echo "arguments of {build|build-docker|build-podman|extract|execute}, waltid-ssi-kit will"
echo "be executed with the provided arguments."
}
if [[ $# -eq 0 ]]; then
header
help
else
case "$1" in
build | rebuild)
header
build
;;
build-st | rebuild-st)
header
build_skip_tests
;;
build-docker | rebuild-docker)
header
build_docker
;;
build-podman | rebuild-podman)
header
build_podman
;;
extract)
header
extract
;;
execute)
shift
execute "$@"
;;
help)
header
help
;;
*)
execute "$@"
;;
esac
fi