-
Notifications
You must be signed in to change notification settings - Fork 35
/
ssikit.sh
executable file
·157 lines (142 loc) · 2.78 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
#!/bin/bash
set -e
function header() {
echo "waltid-ssikit wrapper script"
echo
}
function build() {
echo "Building walt.id build files..."
if ./gradlew clean build installDist; then
echo
echo "Build was successful."
echo
else
echo
echo "Build was unsuccessful."
exit
echo
fi
}
function build_skip_tests() {
echo "Building walt.id build files..."
if ./gradlew clean installDist -x test; then
echo
echo "Build was successful."
echo
else
echo
echo "Build was unsuccessful."
exit
echo
fi
}
function build_docker() {
if docker build -t waltid/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 waltid/ssikit .; then
echo
echo "Podman container build was successful."
echo
else
echo
echo "Podman container build was unsuccessful."
echo
exit
fi
}
function build_runscript_question() {
header
echo "Cannot run walt.id: Runscript does not exist."
echo "Have you run 'build' yet? ($0 build)"
echo
echo -n "Do you want to build ($0 build)? [y/n]: "
read -r ans
}
function execute_debug() {
if [[ -f build/install/waltid-ssikit/bin/waltid-ssikit ]]; then
JAVA_OPTS="-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG" build/install/waltid-ssikit/bin/waltid-ssikit "$@"
else
build_runscript_question
if [[ $ans != "n" ]]; then
build_skip_tests
execute_debug "$@"
fi
fi
}
function execute() {
if [[ -f build/install/waltid-ssikit/bin/waltid-ssikit ]]; then
build/install/waltid-ssikit/bin/waltid-ssikit "$@"
else
build_runscript_question
if [[ $ans != "n" ]]; then
build_skip_tests
execute "$@"
fi
fi
}
function clean() {
./gradlew clean
}
function help() {
echo "Usage: $0 {build|build-st|build-docker|build-podman|extract|--verbose|execute (default)}"
echo
echo "Use \"execute\" to execute waltid-ssikit with no arguments. If you don't supply any"
echo "arguments of {build|build-st|build-docker|build-podman|extract}, waltid-ssikit 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
;;
clean)
header
clean
;;
help)
header
help
;;
-v | --verbose | -d | --debug)
shift
execute_debug "$@"
;;
execute)
shift
execute "$@"
;;
*)
execute "$@"
;;
esac
fi