-
Notifications
You must be signed in to change notification settings - Fork 3
/
createArchiva.sh
executable file
·103 lines (90 loc) · 2.48 KB
/
createArchiva.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
#!/bin/bash
set -e
. config.rc
CONFIG_DIR=${FORGE_CONFIG_DIR}/archiva
mkdir -p ${CONFIG_DIR}/conf
chmod -R 777 ${CONFIG_DIR}
cp -v archiva/archiva.xml ${CONFIG_DIR}/conf
docker run \
--name ${FORGE_PREFIX}-${ARCHIVA_NAME} \
--net ${CI_NETWORK} \
--volume ${CONFIG_DIR}:/archiva-data \
--publish ${ARCHIVA_PORT}:8080 \
--detach ${ARCHIVA_IMAGE_NAME}
until curl --location --output /dev/null --silent --write-out "%{http_code}\\n" "http://localhost:${ARCHIVA_PORT}/" | grep 200 &>/dev/null
do
echo -e "${YELLOW}Waiting for Archiva${NC}"
sleep 1
done
generate_admin_data()
{
cat <<EOF
{
"username":"admin",
"password":"${ADMIN_PWD}",
"confirmPassword":"${ADMIN_PWD}",
"fullName":"URJC CI Forge",
"email":"${ADMIN_EMAIL}",
"assignedRoles":[],
"modified":true,
"rememberme":false,
"logged":false
}
EOF
}
curl -v "http://localhost:${ARCHIVA_PORT}/restServices/redbackServices/userService/createAdminUser" \
-H "Origin: http://localhost:${ARCHIVA_PORT}" \
-H "Content-Type: application/json" \
-H "Referer: http://localhost:${ARCHIVA_PORT}/" \
-H "Connection: keep-alive" \
--data "$(generate_admin_data)" --compressed
echo ""
generate_user_data()
{
cat <<EOF
{
"username":"${DEVELOPER1_USERNAME}",
"password":"${DEVELOPER1_PASSWORD}",
"confirmPassword":"${DEVELOPER1_PASSWORD}",
"fullName":"developer",
"email":"${DEVELOPER1_EMAIL}",
"modified":true,
"rememberme":false,
"logged":false,
"validated":true
}
EOF
}
curl -v "http://localhost:${ARCHIVA_PORT}/restServices/redbackServices/userService/createUser" \
-u admin:${ADMIN_PWD} \
-H "Origin: http://localhost:${ARCHIVA_PORT}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Referer: http://localhost:${ARCHIVA_PORT}/" \
-H "Connection: keep-alive" \
--data "$(generate_user_data)" --compressed
echo ""
generate_user_role()
{
cat <<EOF
{
"username": "${DEVELOPER1_USERNAME}",
"assignedRoles": ["Registered User", "Global Repository Manager", "Global Repository Observer"],
"fullName":"developer",
"email":"${DEVELOPER1_EMAIL}",
"locked":false,
"logged":false,
"modified":true,
"rememberme": false
}
EOF
}
curl -v "http://localhost:${ARCHIVA_PORT}/restServices/redbackServices/roleManagementService/updateUserRoles" \
-u admin:${ADMIN_PWD} \
-H "Origin: http://localhost:${ARCHIVA_PORT}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Referer: http://localhost:${ARCHIVA_PORT}/" \
-H "Connection: keep-alive" \
--data "$(generate_user_role)" --compressed
echo ""