@@ -5,11 +5,6 @@ set -o errexit -o pipefail
5
5
: " ${COUNT:= 1} "
6
6
: " ${DOMAIN:= inmylab.de} "
7
7
8
- if test -f seats.json; then
9
- echo " ERROR: File seats.json already exists."
10
- exit 1
11
- fi
12
-
13
8
function generate_code() {
14
9
local chars=(A B C D E F G H J K L M N P Q R S T U V W X Y Z 2 3 4 5 6 7 8 9)
15
10
local length=6
@@ -26,50 +21,32 @@ function generate_code() {
26
21
echo -n " ${code} "
27
22
}
28
23
29
- result=" $(
30
- jq \
31
- --null-input \
32
- --arg name " ${SET_NAME} " \
33
- --arg count " ${COUNT} " \
34
- --arg domain " ${DOMAIN} " \
35
- --arg gitlab_admin_password " $( openssl rand -hex 32) " \
36
- --arg gitlab_admin_token " $( openssl rand -hex 32) " \
37
- '
38
- {
39
- "name": $name,
40
- "count": $count,
41
- "domain": $domain,
42
- "gitlab_admin_password": $gitlab_admin_password,
43
- "gitlab_admin_token": $gitlab_admin_token,
44
- "seats": []
45
- }
46
- '
47
- ) "
48
-
49
- for INDEX in $( seq 0 $(( COUNT - 1 )) ) ; do
50
- result=" $(
51
- echo " ${result} " | jq \
52
- --arg index " ${INDEX} " \
53
- --arg password " $( openssl rand -hex 32) " \
54
- --arg code " $( generate_code) " \
55
- --arg gitlab_token " $( openssl rand -hex 32) " \
56
- --arg webdav_pass_dev " $( openssl rand -hex 32) " \
57
- --arg webdav_pass_live " $( openssl rand -hex 32) " \
58
- '
59
- . as $all |
60
- $all.seats +=
61
- [{
62
- "index": $index,
63
- "password": $password,
64
- "code": $code,
65
- "gitlab_token": $gitlab_token,
66
- "webdav_pass_dev": $webdav_pass_dev,
67
- "webdav_pass_live": $webdav_pass_live
68
- }]
69
- '
70
- ) "
71
- done
72
- echo " ${result} " > seats.json
24
+ if ! test -f seats.json; then
25
+ for INDEX in $( seq 0 $(( COUNT - 1 )) ) ; do
26
+ result=" $(
27
+ echo " ${result} " | jq \
28
+ --arg index " ${INDEX} " \
29
+ --arg password " $( openssl rand -hex 32) " \
30
+ --arg code " $( generate_code) " \
31
+ --arg gitlab_token " $( openssl rand -hex 32) " \
32
+ --arg webdav_pass_dev " $( openssl rand -hex 32) " \
33
+ --arg webdav_pass_live " $( openssl rand -hex 32) " \
34
+ '
35
+ . as $all |
36
+ $all.seats +=
37
+ [{
38
+ "index": $index,
39
+ "password": $password,
40
+ "code": $code,
41
+ "gitlab_token": $gitlab_token,
42
+ "webdav_pass_dev": $webdav_pass_dev,
43
+ "webdav_pass_live": $webdav_pass_live
44
+ }]
45
+ '
46
+ ) "
47
+ done
48
+ echo " ${result} " > seats.json
49
+ fi
73
50
74
51
UNIQUE_CODES_COUNT=" $(
75
52
jq --raw-output ' .seats[].code' seats.json \
0 commit comments